XeroAPI / Xero-Java

Official Java client for use with Xero API
MIT License
75 stars 87 forks source link

Error when setting Tax Tye and Accoount Code in line Item #336

Closed arifainchtein closed 1 year ago

arifainchtein commented 1 year ago

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

Describe the bug I have created two accounts in the Demo Company, the type is Revenue and the Tax Type is GST on income.
I am including images of the accounts. If i try to use those accounts on line items, i get validation errors and the invoice is not created. If i omit those lines in the code, the invoice is created.

The lines in question are:

lineItem.setTaxType("GST on Income"); lineItem.setAccountCode("60410");

The validation errors are: statusAttributeString: ERROR validationErrors: [class ValidationError { message: The TaxType code GST on Income does not exist or cannot be used for this type of transaction. }, class ValidationError { message: The TaxType code 'GST on Income' cannot be used with account code '40010-01'. }, class ValidationError { message: The TaxType code GST on Income does not exist or cannot be used for this type of transaction. }, class ValidationError { message: The TaxType code 'GST on Income' cannot be used with account code '60410'. }]

To Reproduce Here is the code: if(freightLineItem!=null) { lineItem = new LineItem(); lineItem.setDescription("Freight"); lineItem.setQuantity((double)freightLineItem.getInt("itemQuantity")); lineItem.setUnitAmount(freightLineItem.getDouble("rate")); lineItem.setTaxType("GST on Income"); lineItem.setAccountCode("60410"); lineItem.setTracking(lineItemTrackings); lineItems.add(lineItem); }

and here is the output

line 462, returning invoice=class Invoice { type: ACCREC contact: class Contact { contactID: 508e3083-9b79-4ca2-98b5-e737d1d73837 mergedToContactID: null contactNumber: +61 7 3412 8600 accountNumber: null contactStatus: ACTIVE name: ATCO - QLD firstName: Damien lastName: Knight companyNumber: null emailAddress: damien.knight@atco.com skypeUserName: null contactPersons: [] bankAccountDetails: null taxNumber: null accountsReceivableTaxType: null accountsPayableTaxType: null addresses: [class Address { addressType: STREET addressLine1: null addressLine2: 55 Tonka Street Luscombe addressLine3: null addressLine4: null city: null region: QLD postalCode: 4207 country: null attentionTo: null }, class Address { addressType: POBOX addressLine1: null addressLine2: null addressLine3: null addressLine4: null city: null region: null postalCode: null country: null attentionTo: null }] phones: [class Phone { phoneType: DDI phoneNumber: null phoneAreaCode: null phoneCountryCode: null }, class Phone { phoneType: DEFAULT phoneNumber: null phoneAreaCode: null phoneCountryCode: null }, class Phone { phoneType: FAX phoneNumber: null phoneAreaCode: null phoneCountryCode: null }, class Phone { phoneType: MOBILE phoneNumber: null phoneAreaCode: null phoneCountryCode: null }] isSupplier: false isCustomer: true salesDefaultLineAmountType: null purchasesDefaultLineAmountType: null defaultCurrency: null xeroNetworkKey: null salesDefaultAccountCode: null purchasesDefaultAccountCode: null salesTrackingCategories: [] purchasesTrackingCategories: [] trackingCategoryName: null trackingCategoryOption: null paymentTerms: null updatedDateUTC: /Date(1680217833540+0000)/ contactGroups: [] website: null brandingTheme: null batchPayments: null discount: null balances: null attachments: [] hasAttachments: false validationErrors: [] hasValidationErrors: false statusAttributeString: null } lineItems: [class LineItem { lineItemID: null description: 8719 AB12 AB12/H8CG/PFPCG/PT10/ quantity: 1.0 unitAmount: 1975.0 itemCode: null accountCode: 40010-01 accountID: f61ebc55-dd77-4e05-abf5-c83ed2b4ab3b taxType: GST on Income taxAmount: 0.0 lineAmount: 1975.0 tracking: [class LineItemTracking { trackingCategoryID: 00000000-0000-0000-0000-000000000000 trackingOptionID: null name: null option: null }] discountRate: null discountAmount: null repeatingInvoiceID: null }, class LineItem { lineItemID: null description: Freight quantity: 1.0 unitAmount: 125.0 itemCode: null accountCode: 60410 accountID: ecb49075-1404-4165-896b-4f3938052ca2 taxType: GST on Income taxAmount: 0.0 lineAmount: 125.0 tracking: [class LineItemTracking { trackingCategoryID: 00000000-0000-0000-0000-000000000000 trackingOptionID: null name: null option: null }] discountRate: null discountAmount: null repeatingInvoiceID: null }] date: /Date(1680220800000+0000)/ dueDate: null lineAmountTypes: Exclusive invoiceNumber: INV-05012 reference: Customer Order 895 brandingThemeID: null url: null currencyCode: AUD currencyRate: null status: DRAFT sentToContact: null expectedPaymentDate: null plannedPaymentDate: null ciSDeduction: null ciSRate: null subTotal: 2100.0 totalTax: 0.0 total: 2100.0 totalDiscount: null invoiceID: 00000000-0000-0000-0000-000000000000 repeatingInvoiceID: null hasAttachments: false isDiscounted: false payments: [] prepayments: [] overpayments: [] amountDue: null amountPaid: null fullyPaidOnDate: null amountCredited: null updatedDateUTC: null creditNotes: [] attachments: [] hasErrors: true statusAttributeString: ERROR validationErrors: [class ValidationError { message: The TaxType code GST on Income does not exist or cannot be used for this type of transaction. }, class ValidationError { message: The TaxType code 'GST on Income' cannot be used with account code '40010-01'. }, class ValidationError { message: The TaxType code GST on Income does not exist or cannot be used for this type of transaction. }, class ValidationError { message: The TaxType code 'GST on Income' cannot be used with account code '60410'. }] warnings: [] } Expected behavior

the code should accept the data

ClassicAccount

Freight Account

github-actions[bot] commented 1 year ago

PETOSS-290

github-actions[bot] commented 1 year ago

Thanks for raising an issue, a ticket has been created to track your request

rdemarco-xero commented 1 year ago

You need to use the TaxType enum not the description.

arifainchtein commented 1 year ago

thanks for that , it works now