Find item tax code used by line item through the SuiteQL

62 Views Asked by At

I need to find the tax code used per line item from invoices. I tried few queries, this is one of them :

SELECT

    Invoice.id,
    Invoice.trandate,
    Invoice.createddate,
    Invoice.tranid,

    lineitem.transaction as line_transaction,
    lineitem.class as line_class,
    BUILTIN.DF(lineitem.class) as line_class_name,
    lineitem.itemtype as line_type,

    BUILTIN.DF(lineitem.itemtype) as line_type_name,

    lineitem.id AS line_id,
    lineitem.uniquekey AS line_uniquekey,

    ABS(lineitem.quantity) AS line_quantity,

    BUILTIN.CF(lineitem.item) AS line_product_id,
    BUILTIN.DF(lineitem.item) AS line_product_sku,

    ABS(lineitem.foreignamount) AS line_item_fxamount,
    ABS(lineitem.netamount) AS line_item_net_amount,
    lineitem.memo AS line_taxes_code,
    lineitem.rate AS line_taxes_rate

FROM
    transaction AS Invoice

INNER JOIN 
    transactionline AS lineitem ON Invoice.id = lineitem.transaction AND lineitem.mainline = 'F'

WHERE
    Invoice.type = 'CustInvc' AND
    lineitem.class IN (173)

ORDER BY
    Invoice.id ASC,
    lineitem.linesequencenumber ASC,
    lineitem.id ASC

The query returns all items attached to an invoice, and it returns the taxe lines related to the invoice (not to line item). Based on NS connect schema it should have a table that contains the data related to taxes transaction and transactionline. BUT this table is not available for SuiteQL through rest api or N/query api.

I have few ideas (custom solution, through N/api. eg. load record->get taxes... ), but now I want to do it through a "standard way".

Do you know how to get taxes by line item via SuiteQL? Thank YOU!

0

There are 0 best solutions below