calcinai / xero-php

A php library for the Xero API, with a cleaner OAuth interface and ORM-like abstraction.
MIT License
359 stars 256 forks source link

Creating a new TrackingOption on an existing TrackingCategory #920

Open rushork opened 5 days ago

rushork commented 5 days ago

Hi,

I'm trying to create tracking options and add them to an existing tracking category (that has tracking options) like this:

     $option = new TrackingCategory\TrackingOption();
     $option->setName($name);
     $tracking->addOption($option);
     $tracking->save();

Each time I do so, apart from adding the FIRST tracking option to a tracking category, I get the following exception:

A validation exception occurred (For each specified tracking option the name must be unique)
Validation errors:
For each specified tracking option the name must be unique.

The value of $name does not exist in the tracking category before this, but it still says it must be unique?

It only happens when I try to add a new one. I also notice that it does actually create the tracking option, but the error means that when I try adding the tracking variable to a line item and save it for an invoice - it does not save the line item as there has been an error.

Thanks

rushork commented 4 days ago

To further prove there is an issue, I instead made the requests through the XeroPHP\Remote\Request class and manually chose the endpoints I wanted.

I managed to get it to work using this method instead.