소스 검색

Ticket #3620 - Xero integration module: Tax type.

AntonLV 4 년 전
부모
커밋
071152c77a
2개의 변경된 파일과 21개의 추가작업 그리고 6개의 파일을 삭제
  1. 19 4
      modules/boonex/xero/classes/BxXeroApi.php
  2. 2 2
      modules/boonex/xero/classes/BxXeroModule.php

+ 19 - 4
modules/boonex/xero/classes/BxXeroApi.php

@@ -249,17 +249,32 @@ class BxXeroApi extends BxDol
                 $mixedDueDate = new DateTime($mixedDueDate);
 
             $fAmount = $mixedAmount;
-            $fTaxAmount = false;
+            $fTaxAmount = $sTaxType = false;
             if(is_array($mixedAmount))
-                list($fAmount, $fTaxAmount) = $mixedAmount;
+                switch(count($mixedAmount)) {
+                    case 2:
+                        list($fAmount, $fTaxAmount) = $mixedAmount;
+                        break;
+
+                    case 3:
+                        list($fAmount, $fTaxAmount, $sTaxType) = $mixedAmount;
+                        break;
+                }
+
+            $sLineAmountType = \XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::NO_TAX;
 
             $oLineItem = new XeroAPI\XeroPHP\Models\Accounting\LineItem;
             $oLineItem->setDescription($sName)
                 ->setUnitAmount($fAmount)
                 ->setQuantity($iQuantity)
                 ->setAccountCode($sAccount);
-            if($fTaxAmount !== false)
+            if($fTaxAmount !== false) {
+                $sLineAmountType = \XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::EXCLUSIVE;
+
                 $oLineItem->setTaxAmount($fTaxAmount);
+            }
+            if($sTaxType !== false)
+                $oLineItem->setTaxType($sTaxType);
 
             $aLineItems = [$oLineItem];		
 
@@ -277,7 +292,7 @@ class BxXeroApi extends BxDol
                 ->setLineItems($aLineItems)
                 ->setStatus(XeroAPI\XeroPHP\Models\Accounting\Invoice::STATUS_AUTHORISED)
                 ->setType(XeroAPI\XeroPHP\Models\Accounting\Invoice::TYPE_ACCREC)
-                ->setLineAmountTypes(\XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::EXCLUSIVE);
+                ->setLineAmountTypes($sLineAmountType);
 
             $oXeroResponse = $oXeroApi->createInvoices($sTenantId, $oInvoice); 
             if(count($oXeroResponse->getInvoices()) == 1)

+ 2 - 2
modules/boonex/xero/classes/BxXeroModule.php

@@ -176,11 +176,11 @@ class BxXeroModule extends BxDolModule
         return $this->_oApi->actionIsContact($sProfileEmail);
     }
     
-    public function addInvoice($sProfileEmail, $sName, $fAmount, $iQuantity, $mixedDueDate)
+    public function addInvoice($sProfileEmail, $sName, $mixedAmount, $iQuantity, $mixedDueDate)
     {
         $CNF = &$this->_oConfig->CNF;
 
-        $mixedInvoiceId = $this->_oApi->actionAddInvoice($sProfileEmail, $sName, $fAmount, $iQuantity, $mixedDueDate);
+        $mixedInvoiceId = $this->_oApi->actionAddInvoice($sProfileEmail, $sName, $mixedAmount, $iQuantity, $mixedDueDate);
         if(!$mixedInvoiceId)
             return $mixedInvoiceId;