<commit_before><?php
/**
 * Customisations to {@link Payment} specifically
 * for the ecommerce module.
 *
 * @package ecommerce
 */
class EcommercePayment extends DataObjectDecorator {

	function extraStatics() {

		return array(
			'has_one' => array(
				'Order' => 'Order'
			),
			'searchable_fields' => array(
				'OrderID' => array('title' => 'Order ID'),
				'Amount' => array('title' => 'Amount'),
				'IP' => array('title' => 'IP Address', 'filter' => 'PartialMatchFilter'),
				'Status'
			)
		);
	}

	function canCreate($member = null) {
		return false;
	}

	function canDelete($member = null) {
		return false;
	}

	function updateSummaryFields(&$fields){
		$fields['Created'] = 'Date';
		$fields['OrderID'] = 'OrderID';
		$fields['Amount'] = 'Amount';
		$fields['IP'] = 'Amount';
		$fields['Total'] = 'Total';
	}

	function onBeforeWrite() {
		if($this->owner->Status == 'Success' && $this->owner->Order()) {
			$order = $this->owner->Order();
			$order->Status = 'Paid';
			$order->write();
			$order->sendReceipt();
		}
	}

	function redirectToOrder() {
		$order = $this->owner->Order();
		Director::redirect($order->Link());
		return;
	}

	function setPaidObject(DataObject $do){
		$this->owner->PaidForID = $do->ID;
		$this->owner->PaidForClass = $do->ClassName;
	}


}<commit_msg>added a payment migration piece of code...<commit_after><?php
/**
 * Customisations to {@link Payment} specifically
 * for the ecommerce module.
 *
 * @package ecommerce
 */
class EcommercePayment extends DataObjectDecorator {

	function extraStatics() {

		return array(
			'has_one' => array(
				'Order' => 'Order'
			),
			'searchable_fields' => array(
				'OrderID' => array('title' => 'Order ID'),
				'Amount' => array('title' => 'Amount'),
				'IP' => array('title' => 'IP Address', 'filter' => 'PartialMatchFilter'),
				'Status'
			)
		);
	}

	function canCreate($member = null) {
		return false;
	}

	function canDelete($member = null) {
		return false;
	}

	function updateSummaryFields(&$fields){
		$fields['Created'] = 'Date';
		$fields['OrderID'] = 'OrderID';
		$fields['Amount'] = 'Amount';
		$fields['IP'] = 'Amount';
		$fields['Total'] = 'Total';
	}

	function onBeforeWrite() {
		if($this->owner->Status == 'Success' && $this->owner->Order()) {
			$order = $this->owner->Order();
			$order->Status = 'Paid';
			$order->write();
			$order->sendReceipt();
		}
	}

	function redirectToOrder() {
		$order = $this->owner->Order();
		Director::redirect($order->Link());
		return;
	}

	function setPaidObject(DataObject $do){
		$this->owner->PaidForID = $do->ID;
		$this->owner->PaidForClass = $do->ClassName;
	}

	function requiredDefaultRecords() {
		$bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
		parent::requiredDefaultRecords();
		if(isset($_GET["updatepayment"])) {
			DB::query("
				UPDATE {$bt}Payment{$bt}
				SET {$bt}AmountAmount{$bt} = {$bt}Amount{$bt}
				WHERE
					{$bt}Amount{$bt} > 0
					AND (
						{$bt}AmountAmount{$bt} IS NULL
						OR {$bt}AmountAmount{$bt} = 0
					)
				"
			);
			DB::query("
				UPDATE {$bt}Payment{$bt}
				SET {$bt}AmountCurrency{$bt} = {$bt}Currency{$bt}
				WHERE
					{$bt}Currency{$bt} <> ''
					AND {$bt}Currency{$bt} IS NOT NULL
					AND (
						{$bt}AmountCurrency{$bt} IS NULL
						OR {$bt}AmountCurrency{$bt} = ''
					)
				"
			);
		}
	}


}
{'fraction_non_alphanumeric': 0.20452488687782805, 'fraction_numerical': 0.0006033182503770739, 'mean_word_length': 3.6638537271448666, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7197238', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1134, 'n_words': 219}