Is it possible to retrieve the COGS of a fulfilled...
# suiteql
g
Is it possible to retrieve the COGS of a fulfilled order using SuiteQL? I have tried but without success.
m
Join from the item fulfillment to the table transactionaccountingline and filter out the lines with account type COGS
g
I have a simple query like this one, but i m not sure how to get that join with transactionaccountingline, something is not working:
Copy code
SELECT 
    tran.trandate AS "date",
    tran.tranid AS "id",
    tran.custbody_external_system_number AS "woo_id",
    BUILTIN.DF(tran.entity) AS "customer_name",
    BUILTIN.DF(tran.status) AS "status",
    tran.custbodysale_source AS "sale_source",
    NVL(tran.totalaftertaxes, 0) AS "income_billed",
    (tran.totalaftertaxes * 0.005) AS "badgodsreturns_cost",
    BUILTIN.DF(acctline.account) AS "account_name",
    acctline.amount AS "cogs_amount"
FROM 
    transaction tran
    INNER JOIN transactionaccountingline acctline 
        ON tran.id = acctline.transaction
WHERE 
    tran.type = 'SalesOrd'
    AND acctline.accounttype = 'COGS' COGS
    AND tran.trandate >= TO_DATE('2024-11-26', 'YYYY-MM-DD') 
ORDER BY 
    tran.trandate DESC;