diff --git a/app/code/Magento/Bundle/view/base/templates/product/price/final_price.phtml b/app/code/Magento/Bundle/view/base/templates/product/price/final_price.phtml index 406ca0cd37c5291c6cc36f0680b9966e72b82468..4e466c81a342cc5b572b3647420fe8a47224d276 100644 --- a/app/code/Magento/Bundle/view/base/templates/product/price/final_price.phtml +++ b/app/code/Magento/Bundle/view/base/templates/product/price/final_price.phtml @@ -16,7 +16,8 @@ $productId = $block->getSaleableItem()->getId(); $finalPriceModel = $block->getPrice(); $minimalPrice = $finalPriceModel->getMinimalPrice(); $maximalPrice = $finalPriceModel->getMaximalPrice(); -/** @var \Magento\Bundle\Pricing\Price\BundleRegularPrice $regularPriceModel */ +/** ex: \Magento\Bundle\Pricing\Price\BundleRegularPrice */ +/** @var \Magento\Framework\Pricing\Price\PriceInterface $regularPriceModel */ $regularPriceModel = $block->getPriceType('regular_price'); $maximalRegularPrice = $regularPriceModel->getMaximalPrice(); $minimalRegularPrice = $regularPriceModel->getMinimalPrice(); diff --git a/app/code/Magento/Catalog/view/base/templates/product/price/default.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/default.phtml index 54933e88b99573d2bae03baf09f023775f2ddc39..6283d8a08f24e9bbbd09e97b371e516970dfdf9e 100644 --- a/app/code/Magento/Catalog/view/base/templates/product/price/default.phtml +++ b/app/code/Magento/Catalog/view/base/templates/product/price/default.phtml @@ -13,7 +13,8 @@ $productId = $block->getSaleableItem()->getId(); -/** @var \Magento\Catalog\Pricing\Price\RegularPrice $priceModel */ +/** ex: \Magento\Catalog\Pricing\Price\RegularPrice */ +/** @var \Magento\Framework\Pricing\Price\PriceInterface $priceModel */ $priceModel = $block->getPriceType('regular_price'); /* @escapeNotVerified */ echo $block->renderAmount($priceModel->getAmount(), [ diff --git a/app/code/Magento/Catalog/view/base/templates/product/price/final_price.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/final_price.phtml index 402c2a1b67a5848bda77852ff09a221726dc7283..94638bdd1acbbbb4c48c423ef4910fe6067d3189 100644 --- a/app/code/Magento/Catalog/view/base/templates/product/price/final_price.phtml +++ b/app/code/Magento/Catalog/view/base/templates/product/price/final_price.phtml @@ -13,10 +13,12 @@ $productId = $block->getSaleableItem()->getId(); -/** @var \Magento\Catalog\Pricing\Price\RegularPrice $priceModel */ +/** ex: \Magento\Catalog\Pricing\Price\RegularPrice */ +/** @var \Magento\Framework\Pricing\Price\PriceInterface $priceModel */ $priceModel = $block->getPriceType('regular_price'); -/** @var \Magento\Catalog\Pricing\Price\FinalPrice $finalPriceModel */ +/** ex: \Magento\Catalog\Pricing\Price\FinalPrice */ +/** @var \Magento\Framework\Pricing\Price\PriceInterface $finalPriceModel */ $finalPriceModel = $block->getPriceType('final_price'); $idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : ''; $schema = ($block->getZone() == 'item_view') ? true : false; diff --git a/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js b/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js index 5ac696cd6f2f310901f508b073f53595b33cfce1..eabc4c7c293d590cb8e677ae3d826acfb3a23026 100644 --- a/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js +++ b/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js @@ -13,6 +13,8 @@ define( 'mage/translate' ], function (_, Component, creditCardData, cardNumberValidator, $t) { + 'use strict'; + return Component.extend({ defaults: { creditCardType: '', @@ -39,19 +41,25 @@ define( 'creditCardSsIssue', 'selectedCardType' ]); + return this; }, - initialize: function() { + /** + * Init component + */ + initialize: function () { var self = this; + this._super(); //Set credit card number to credit card data object - this.creditCardNumber.subscribe(function(value) { + this.creditCardNumber.subscribe(function (value) { var result; + self.selectedCardType(null); - if (value == '' || value == null) { + if (value === '' || value === null) { return false; } result = cardNumberValidator(value); @@ -59,6 +67,7 @@ define( if (!result.isPotentiallyValid && !result.isValid) { return false; } + if (result.card !== null) { self.selectedCardType(result.card.type); creditCardData.creditCard = result.card; @@ -71,25 +80,34 @@ define( }); //Set expiration year to credit card data object - this.creditCardExpYear.subscribe(function(value) { + this.creditCardExpYear.subscribe(function (value) { creditCardData.expirationYear = value; }); //Set expiration month to credit card data object - this.creditCardExpMonth.subscribe(function(value) { - creditCardData.expirationYear = value; + this.creditCardExpMonth.subscribe(function (value) { + creditCardData.expirationMonth = value; }); //Set cvv code to credit card data object - this.creditCardVerificationNumber.subscribe(function(value) { + this.creditCardVerificationNumber.subscribe(function (value) { creditCardData.cvvCode = value; }); }, - getCode: function() { + /** + * Get code + * @returns {String} + */ + getCode: function () { return 'cc'; }, - getData: function() { + + /** + * Get data + * @returns {Object} + */ + getData: function () { return { 'method': this.item.method, 'additional_data': { @@ -104,89 +122,185 @@ define( } }; }, - getCcAvailableTypes: function() { + + /** + * Get list of available credit card types + * @returns {Object} + */ + getCcAvailableTypes: function () { return window.checkoutConfig.payment.ccform.availableTypes[this.getCode()]; }, + + /** + * Get payment icons + * @param {String} type + * @returns {Boolean} + */ getIcons: function (type) { - return window.checkoutConfig.payment.ccform.icons.hasOwnProperty(type) - ? window.checkoutConfig.payment.ccform.icons[type] - : false + return window.checkoutConfig.payment.ccform.icons.hasOwnProperty(type) ? + window.checkoutConfig.payment.ccform.icons[type] + : false; }, - getCcMonths: function() { + + /** + * Get list of months + * @returns {Object} + */ + getCcMonths: function () { return window.checkoutConfig.payment.ccform.months[this.getCode()]; }, - getCcYears: function() { + + /** + * Get list of years + * @returns {Object} + */ + getCcYears: function () { return window.checkoutConfig.payment.ccform.years[this.getCode()]; }, - hasVerification: function() { + + /** + * Check if current payment has verification + * @returns {Boolean} + */ + hasVerification: function () { return window.checkoutConfig.payment.ccform.hasVerification[this.getCode()]; }, - hasSsCardType: function() { + + /** + * @deprecated + * @returns {Boolean} + */ + hasSsCardType: function () { return window.checkoutConfig.payment.ccform.hasSsCardType[this.getCode()]; }, - getCvvImageUrl: function() { + + /** + * Get image url for CVV + * @returns {String} + */ + getCvvImageUrl: function () { return window.checkoutConfig.payment.ccform.cvvImageUrl[this.getCode()]; }, - getCvvImageHtml: function() { - return '<img src="' + this.getCvvImageUrl() - + '" alt="' + $t('Card Verification Number Visual Reference') - + '" title="' + $t('Card Verification Number Visual Reference') - + '" />'; + + /** + * Get image for CVV + * @returns {String} + */ + getCvvImageHtml: function () { + return '<img src="' + this.getCvvImageUrl() + + '" alt="' + $t('Card Verification Number Visual Reference') + + '" title="' + $t('Card Verification Number Visual Reference') + + '" />'; }, - getSsStartYears: function() { + + /** + * @deprecated + * @returns {Object} + */ + getSsStartYears: function () { return window.checkoutConfig.payment.ccform.ssStartYears[this.getCode()]; }, - getCcAvailableTypesValues: function() { - return _.map(this.getCcAvailableTypes(), function(value, key) { + + /** + * Get list of available credit card types values + * @returns {Object} + */ + getCcAvailableTypesValues: function () { + return _.map(this.getCcAvailableTypes(), function (value, key) { return { 'value': key, 'type': value - } + }; }); }, - getCcMonthsValues: function() { - return _.map(this.getCcMonths(), function(value, key) { + + /** + * Get list of available month values + * @returns {Object} + */ + getCcMonthsValues: function () { + return _.map(this.getCcMonths(), function (value, key) { return { 'value': key, 'month': value - } + }; }); }, - getCcYearsValues: function() { - return _.map(this.getCcYears(), function(value, key) { + + /** + * Get list of available year values + * @returns {Object} + */ + getCcYearsValues: function () { + return _.map(this.getCcYears(), function (value, key) { return { 'value': key, 'year': value - } + }; }); }, - getSsStartYearsValues: function() { - return _.map(this.getSsStartYears(), function(value, key) { + + /** + * @deprecated + * @returns {Object} + */ + getSsStartYearsValues: function () { + return _.map(this.getSsStartYears(), function (value, key) { return { 'value': key, 'year': value - } + }; }); }, - isShowLegend: function() { + + /** + * Is legend available to display + * @returns {Boolean} + */ + isShowLegend: function () { return false; }, - getCcTypeTitleByCode: function(code) { - var title = ''; + + /** + * Get available credit card type by code + * @param {String} code + * @returns {String} + */ + getCcTypeTitleByCode: function (code) { + var title = '', + keyValue = 'value', + keyType = 'type'; + _.each(this.getCcAvailableTypesValues(), function (value) { - if (value['value'] == code) { - title = value['type']; + if (value[keyValue] === code) { + title = value[keyType]; } }); + return title; }, - formatDisplayCcNumber: function(number) { + + /** + * Prepare credit card number to output + * @param {String} number + * @returns {String} + */ + formatDisplayCcNumber: function (number) { return 'xxxx-' + number.substr(-4); }, - getInfo: function() { + + /** + * Get credit card details + * @returns {Array} + */ + getInfo: function () { return [ - {'name': 'Credit Card Type', value: this.getCcTypeTitleByCode(this.creditCardType())}, - {'name': 'Credit Card Number', value: this.formatDisplayCcNumber(this.creditCardNumber())} + { + 'name': 'Credit Card Type', value: this.getCcTypeTitleByCode(this.creditCardType()) + }, + { + 'name': 'Credit Card Number', value: this.formatDisplayCcNumber(this.creditCardNumber()) + } ]; } }); diff --git a/app/code/Magento/Paypal/etc/frontend/di.xml b/app/code/Magento/Paypal/etc/frontend/di.xml index 4926410e49187d169eceb8af9d5ee3f894de2320..ea54af994ca87ba50845f1b9757dec6dd19e9851 100644 --- a/app/code/Magento/Paypal/etc/frontend/di.xml +++ b/app/code/Magento/Paypal/etc/frontend/di.xml @@ -48,6 +48,7 @@ <item name="paypal_payflowbml" xsi:type="string">/paypal/payflowbml/</item> <item name="paypal_payflowexpress" xsi:type="string">/paypal/payflowexpress/</item> <item name="paypal_transparent" xsi:type="string">/paypal/transparent/</item> + <item name="paypal_express" xsi:type="string">/paypal/express/</item> </argument> </arguments> </type> diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php index 3d8eea7469b80f47dff4b5ed24b8e9eb7a50db4b..da9d1078657d4ce76bc30d1a73c5b2e3a683c2f5 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php @@ -42,7 +42,7 @@ class Tax extends AbstractTotal */ $tax = $orderItemTax - $orderItem->getTaxRefunded(); - $baseTax = $baseOrderItemTax - $orderItem->getTaxRefunded(); + $baseTax = $baseOrderItemTax - $orderItem->getBaseTaxRefunded(); $discountTaxCompensation = $orderItem->getDiscountTaxCompensationInvoiced() - $orderItem->getDiscountTaxCompensationRefunded(); $baseDiscountTaxCompensation = $orderItem->getBaseDiscountTaxCompensationInvoiced() - diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php index 669369a1d4b888506d4e32c32d05ac71b9aaa3ba..cef53e0193effc952f0a7521b09ca3c51c132e4c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php @@ -232,6 +232,95 @@ class TaxTest extends \PHPUnit_Framework_TestCase ], ]; + $currencyRatio = 2; + // scenario 1: 3 item_1, 3 item_2, $99 each, 8.19 tax rate + // 1 item_1 and 2 item_2 are invoiced and base currency <> display currency + $result['partial_invoice_partial_creditmemo_different_currencies'] = [ + 'order_data' => [ + 'data_fields' => [ + 'shipping_tax_amount' => 2.45 * $currencyRatio, + 'base_shipping_tax_amount' => 2.45, + 'shipping_discount_tax_compensation_amount' => 0.00, + 'base_shipping_discount_tax_compensation_amount' => 0.00, + 'tax_amount' => 53.56 * $currencyRatio, + 'base_tax_amount' => 53.56, + 'tax_invoiced' => 24.33 * $currencyRatio, + 'base_tax_invoiced' => 24.33, + 'tax_refunded' => 0.00, + 'base_tax_refunded' => 0.00, + 'base_shipping_amount' => 30.00, + ], + ], + 'creditmemo_data' => [ + 'items' => [ + 'item_1' => [ + 'order_item' => [ + 'qty_invoiced' => 1, + 'tax_invoiced' => 8.11 * $currencyRatio, + 'tax_refunded' => 0, + 'base_tax_invoiced' => 8.11, + 'base_tax_refunded' => 0, + 'discount_tax_compensation_amount' => 0, + 'base_discount_tax_compensation_amount' => 0, + 'qty_refunded' => 0, + ], + 'is_last' => false, + 'qty' => 1, + ], + 'item_2' => [ + 'order_item' => [ + 'qty_invoiced' => 2, + 'tax_refunded' => 0, + 'tax_invoiced' => 16.22 * $currencyRatio, + 'base_tax_refunded' => 0, + 'base_tax_invoiced' => 16.22, + 'discount_tax_compensation_amount' => 0, + 'base_discount_tax_compensation_amount' => 0, + 'qty_refunded' => 0, + ], + 'is_last' => false, + 'qty' => 1, + ], + ], + 'is_last' => false, + 'data_fields' => [ + 'grand_total' => 198 * $currencyRatio, + 'base_grand_total' => 198, + 'base_shipping_amount' => 30, + 'tax_amount' => 0.82 * $currencyRatio, + 'base_tax_amount' => 0.82, + 'invoice' => new MagentoObject( + [ + 'shipping_tax_amount' => 2.45 * $currencyRatio, + 'base_shipping_tax_amount' => 2.45, + 'shipping_discount_tax_compensation_amount' => 0, + 'base_shipping_discount_tax_compensation_amount' => 0, + ] + ), + ], + ], + 'expected_results' => [ + 'creditmemo_items' => [ + 'item_1' => [ + 'tax_amount' => 8.11 * $currencyRatio, + 'base_tax_amount' => 8.11, + ], + 'item_2' => [ + 'tax_amount' => 8.11 * $currencyRatio, + 'base_tax_amount' => 8.11, + ], + ], + 'creditmemo_data' => [ + 'grand_total' => 216.67 * $currencyRatio, + 'base_grand_total' => 216.67, + 'tax_amount' => 19.49 * $currencyRatio, + 'base_tax_amount' => 19.49, + 'shipping_tax_amount' => 2.45 * $currencyRatio, + 'base_shipping_tax_amount' => 2.45, + ], + ], + ]; + // scenario 2: 3 items, 2 invoiced, rowtotal of 150 with 8.25 tax rate // extra tax amount exist (weee tax), make sure that tax amount // is not over the amount invoiced