Esempio n. 1
0
 /**
  * Map item extra taxables
  *
  * @param ItemBuilder $itemBuilder
  * @param AbstractItem $item
  * @param bool $priceIncludesTax
  * @param bool $useBaseCurrency
  * @return ItemDataObject[]
  */
 public function mapItemExtraTaxables(ItemBuilder $itemBuilder, AbstractItem $item, $priceIncludesTax, $useBaseCurrency)
 {
     $itemDataObjects = [];
     $extraTaxables = $item->getAssociatedTaxables();
     if (!$extraTaxables) {
         return [];
     }
     foreach ($extraTaxables as $extraTaxable) {
         $extraTaxableIncludesTax = isset($extraTaxable['price_includes_tax']) ? $extraTaxable['price_includes_tax'] : $priceIncludesTax;
         $itemBuilder->setCode($extraTaxable[self::KEY_ASSOCIATED_TAXABLE_CODE]);
         $itemBuilder->setType($extraTaxable[self::KEY_ASSOCIATED_TAXABLE_TYPE]);
         $itemBuilder->setQuantity($extraTaxable[self::KEY_ASSOCIATED_TAXABLE_QUANTITY]);
         $itemBuilder->setTaxClassKey($itemBuilder->getTaxClassKeyBuilder()->setType(TaxClassKey::TYPE_ID)->setValue($extraTaxable[self::KEY_ASSOCIATED_TAXABLE_TAX_CLASS_ID])->create());
         if ($useBaseCurrency) {
             $unitPrice = $extraTaxable[self::KEY_ASSOCIATED_TAXABLE_BASE_UNIT_PRICE];
         } else {
             $unitPrice = $extraTaxable[self::KEY_ASSOCIATED_TAXABLE_UNIT_PRICE];
         }
         $itemBuilder->setUnitPrice($unitPrice);
         $itemBuilder->setTaxIncluded($extraTaxableIncludesTax);
         $itemBuilder->setAssociatedItemCode($item->getTaxCalculationItemId());
         $itemDataObjects[] = $itemBuilder->create();
     }
     return $itemDataObjects;
 }
Esempio n. 2
0
 /**
  * Map extra taxables associated with quote
  *
  * @param ItemBuilder $itemBuilder
  * @param Address $address
  * @param bool $useBaseCurrency
  * @return ItemDataObject[]
  */
 public function mapQuoteExtraTaxables(ItemBuilder $itemBuilder, Address $address, $useBaseCurrency)
 {
     $itemDataObjects = [];
     $extraTaxables = $address->getAssociatedTaxables();
     if (!$extraTaxables) {
         return [];
     }
     foreach ($extraTaxables as $extraTaxable) {
         $itemBuilder->setCode($extraTaxable[self::KEY_ASSOCIATED_TAXABLE_CODE]);
         $itemBuilder->setType($extraTaxable[self::KEY_ASSOCIATED_TAXABLE_TYPE]);
         $itemBuilder->setQuantity($extraTaxable[self::KEY_ASSOCIATED_TAXABLE_QUANTITY]);
         $itemBuilder->setTaxClassKey($itemBuilder->getTaxClassKeyBuilder()->setType(TaxClassKey::TYPE_ID)->setValue($extraTaxable[self::KEY_ASSOCIATED_TAXABLE_TAX_CLASS_ID])->create());
         if ($useBaseCurrency) {
             $unitPrice = $extraTaxable[self::KEY_ASSOCIATED_TAXABLE_BASE_UNIT_PRICE];
         } else {
             $unitPrice = $extraTaxable[self::KEY_ASSOCIATED_TAXABLE_UNIT_PRICE];
         }
         $itemBuilder->setUnitPrice($unitPrice);
         $itemBuilder->setTaxIncluded($extraTaxable[self::KEY_ASSOCIATED_TAXABLE_PRICE_INCLUDES_TAX]);
         $itemBuilder->setAssociatedItemCode($extraTaxable[self::KEY_ASSOCIATED_TAXABLE_ASSOCIATION_ITEM_CODE]);
         $itemDataObjects[] = $itemBuilder->create();
     }
     return $itemDataObjects;
 }