Skip to content

Commit

Permalink
Merge branch 'develop' into bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Olexandr Lysenko committed Jan 21, 2015
2 parents 679197b + ae383b5 commit 47a1704
Show file tree
Hide file tree
Showing 350 changed files with 4,000 additions and 1,338 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ protected function calculateDynamicBundleAmount($basePriceValue, $bundleProduct,

/** @var Store $store */
$store = $bundleProduct->getStore();
$roundingMethod = $this->taxHelper->getCalculationAgorithm($store);
$roundingMethod = $this->taxHelper->getCalculationAlgorithm($store);
foreach ($amountList as $amountInfo) {
/** @var \Magento\Framework\Pricing\Amount\AmountInterface $itemAmount */
$itemAmount = $amountInfo['amount'];
Expand Down
6 changes: 4 additions & 2 deletions app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,10 @@ public function afterSave()
*/
public function setQty($qty)
{
$this->setData('qty', $qty);
$this->reloadPriceInfo();
if ($this->getData('qty') != $qty) {
$this->setData('qty', $qty);
$this->reloadPriceInfo();
}
return $this;
}

Expand Down
14 changes: 4 additions & 10 deletions app/code/Magento/Directory/Model/PriceCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,12 @@ public function convert($amount, $scope = null, $currency = null)
}

/**
* Convert and round price value for specified store or passed currency
*
* @param float $amount
* @param null|string|bool|int|\Magento\Store\Model\Store $store
* @param Currency|string|null $currency
* @param int $precision
* @return float
* {@inheritdoc}
*/
public function convertAndRound($amount, $store = null, $currency = null, $precision = self::DEFAULT_PRECISION)
public function convertAndRound($amount, $scope = null, $currency = null, $precision = self::DEFAULT_PRECISION)
{
$currentCurrency = $this->getCurrency($store, $currency);
$convertedValue = $this->getStore($store)->getBaseCurrency()->convert($amount, $currentCurrency);
$currentCurrency = $this->getCurrency($scope, $currency);
$convertedValue = $this->getStore($scope)->getBaseCurrency()->convert($amount, $currentCurrency);
return round($convertedValue, $precision);
}

Expand Down
35 changes: 2 additions & 33 deletions app/code/Magento/Sales/Model/Order/Invoice/Total/Subtotal.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,15 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)

$allowedSubtotal = $order->getSubtotal() - $order->getSubtotalInvoiced();
$baseAllowedSubtotal = $order->getBaseSubtotal() - $order->getBaseSubtotalInvoiced();
$allowedSubtotalInclTax = $allowedSubtotal +
$order->getHiddenTaxAmount() +
$order->getTaxAmount() -
$order->getTaxInvoiced() -
$order->getHiddenTaxInvoiced();
$baseAllowedSubtotalInclTax = $baseAllowedSubtotal +
$order->getBaseHiddenTaxAmount() +
$order->getBaseTaxAmount() -
$order->getBaseTaxInvoiced() -
$order->getBaseHiddenTaxInvoiced();

/**
* Check if shipping tax calculation is included to current invoice.
*/
$includeShippingTax = true;
foreach ($invoice->getOrder()->getInvoiceCollection() as $previousInvoice) {
if ($previousInvoice->getShippingAmount() && !$previousInvoice->isCanceled()) {
$includeShippingTax = false;
break;
}
}

if ($includeShippingTax) {
$allowedSubtotalInclTax -= $order->getShippingTaxAmount();
$baseAllowedSubtotalInclTax -= $order->getBaseShippingTaxAmount();
} else {
$allowedSubtotalInclTax += $order->getShippingHiddenTaxAmount();
$baseAllowedSubtotalInclTax += $order->getBaseShippingHiddenTaxAmount();
}
//Note: The $subtotalInclTax and $baseSubtotalInclTax are not adjusted from those provide by the line items
//because the "InclTax" is displayed before any tax adjustments based on discounts, shipping, etc.

if ($invoice->isLast()) {
$subtotal = $allowedSubtotal;
$baseSubtotal = $baseAllowedSubtotal;
$subtotalInclTax = $allowedSubtotalInclTax;
$baseSubtotalInclTax = $baseAllowedSubtotalInclTax;
} else {
$subtotal = min($allowedSubtotal, $subtotal);
$baseSubtotal = min($baseAllowedSubtotal, $baseSubtotal);
$subtotalInclTax = min($allowedSubtotalInclTax, $subtotalInclTax);
$baseSubtotalInclTax = min($baseAllowedSubtotalInclTax, $baseSubtotalInclTax);
}

$invoice->setSubtotal($subtotal);
Expand Down
36 changes: 18 additions & 18 deletions app/code/Magento/Tax/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ public function getCalculationSequence($store = null)
* @param null|string|bool|int|Store $store
* @return string
*/
public function getCalculationAgorithm($store = null)
public function getCalculationAlgorithm($store = null)
{
return $this->_config->getAlgorithm($store);
}
Expand Down Expand Up @@ -797,23 +797,6 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface

$orderTaxDetails = $this->orderTaxManagement->getOrderTaxDetails($order->getId());

// Apply any taxes for shipping
$shippingTaxAmount = $salesItem->getShippingTaxAmount();
$originalShippingTaxAmount = $order->getShippingTaxAmount();
if ($shippingTaxAmount && $originalShippingTaxAmount &&
$shippingTaxAmount != 0 && floatval($originalShippingTaxAmount)
) {
//An invoice or credit memo can have a different qty than its order
$shippingRatio = $shippingTaxAmount / $originalShippingTaxAmount;
$itemTaxDetails = $orderTaxDetails->getItems();
foreach ($itemTaxDetails as $itemTaxDetail) {
//Aggregate taxable items associated with shipping
if ($itemTaxDetail->getType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING) {
$taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio);
}
}
}

// Apply any taxes for the items
/** @var $item \Magento\Sales\Model\Order\Invoice\Item|\Magento\Sales\Model\Order\Creditmemo\Item */
foreach ($salesItem->getItems() as $item) {
Expand Down Expand Up @@ -845,6 +828,23 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface
}
}

// Apply any taxes for shipping
$shippingTaxAmount = $salesItem->getShippingTaxAmount();
$originalShippingTaxAmount = $order->getShippingTaxAmount();
if ($shippingTaxAmount && $originalShippingTaxAmount &&
$shippingTaxAmount != 0 && floatval($originalShippingTaxAmount)
) {
//An invoice or credit memo can have a different qty than its order
$shippingRatio = $shippingTaxAmount / $originalShippingTaxAmount;
$itemTaxDetails = $orderTaxDetails->getItems();
foreach ($itemTaxDetails as $itemTaxDetail) {
//Aggregate taxable items associated with shipping
if ($itemTaxDetail->getType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING) {
$taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio);
}
}
}

return $taxClassAmount;
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Tax/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public function getNeedUseShippingExcludeTax()
}

/**
* Get defined tax calculation agorithm
* Get defined tax calculation algorithm
*
* @param null|string|bool|int|Store $store
* @return string
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Tax/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function updateProductOptions(\Magento\Framework\Event\Observer $observer
return $this;
}

$algorithm = $this->_taxData->getCalculationAgorithm();
$algorithm = $this->_taxData->getCalculationAlgorithm();
$options['calculationAlgorithm'] = $algorithm;
// prepare correct template for options render
if ($this->_taxData->displayBothPrices()) {
Expand Down
5 changes: 4 additions & 1 deletion dev/tests/functional/composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"require": {
"magento/mtf": "1.0.0-rc12",
"magento/mtf": "1.0.0-rc13",
"php": ">=5.4.0",
"phpunit/phpunit": "4.1.0",
"phpunit/phpunit-selenium": ">=1.2",
"netwing/selenium-server-standalone": ">=2.35"
},
"suggest": {
"facebook/webdriver": "dev-master"
},
"autoload": {
"psr-4": {
"Mtf\\": ["lib/Mtf/", "generated/Mtf/", "testsuites/Mtf/"],
Expand Down

This file was deleted.

Loading

0 comments on commit 47a1704

Please sign in to comment.