r103863 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103862‎ | r103863 | r103864 >
Date:23:09, 21 November 2011
Author:jpostlethwaite
Status:resolved
Tags:
Comment:
Simplifying process of flooring yen currency. See r103514.
Modified paths:
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -1720,46 +1720,26 @@
17211721 );
17221722 return $languages;
17231723 }
1724 -
 1724+
17251725 /**
1726 - * Floor the amount
 1726+ * Stage: amount
17271727 *
1728 - * Some amounts for GlobalCollect cannot have cents. We will not round up.
1729 - *
17301728 * For example: JPY 1000.05 get changed to 100005. This need to be 100000.
17311729 * For example: JPY 1000.95 get changed to 100095. This need to be 100000.
17321730 *
1733 - *
1734 - * @param string $value
1735 - */
1736 - protected function floorAmount( $value ) {
1737 -
1738 - $value = substr( $value, 0, -2 ) . '00';
1739 -
1740 - return $value;
1741 - }
1742 -
1743 - /**
1744 - * Stage: amount
1745 - *
17461731 * @param string $type request|response
17471732 */
17481733 protected function stage_amount( $type = 'request' ) {
17491734 switch ( $type ) {
17501735 case 'request':
17511736
1752 - $floor = false;
1753 -
1754 - if ( $this->staged_data['currency_code'] == 'JPY' ) {
1755 - $floor = true;
 1737+ // JPY cannot have cents.
 1738+ $floorCurrencies = array ( 'JPY' );
 1739+ if ( in_array( $this->staged_data['currency_code'], $floorCurrencies ) ) {
 1740+ $this->staged_data['amount'] = floor( $this->staged_data['amount'] ) * 100;
17561741 }
17571742
17581743 $this->staged_data['amount'] = $this->staged_data['amount'] * 100;
1759 -
1760 - // Floor if required
1761 - if ( $floor ) {
1762 - $this->staged_data['amount'] = $this->floorAmount( $this->staged_data['amount'] );
1763 - }
17641744
17651745 break;
17661746 case 'response':

Follow-up revisions

RevisionCommit summaryAuthorDate
r103866Removing unnecessary multiplication by 100.. See r103863..jpostlethwaite23:17, 21 November 2011
r103869MFT r103415, r103514, r103837, r103854, r103863, r103866khorn23:41, 21 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103514Fixing issue with currency JPY. The amount is floored for the last two digits.jpostlethwaite22:15, 17 November 2011

Status & tagging log