Guido Gallo
11/28/2024, 5:59 PMmesper
11/29/2024, 9:12 AMGuido Gallo
11/29/2024, 4:09 PMSELECT
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;