Xero Tracking Categories #315
-
Hi, I'm struggling with sending Purchase Orders with 2 tracking categories on a line item. I'm currently sending them with with one tracking category but I can't work out the syntax for send two different tracking categories. This is what I use for sending one... $lineItemTracking[$x] = new XeroAPI\XeroPHP\Models\Accounting\LineItemTracking; So what I need to achieve is... $lineItemTracking[$x] = new XeroAPI\XeroPHP\Models\Accounting\LineItemTracking; Hope someone can help. It would be very much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
Hi Andy, $lineItemTracking[1] = new XeroAPI\XeroPHP\Models\Accounting\LineItemTracking; |
Beta Was this translation helpful? Give feedback.
-
Hi pumpkinball.
Thank you for your quick reply. I tried something similar which didn't work
but I'll give what you suggest in the morning. Thank you again.
Andy
…On Tue, 21 Feb 2023 at 16:43, pumpkinball ***@***.***> wrote:
Hi Andy,
Off the top of my head, have you tried instantiating the LineItemTracking
object again?
So for each LineItemTracking you would need to do
$lineItemTracking[1] = new
XeroAPI\XeroPHP\Models\Accounting\LineItemTracking;
blah blah ...
$lineItemTracking[2] = new
XeroAPI\XeroPHP\Models\Accounting\LineItemTracking;
blah blah
And then at the end
array_push($lineItemTrackings, $lineItemTracking);
—
Reply to this email directly, view it on GitHub
<#315 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALFZ7BVPEBTIEPS3XE4YY5LWYTWBJANCNFSM6AAAAAAVDG2CMU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi @AndyTurff I know it seems a daft question, but the error suggests that the tracking categories you are sending across are not active.. ? |
Beta Was this translation helpful? Give feedback.
-
Hi @AndyTurff I've just tried it on my local. With the array_push, I forgot you have to push into the array after each tracking item.
|
Beta Was this translation helpful? Give feedback.
-
That worked!
Thank you so much for all your help. It's very much appreciated.
Have a great weekend. I will now! 🤓
Andy
…On Fri, 24 Feb 2023 at 12:11, pumpkinball ***@***.***> wrote:
Hi @AndyTurff <https://github.com/AndyTurff> I've just tried it on my
local. WIth the array_push, I forgot you have to push after each tracking
item.
So I tried this, and it seemed to work..
`
$trackingCat = new XeroAPI\XeroPHP\Models\Accounting\LineItemTracking;
$trackingCat->setTrackingCategoryId('xxxxxxxx-xxxx-xxxx-97a1-0e6d15b0b574')
->setName('Garden')
->setOption('All Gardens');
array_push($trackingCats, $trackingCat);
$trackingCat = new XeroAPI\XeroPHP\Models\Accounting\LineItemTracking;
$trackingCat->setTrackingCategoryId('xxxxxxxx-xxxx-xxxx-8dcb-9405d571b614')
->setName('Unit')
->setOption('All Units');
array_push($trackingCats, $trackingCat);
$lineitems = [];
$lineitem = new XeroAPI\XeroPHP\Models\Accounting\LineItem;
$lineitem->setDescription('Item 123')
->setQuantity(1)
->setUnitAmount(32)
->setAccountCode("400")
->setTracking($trackingCats);
array_push($lineitems, $lineitem);
`
—
Reply to this email directly, view it on GitHub
<#315 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALFZ7BXHD7SLYAXTKMBW7YDWZCQPBANCNFSM6AAAAAAVDG2CMU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Hi @AndyTurff I've just tried it on my local. With the array_push, I forgot you have to push into the array after each tracking item.
So I tried this, and it seemed to work..