foxtrot
foxtrot

Reputation: 1096

How can I get lines of tax and where was applied?

I get this kind of data from the Journal Transactions API.

{
    "UID": "",
    "DisplayID": "00000001",
    "JournalType": "Purchase",
    "SourceTransaction": {
        "UID": "",
        "TransactionType": "Bill",
        "URI": ""
    },
    "DateOccurred": "2024-04-01T00:00:00",
    "DatePosted": "2024-04-18T09:24:10.657",
    "Description": "Purchase; Supplier AA",
    "Lines": [
        {
            "Account": {
                "UID": "",
                "Name": "Inventory",
                "DisplayID": "1-1320",
                "URI": ""
            },
            "Amount": 1500.0,
            "IsCredit": false,
            "Job": null,
            "LineDescription": "Books; Books",
            "ReconciledDate": null,
            "UnitCount": null
        },
        {
            "Account": {
                "UID": "",
                "Name": "GST Paid",
                "DisplayID": "2-1220",
                "URI": ""
            },
            "Amount": 150.0,
            "IsCredit": false,
            "Job": null,
            "LineDescription": "",
            "ReconciledDate": null,
            "UnitCount": null
        },
        {
            "Account": {
                "UID": "",
                "Name": "Trade Creditors",
                "DisplayID": "2-1510",
                "URI": ""
            },
            "Amount": 1650.0,
            "IsCredit": true,
            "Job": null,
            "LineDescription": "",
            "ReconciledDate": null,
            "UnitCount": null
        }
    ],
    "URI": "",
    "RowVersion": "-7620372044487589888"
},

How can I know which line is GST? And to which line was applied? It seems the account name is always GST Collected or GST Paid. But this way I would need to iterate the lines and do calculations. To go with calculations:

  1. I would need to look for the row with the highest value
  2. Divide it by 1.10, and subtract to get the tax
  3. Look for the row with the tax
  4. Finally calculate the subtraction between the highest value and the tax, to know to which line the tax was applied

Anyone knows a better solution? I'm using MYOB AccountRight, the Business API v2 on Windows, to get the data. Here’s the documentation: https://developer.myob.com/api/myob-business-api/v2/

Upvotes: 0

Views: 24

Answers (0)

Related Questions