Skip to content

Commit

Permalink
Ticket #3620 - Xero integration module: Tax type.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLV committed Dec 20, 2021
1 parent ec777b2 commit 071152c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
23 changes: 19 additions & 4 deletions modules/boonex/xero/classes/BxXeroApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,32 @@ public function actionAddInvoice($sProfileEmail, $sName, $mixedAmount, $iQuantit
$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];

Expand All @@ -277,7 +292,7 @@ public function actionAddInvoice($sProfileEmail, $sName, $mixedAmount, $iQuantit
->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)
Expand Down
4 changes: 2 additions & 2 deletions modules/boonex/xero/classes/BxXeroModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ public function isContact($sProfileEmail, $bForceCheckApi = false)
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;

Expand Down

0 comments on commit 071152c

Please sign in to comment.