From a626046e89b3b4ff68feb3a829d60af35ea595a8 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 19 Aug 2025 13:49:51 +0700 Subject: add calculate margin invoice v3 --- calculate_margin_invoice_v3.ktr | 2328 +++++++++++++++++++++++++++++++++++++++ run_single_ktr.sh | 2 +- 2 files changed, 2329 insertions(+), 1 deletion(-) create mode 100644 calculate_margin_invoice_v3.ktr diff --git a/calculate_margin_invoice_v3.ktr b/calculate_margin_invoice_v3.ktr new file mode 100644 index 0000000..fa17fbb --- /dev/null +++ b/calculate_margin_invoice_v3.ktr @@ -0,0 +1,2328 @@ + + + + calculate_margin_invoice_v3 + + + + Normal + / + + + + + + + + + + + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + TRANSNAME + Y + TRANSNAME + + + STATUS + Y + STATUS + + + LINES_READ + Y + LINES_READ + + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + + LINES_UPDATED + Y + LINES_UPDATED + + + + LINES_INPUT + Y + LINES_INPUT + + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + + LINES_REJECTED + Y + LINES_REJECTED + + + + ERRORS + Y + ERRORS + + + STARTDATE + Y + STARTDATE + + + ENDDATE + Y + ENDDATE + + + LOGDATE + Y + LOGDATE + + + DEPDATE + Y + DEPDATE + + + REPLAYDATE + Y + REPLAYDATE + + + LOG_FIELD + Y + LOG_FIELD + + + EXECUTING_SERVER + N + EXECUTING_SERVER + + + EXECUTING_USER + N + EXECUTING_USER + + + CLIENT + N + CLIENT + + + + + +
+ + + + ID_BATCH + Y + ID_BATCH + + + SEQ_NR + Y + SEQ_NR + + + LOGDATE + Y + LOGDATE + + + TRANSNAME + Y + TRANSNAME + + + STEPNAME + Y + STEPNAME + + + STEP_COPY + Y + STEP_COPY + + + LINES_READ + Y + LINES_READ + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + LINES_UPDATED + Y + LINES_UPDATED + + + LINES_INPUT + Y + LINES_INPUT + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + LINES_REJECTED + Y + LINES_REJECTED + + + ERRORS + Y + ERRORS + + + INPUT_BUFFER_ROWS + Y + INPUT_BUFFER_ROWS + + + OUTPUT_BUFFER_ROWS + Y + OUTPUT_BUFFER_ROWS + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + LOGGING_OBJECT_TYPE + Y + LOGGING_OBJECT_TYPE + + + OBJECT_NAME + Y + OBJECT_NAME + + + OBJECT_COPY + Y + OBJECT_COPY + + + REPOSITORY_DIRECTORY + Y + REPOSITORY_DIRECTORY + + + FILENAME + Y + FILENAME + + + OBJECT_ID + Y + OBJECT_ID + + + OBJECT_REVISION + Y + OBJECT_REVISION + + + PARENT_CHANNEL_ID + Y + PARENT_CHANNEL_ID + + + ROOT_CHANNEL_ID + Y + ROOT_CHANNEL_ID + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + TRANSNAME + Y + TRANSNAME + + + STEPNAME + Y + STEPNAME + + + STEP_COPY + Y + STEP_COPY + + + LINES_READ + Y + LINES_READ + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + LINES_UPDATED + Y + LINES_UPDATED + + + LINES_INPUT + Y + LINES_INPUT + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + LINES_REJECTED + Y + LINES_REJECTED + + + ERRORS + Y + ERRORS + + + LOG_FIELD + N + LOG_FIELD + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + METRICS_DATE + Y + METRICS_DATE + + + METRICS_CODE + Y + METRICS_CODE + + + METRICS_DESCRIPTION + Y + METRICS_DESCRIPTION + + + METRICS_SUBJECT + Y + METRICS_SUBJECT + + + METRICS_TYPE + Y + METRICS_TYPE + + + METRICS_VALUE + Y + METRICS_VALUE + + + + + +
+ + 0.0 + 0.0 + + 10000 + 50 + 50 + N + Y + 50000 + Y + + N + 1000 + 100 + + + + + + + + + - + 2025/08/13 09:47:28.228 + - + 2025/08/13 09:47:28.228 + + N + + + + + dw bi indoteknik (localhost) + localhost + POSTGRESQL + Native + dw_bi_indoteknik + 5432 + odoo + Encrypted 2be98afc82bdfd8dd9a2ca45acc83f6c3 + + + + + + FORCE_IDENTIFIERS_TO_LOWERCASE + N + + + FORCE_IDENTIFIERS_TO_UPPERCASE + N + + + IS_CLUSTERED + N + + + PORT_NUMBER + 5432 + + + PRESERVE_RESERVED_WORD_CASE + Y + + + QUOTE_ALL_FIELDS + N + + + SUPPORTS_BOOLEAN_DATA_TYPE + Y + + + SUPPORTS_TIMESTAMP_DATA_TYPE + N + + + USE_POOLING + N + + + + + + Table input + penjualan + Y + + + Table input 2 + hpp + Y + + + penjualan + Merge join + Y + + + hpp + Merge join + Y + + + Merge join + Filter rows + Y + + + Filter rows + Write to log + Y + + + Filter rows + select all + Y + + + select all + param only + Y + + + param only + Table input 3 + Y + + + select all + all + Y + + + all + Sort rows + Y + + + Table input 3 + Sort rows 2 + Y + + + Sort rows + Merge join 2 + Y + + + Sort rows 2 + Merge join 2 + Y + + + Merge join 2 + Add constants + Y + + + Add constants + Calculator + Y + + + Calculator + Select values + Y + + + Select values + Insert / update + Y + + + + Table input + TableInput + + Y + + 1 + + none + + + dw bi indoteknik (localhost) + select aml.id, am.id as move_id, am.date, am.invoice_origin, am.name as invoice, coalesce(gp.name, rp.name) as customer, +rpi.name as lob, b.name as brand, p.product_id, p.item_code, p.name as product, rp2.name as salesperson, +aml.quantity, aml.price_unit, aml.price_subtotal, aml.price_total, +0-aml.balance as penjualan +from account_move_line aml +join account_move am on am.id = aml.move_id +join product p on p.product_id = aml.product_id +join res_partner rp on rp.id = am.partner_id +join res_users ru on ru.id = am.invoice_user_id +join res_partner rp2 on rp2.id = ru.partner_id +join account_account aa on aa.id = aml.account_id +left join res_partner_industry rpi on rpi.id = rp.industry_id +left join group_partner gp on gp.id = rp.group_partner_id +left join brand b on b.id = p.brand_id +where 1=1 +and aml.account_id = 462 +and am.state = 'posted' +and aml.date >= '2024-06-01' +--and aml.write_date >= (now() - '3 days'::interval) + 0 + + N + N + N + N + + + Integer + normal + id + 9 + 0 + Table input + id + ####0;-####0 + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + Integer + normal + move_id + 9 + 0 + Table input + move_id + ####0;-####0 + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + Date + normal + date + -1 + -1 + Table input + date + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + String + normal + invoice_origin + 2147483647 + -1 + Table input + invoice_origin + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + String + normal + invoice + 2147483647 + -1 + Table input + invoice + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + String + normal + customer + 2147483647 + -1 + Table input + customer + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + String + normal + lob + 2147483647 + -1 + Table input + lob + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + String + normal + brand + 2147483647 + -1 + Table input + brand + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + Integer + normal + product_id + 9 + 0 + Table input + product_id + ####0;-####0 + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + String + normal + item_code + 2147483647 + -1 + Table input + item_code + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + String + normal + product + 2147483647 + -1 + Table input + product + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + String + normal + salesperson + 2147483647 + -1 + Table input + salesperson + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + BigNumber + normal + quantity + -1 + -1 + Table input + quantity + ######0.0###################;-######0.0################### + . + + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + BigNumber + normal + price_unit + -1 + -1 + Table input + price_unit + ######0.0###################;-######0.0################### + . + + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + BigNumber + normal + price_subtotal + -1 + -1 + Table input + price_subtotal + ######0.0###################;-######0.0################### + . + + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + BigNumber + normal + price_total + -1 + -1 + Table input + price_total + ######0.0###################;-######0.0################### + . + + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + BigNumber + normal + penjualan + -1 + -1 + Table input + penjualan + ######0.0###################;-######0.0################### + . + + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + + + + + + + + + + 144 + 80 + Y + + + + penjualan + SortRows + + Y + + 1 + + none + + + %%java.io.tmpdir%% + out + 1000000 + + N + + N + + + id + Y + N + N + 0 + N + + + + + + + + + + + + 144 + 176 + Y + + + + Table input 2 + TableInput + + Y + + 1 + + none + + + dw bi indoteknik (localhost) + select aml.id, am.id as move_id, aml.product_id, aml.balance as hpp +from account_move_line aml +join account_move am on am.id = aml.move_id +--join product p on p.product_id = aml.product_id +--join res_partner rp on rp.id = am.partner_id +--join res_users ru on ru.id = am.invoice_user_id +--join res_partner rp2 on rp2.id = ru.partner_id +--join account_account aa on aa.id = aml.account_id +--left join res_partner_industry rpi on rpi.id = rp.industry_id +--left join group_partner gp on gp.id = rp.group_partner_id +--left join brand b on b.id = p.brand_id +where 1=1 +and aml.account_id = 466 +and am.state = 'posted' +and aml.date >= '2024-06-01' +--and aml.write_date >= (now() - '3 days'::interval) + 0 + + N + N + N + N + + + Integer + normal + id + 9 + 0 + Table input 2 + id + ####0;-####0 + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + Integer + normal + move_id + 9 + 0 + Table input 2 + move_id + ####0;-####0 + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + Integer + normal + product_id + 9 + 0 + Table input 2 + product_id + ####0;-####0 + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + BigNumber + normal + hpp + -1 + -1 + Table input 2 + hpp + ######0.0###################;-######0.0################### + . + + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + + + + + + + + + + 320 + 80 + Y + + + + hpp + SortRows + + Y + + 1 + + none + + + %%java.io.tmpdir%% + out + 1000000 + + N + + N + + + id + Y + N + N + 0 + N + + + + + + + + + + + + 320 + 176 + Y + + + + Merge join + MergeJoin + + Y + + 1 + + none + + + LEFT OUTER + penjualan + hpp + + move_id + product_id + + + move_id + product_id + + + + + + + + + + + 240 + 288 + Y + + + + Filter rows + FilterRows + + Y + + 1 + + none + + + select all + Write to log + + + N + + + N + penjualan + > + + + constant + BigNumber + 0.0 + -1 + -1 + N + ######0.0###################;-######0.0################### + + + + N + AND + hpp + > + + + constant + BigNumber + 0.0 + -1 + -1 + N + ######0.0###################;-######0.0################### + + + + + + + + + + + + + + + 416 + 288 + Y + + + + Write to log + WriteToLog + + Y + + 1 + + none + + + log_level_basic + Y + N + 0 + + + + + + + + + + + + + 416 + 400 + Y + + + + select all + SelectValues + + N + + 1 + + none + + + + + id + + + + move_id + + + + date + + + + invoice_origin + + + + invoice + + + + customer + + + + lob + + + + brand + + + + product_id + + + + item_code + + + + product + + + + salesperson + + + + quantity + + + + price_unit + + + + price_subtotal + + + + price_total + + + + penjualan + + + + id_1 + + + + move_id_1 + + + + product_id_1 + + + + hpp + + + N + + + + + + + + + + + 560 + 288 + Y + + + + param only + SelectValues + + Y + + 1 + + none + + + + + id + + + + invoice_origin + + + + product_id + + + N + + + + + + + + + + + 688 + 192 + Y + + + + Table input 3 + TableInput + + Y + + 1 + + none + + + dw bi indoteknik (localhost) + select ? as id, tso.name as sale_order, tsol.product_id as sale_product_id, tsol.vendor_id, rp.name as vendor +from t_sale_order_line tsol +join t_sale_order tso on tso.id = tsol.order_id +join res_partner rp on rp.id = tsol.vendor_id +where 1=1 +and tso.name = ? and tsol.vendor_id = ? + 0 + param only + Y + N + N + N + + + String + normal + id + 2147483647 + -1 + Table input 3 + id + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + String + normal + sale_order + 2147483647 + -1 + Table input 3 + sale_order + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + Integer + normal + sale_product_id + 9 + 0 + Table input 3 + sale_product_id + ####0;-####0 + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + Integer + normal + vendor_id + 9 + 0 + Table input 3 + vendor_id + ####0;-####0 + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + String + normal + vendor + 2147483647 + -1 + Table input 3 + vendor + + . + , + + none + N + Y + 0 + N + N + N + en_US + Asia/Bangkok + N + + + + + + + + + + + + 832 + 192 + Y + + + + all + SelectValues + + Y + + 1 + + none + + + + + id + + + + move_id + + + + date + + + + invoice_origin + + + + invoice + + + + customer + + + + lob + + + + brand + + + + product_id + + + + item_code + + + + product + + + + salesperson + + + + quantity + + + + price_unit + + + + price_subtotal + + + + price_total + + + + penjualan + + + + id_1 + + + + move_id_1 + + + + product_id_1 + + + + hpp + + + N + + + + + + + + + + + 688 + 320 + Y + + + + Sort rows + SortRows + + Y + + 1 + + none + + + %%java.io.tmpdir%% + out + 1000000 + + N + + N + + + id + Y + N + N + 0 + N + + + + + + + + + + + + 688 + 400 + Y + + + + Sort rows 2 + SortRows + + Y + + 1 + + none + + + %%java.io.tmpdir%% + out + 1000000 + + N + + N + + + id + Y + N + N + 0 + N + + + + + + + + + + + + 832 + 272 + Y + + + + Merge join 2 + MergeJoin + + Y + + 1 + + none + + + LEFT OUTER + Sort rows + Sort rows 2 + + id + + + id + + + + + + + + + + + 832 + 400 + Y + + + + Calculator + Calculator + + Y + + 1 + + none + + + Y + + margin + SUBTRACT + penjualan + hpp + + None + -1 + -1 + N + + + + + + + div_margin + DIVIDE + margin + penjualan + + None + -1 + -1 + N + + + + + + + percent_margin + MULTIPLY + div_margin + one_hundred + + None + -1 + -1 + N + + + + + + + + + + + + + + + 992 + 160 + Y + + + + Add constants + Constant + + Y + + 1 + + none + + + + + one_hundred + BigNumber + + + + + 100 + -1 + -1 + N + + + + + + + + + + + + 992 + 32 + Y + + + + Select values + SelectValues + + Y + + 1 + + none + + + + + id + + + + move_id + + + + date + + + + invoice_origin + + + + invoice + + + + customer + + + + lob + + + + brand + + + + product_id + + + + item_code + + + + product + + + + salesperson + + + + quantity + + + + price_unit + + + + price_subtotal + + + + price_total + + + + penjualan + + + + hpp + + + + sale_order + + + + sale_product_id + + + + vendor_id + + + + vendor + + + + margin + + + + div_margin + + + + percent_margin + + + N + + + + + + + + + + + 992 + 256 + Y + + + + Insert / update + InsertUpdate + + Y + + 1 + + none + + + dw bi indoteknik (localhost) + 100 + N + + public +
margin_invoice_v3
+ + + id + + + + + id + id + N + + + move_id + move_id + Y + + + date + date + Y + + + invoice_origin + invoice_origin + Y + + + invoice + invoice + Y + + + customer + customer + Y + + + lob + lob + Y + + + brand + brand + Y + + + product_id + product_id + Y + + + item_code + item_code + Y + + + product + product + Y + + + salesperson + salesperson + Y + + + quantity + quantity + Y + + + price_unit + price_unit + Y + + + price_subtotal + price_subtotal + Y + + + price_total + price_total + Y + + + penjualan + penjualan + Y + + + hpp + hpp + Y + + + sale_order + sale_order + Y + + + sale_product_id + sale_product_id + Y + + + vendor_id + vendor_id + Y + + + vendor + vendor + Y + + + margin + margin + Y + + + div_margin + div_margin + Y + + + percent_margin + percent_margin + Y + + + + + + + + + + + + 992 + 352 + Y + + + + + + + N + +
diff --git a/run_single_ktr.sh b/run_single_ktr.sh index a684fb9..f87e0d9 100644 --- a/run_single_ktr.sh +++ b/run_single_ktr.sh @@ -1 +1 @@ -sh /home/stephan/data-integration/pan.sh -level="Debug" -file="/home/stephan/transformation-job-bi/calculate_leadtime_po_to_mr.ktr" > "/home/stephan/transformation-job-bi/log/run_single_ktr.log" +sh /home/stephan/data-integration/pan.sh -level="Debug" -file="/home/stephan/transformation-job-bi/calculate_margin_invoice_v3" > "/home/stephan/transformation-job-bi/log/run_single_ktr.log" -- cgit v1.2.3