We're working with the Clover REST API, and am seeing an odd behaviour with the calculated tax of lineitems that have been discounted.
We're making the following assumptions based on what we see from the API:
* tax RATE information is provided at the lineitem level
* tax AMOUNT information is provided at the order level
What we're seeing is this:
If we add an item to the order, say 5.00, that has a linked taxRate of 0.10, the lineitem total should be calculated to 5.50.
If we look at this order, we see a taxRate that matches this in the API.
The problem arrises when we try to apply a discount to this item. If we add a 100% discount, the lineitem price should now be interpreted as 0.00. This is fine, as when we try to calculate a tax amount ourselves, 0.10 * 0 === 0.00.
However, we've noticed that the taxRate at the order level remains at 0.50. This number appears to be calculated by Clover, and the order API doesn't allow us to edit this manually.
So we end up with an order total of 0.00, but with a taxAmount of 0.50, which clearly doesn't make sense.
How is this meant to be handled?
For reference, I've attached a sample order:
{ "href":"<REDACTED>", "id":"91SWPYNMKPAWG", "currency":"USD", "employee":{ "id":"9Z1RS40CEDN7G" }, "total":0, "paymentState":"PAID", "title":"brandin Chiu", "taxRemoved":false, "isVat":false, "state":"locked", "manualTransaction":false, "groupLineItems":true, "testMode":false, "createdTime":1613058954000, "clientCreatedTime":1613058954000, "modifiedTime":1613058962000, "lineItems":{ "elements":[ { "id":"RD418EJG33YE6", "orderRef":{ "id":"91SWPYNMKPAWG" }, "item":{ "id":"5DXWAPFW7A3CE", "hidden":false, "name":"2 Ladies*", "code":"G01014", "price":413, "priceType":"FIXED", "defaultTaxRates":true, "unitName":"", "cost":0, "isRevenue":true, "stockCount":0, "modifiedTime":1605675865000 }, "name":"2 Ladies*", "price":413, "itemCode":"G01014", "note":"Shaken, not stirred", "printed":false, "createdTime":1613058955000, "orderClientCreatedTime":1613058954000, "discounts":{ "elements":[ { "id":"MQQWAD29XT7BR", "orderRef":{ "id":"91SWPYNMKPAWG" }, "lineItemRef":{ "id":"RD418EJG33YE6" }, "name":"free", "percentage":100 } ] }, "exchanged":false, "modifications":{ "elements":[ { "id":"C3ATY0STAN2JJ", "lineItemRef":{ "id":"RD418EJG33YE6" }, "name":"( M )", "amount":0, "modifier":{ "id":"EN0CJHZC0ZKPA" } }, { "id":"V60Q2Z3F54ANM", "lineItemRef":{ "id":"RD418EJG33YE6" }, "name":"+Tapioca", "amount":69, "modifier":{ "id":"1N7932SM1QGCW" } }, { "id":"GP3NKR6GT6XEG", "lineItemRef":{ "id":"RD418EJG33YE6" }, "name":"+Aloe Vera", "amount":69, "modifier":{ "id":"1E5ZWY5FCBQHE" } }, { "id":"ZHY296RVTK1AC", "lineItemRef":{ "id":"RD418EJG33YE6" }, "name":"(Sweeter)", "amount":0, "modifier":{ "id":"SQ817E71DXT0E" } }, { "id":"G12JJRDVJ6EHY", "lineItemRef":{ "id":"RD418EJG33YE6" }, "name":"(Regular Ice)", "amount":0, "modifier":{ "id":"5968E2V61DSQ2" } } ] }, "refunded":false, "isRevenue":true, "taxRates":{ "elements":[ { "id":"VBXP2R1MCD2YP", "lineItemRef":{ "id":"RD418EJG33YE6" }, "name":"NY Sales Tax", "rate":887500, "isDefault":true } ] } } ] }, "taxRates":{ "elements":[ { "id":"VBXP2R1MCD2YP", "name":"NY Sales Tax", "amount":48 } ] } }
EDIT: We tested again using two drinks, and the correct taxAmount on the payment, but did the order still has the wrong taxAmount on it:
{ "href": "<REDACTED>", "id": "CJ0EQZKMJGW8A", "currency": "USD", "employee": { "id": "9Z1RS40CEDN7G" }, "total": 475, "paymentState": "PAID", "title": "brandin chiu", "taxRemoved": false, "isVat": false, "state": "locked", "manualTransaction": false, "groupLineItems": true, "testMode": false, "createdTime": 1616115883000, "clientCreatedTime": 1616115883000, "modifiedTime": 1616115886000, "lineItems": { "elements": [{ "id": "5MK7620A765PP", "orderRef": { "id": "CJ0EQZKMJGW8A" }, "item": { "id": "P16DGQX38D03T", "hidden": false, "name": "2 Ladies", "alternateName": "", "code": "G01014", "sku": "MT000100B2", "price": 436, "priceType": "FIXED", "defaultTaxRates": true, "unitName": "", "cost": 3, "isRevenue": true, "stockCount": 0, "modifiedTime": 1612216810000 }, "name": "2 Ladies", "alternateName": "", "price": 436, "itemCode": "G01014", "note": "", "printed": false, "createdTime": 1616115883000, "orderClientCreatedTime": 1616115883000, "discounts": { "elements": [{ "id": "5H8D4D2H4ZDM4", "orderRef": { "id": "CJ0EQZKMJGW8A" }, "lineItemRef": { "id": "5MK7620A765PP" }, "name": "BOGO_Launch Event", "percentage": 100 }] }, "exchanged": false, "modifications": { "elements": [{ "id": "BCH78FYW7VNA8", "lineItemRef": { "id": "5MK7620A765PP" }, "name": "( M )", "amount": 0, "modifier": { "id": "ZN7QD4BP4F73J" } }, { "id": "BZZ3TZ3JFP08T", "lineItemRef": { "id": "5MK7620A765PP" }, "name": "(Regular Ice)", "amount": 0, "modifier": { "id": "ARHY5QR86TXV4" } }, { "id": "BFJQ6RHKJJ6G6", "lineItemRef": { "id": "5MK7620A765PP" }, "name": "(Sweeter)", "amount": 0, "modifier": { "id": "CY7DBTFJT6MPA" } }, { "id": "6FXNAKS5RFB2P", "lineItemRef": { "id": "5MK7620A765PP" }, "name": "Regular", "amount": 0, "modifier": { "id": "WGCT8XY76J63A" } } ] }, "refunded": false, "isRevenue": true, "taxRates": { "elements": [{ "id": "K39PGKDKFYD2C", "lineItemRef": { "id": "5MK7620A765PP" }, "name": "NY Sales Tax", "rate": 887500, "isDefault": true }] } }, { "id": "QWEG1P1NWXGC6", "orderRef": { "id": "CJ0EQZKMJGW8A" }, "item": { "id": "P16DGQX38D03T", "hidden": false, "name": "2 Ladies", "alternateName": "", "code": "G01014", "sku": "MT000100B2", "price": 436, "priceType": "FIXED", "defaultTaxRates": true, "unitName": "", "cost": 3, "isRevenue": true, "stockCount": 0, "modifiedTime": 1612216810000 }, "name": "2 Ladies", "alternateName": "", "price": 436, "itemCode": "G01014", "note": "", "printed": false, "createdTime": 1616115884000, "orderClientCreatedTime": 1616115883000, "exchanged": false, "modifications": { "elements": [{ "id": "F3T840QG8FK9M", "lineItemRef": { "id": "QWEG1P1NWXGC6" }, "name": "( M )", "amount": 0, "modifier": { "id": "ZN7QD4BP4F73J" } }, { "id": "S464M2MR0FXQJ", "lineItemRef": { "id": "QWEG1P1NWXGC6" }, "name": "(Regular Ice)", "amount": 0, "modifier": { "id": "ARHY5QR86TXV4" } }, { "id": "SFYJDC17A629R", "lineItemRef": { "id": "QWEG1P1NWXGC6" }, "name": "(Sweeter)", "amount": 0, "modifier": { "id": "CY7DBTFJT6MPA" } }, { "id": "99PN88P0RPVS6", "lineItemRef": { "id": "QWEG1P1NWXGC6" }, "name": "Regular", "amount": 0, "modifier": { "id": "WGCT8XY76J63A" } } ] }, "refunded": false, "isRevenue": true, "taxRates": { "elements": [{ "id": "K39PGKDKFYD2C", "lineItemRef": { "id": "QWEG1P1NWXGC6" }, "name": "NY Sales Tax", "rate": 887500, "isDefault": true }] } } ] }, "taxRates": { "elements": [{ "id": "K39PGKDKFYD2C", "name": "NY Sales Tax", "amount": 77 }] }, "payments": { "elements": [{ "id": "F5GY30B3EHRCP", "order": { "id": "CJ0EQZKMJGW8A" }, "tender": { "href": "<REDACTED>", "id": "9M4D54Z8MP7Q2" }, "amount": 475, "tipAmount": 0, "taxAmount": 39, "employee": { "id": "9Z1RS40CEDN7G" }, "createdTime": 1616115887000, "clientCreatedTime": 1616115887000, "modifiedTime": 1616115886000, "result": "SUCCESS", "note": "<REDACTED> QuickPay" }] } }