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

Unknown tracking details. A Tracking Category did not match a known Active TrackingCategory for purchase orders #268

Closed shorif2000 closed 2 years ago

shorif2000 commented 2 years ago

SDK you're using (please complete the following information):

Describe the bug Adding a tracking category and option for each line item in a purchase order via the api in php does not work.

To Reproduce Steps to reproduce the behavior:

  1. create tracking category 'project'
  2. create an option for the category
  3. set these on the line item for purchase order
$tc = new LineItemTracking();
                    $tc->setTrackingCategoryId($trackingCategoryId);
                    $tc->setTrackingOptionId($trackingOptionId);

                    $lineItem->setTracking([$tc]);

Expected behavior Create a purchase order with tracking

Actual behaviour

It errors with Unknown tracking details. A Tracking Category did not match a known Active TrackingCategory. The same steps work for Invoices and Credit Notes

rodjsta commented 2 years ago

@shorif2000, I'm pretty sure you'll find that you need to use the name of the tracking category rather than the ID.

It's very silly, but that's what I discovered when trying to add tracking categories to line items.

shorif2000 commented 2 years ago

@shorif2000, I'm pretty sure you'll find that you need to use the name of the tracking category rather than the ID.

It's very silly, but that's what I discovered when trying to add tracking categories to line items.

How do you set the name because the function clearly says setTrackingCategoryId and setTrackingOptionId

I have tried below but it errors the same

$tc = new LineItemTracking();
                $tc->setTrackingCategoryId($trackingCategoryId);
                $tc->setTrackingOptionId($trackingOptionId);
                $tc->setName($projectName);
shorif2000 commented 2 years ago

I had to set both names. the docs should be updated to reflect this. this information is not easy to find

$tc = new LineItemTracking();
                $tc->setTrackingCategoryId($trackingCategoryId);
                $tc->setTrackingOptionId($trackingOptionId);
                $tc->setName('Project');
                $tc->setOption($projectName);