XeroAPI / xero-php-oauth2

Xero PHP SDK for oAuth 2 generated from Xero API OpenAPI Spec 3.0
MIT License
90 stars 64 forks source link

setLineAmountTypes ingored? #254

Closed ksn-systems closed 2 years ago

ksn-systems commented 2 years ago

V 2.8.1

I am happily creating Invoices via the API in my Demo Company on Xero.

However when creating the invoice object

$invoice = new \XeroAPI\XeroPHP\Models\Accounting\Invoice; $invoice->setType(\XeroAPI\XeroPHP\Models\Accounting\Invoice::TYPE_ACCREC); $invoice->setContact($contact); $invoice->setDate(new \DateTime($payload['Date'])); $invoice->setDueDate(new \DateTime($payload['DueDate'])); $invoice->setReference($payload['Reference']); $invoice->setStatus(\XeroAPI\XeroPHP\Models\Accounting\Invoice::STATUS_AUTHORISED); $invoice->setLineAmountTypes(\XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::INCLUSIVE);

The invoice is created as "Amounts are Tax Exclusive"

For each line item, I set the quantity and unit amount (not the line amount) and this shows as the correct amount with GST being calculated on the bottom of the invoice.

The tax rate on the line item shows as 15% GST on Income.

I am guessing this may be finger trouble and not a bug.

Thanks

ksn-systems commented 2 years ago

hmm, this seems to be a feature.

If I create an invoice via the API and just open it in zero it shows the line item unit price as (I have one line item) Total - GST.

If I edit the invoice it displays it as an inclusive amount and everything is as I wanted it via the API.

When I preview the invoice I get the unit price is again set to Total - GST.

A bit odd but it looks like it's just how is works.

wobinb commented 2 years ago

The option to use Tax Inclusive or Exclusive figures is intended primarily to help with data entry. When invoices are being displayed through the front-end these are all shown/converted to Tax Exclusive. The logic is that if you are looking through invoices, you can compare them quickly and easily without having to worry if they are tax inclusive or exclusive.