Browse files

updated pricing set and order price provider

  • Loading branch information...
1 parent 1ed3120 commit f00c2d46c2fa0071552af2b99b47e870681b27fa @theodorDiaconu theodorDiaconu committed with iampersistent Jan 27, 2013
View
2 lib/ImmersiveLabs/Pricing/Entity/PricingSet.php
@@ -85,7 +85,7 @@ public function set($name, $value)
return $this;
}
- public function has($name, $value)
+ public function has($name)
{
return isset($this->processed[$name]);
}
View
20 lib/ImmersiveLabs/Pricing/Provider/OrderPricingProvider.php
@@ -44,19 +44,25 @@ public function determineOrderPrices(OrderInterface $order, PricingContextInterf
// updating prices for each item
foreach ($order->getItems() as $item) {
// this is the total value since we want to capture any calculations that happen on a specific item
- $itemsTotalNet += $item->getPricing()->getTotalValue();
+ $itemsTotalNet += $item->getPricing()->get('netValue');
}
$orderPricingSet->set('totalNet', $itemsTotalNet);
+
// if pricing context has taxation enabled we calculate the taxes with the percentage set
// example taxRates : 0.10 for 10%, 0.25 for 25%
- if ($state = $pricingContext->get('address.state')) {
- $rate = $this->taxProvider->getTaxByState($state);
- $totalTax = $itemsTotalNet * $rate;
- $orderPricingSet->set('taxRate', $rate);
- $orderPricingSet->set('taxes', $totalTax);
- $orderPricingSet->set('totalValue', $itemsTotalNet + $totalTax);
+ if ($partner = $pricingContext->get('partner')) {
+ /** @var $partner \Vespolina\Entity\Partner\Partner */
+ if (count($partner->getAddresses())) {
+ /** @var $address \Vespolina\Entity\Partner\AddressInterface */
+ $address = $partner->getAddresses()->get(0);
+ $rate = $this->taxProvider->getTaxForAddress($address);
+ $totalTax = $itemsTotalNet * $rate;
+ $orderPricingSet->set('taxRate', $rate);
+ $orderPricingSet->set('taxes', $totalTax);
+ $orderPricingSet->set('totalValue', $itemsTotalNet + $totalTax);
+ }
}
$orderPricingSet->setProcessingState(PricingSet::PROCESSING_FINISHED);

0 comments on commit f00c2d4

Please sign in to comment.