-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defensive code required in LineItem #910
Comments
Hi @OS4. Typically in this situation you'd be using |
Yes, that's true. Typically in these situations we would return "-unknown-", makes it stand out. Returning null may be a better solution, but I wasn't sure where in the library this function was called, and as it was probably going to return a string an empty one seemed best. I don't think it's used anywhere in your library code. We call it directly to get the item codes to push to Xero. The issue arises with postage, which doesn't use a code, which was causing the error to be reported. For us an empty string was suitable :-) , sorry. You are better placed to determine what defensive code is required and what the correct return value should be. Is it correct to call this function directly, or should we be going via a better API call? |
Hi @OS4, a decision was made early on to let the models reflect the objects returned from Xero as closely as possible. As Xero accepts (and sometimes sends) incomplete objects, they are stored this way client-side. In your code, you can simply test |
Secondary explanation: If you save a Xero model with a property set to null, it could then set the property to null or otherwise delete it, whereas not sending the property at all has a different (or no) effect. |
vendor/calcinai/xero-php/src/XeroPHP/Models/Accounting/LineItem.php line 253 is currently
I believe that something like
Is required to stop errors being thrown
The text was updated successfully, but these errors were encountered: