From 055696d38bca31f494a798637e5bd4739dae2e0e Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 15 May 2024 16:54:29 +0700 Subject: calculate profit and loss --- calculate_financial_report.ktr | 222 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 197 insertions(+), 25 deletions(-) (limited to 'calculate_financial_report.ktr') diff --git a/calculate_financial_report.ktr b/calculate_financial_report.ktr index eae8260..f3094f7 100644 --- a/calculate_financial_report.ktr +++ b/calculate_financial_report.ktr @@ -436,14 +436,14 @@ - dw bi indoteknik + dw bi indoteknik (localhost) localhost POSTGRESQL Native dw_bi_indoteknik - 5703 - metabase - Encrypted 2be98dfba28d7bf86853c9f58cfc4f889 + 5432 + odoo + Encrypted 2be98afc82bdfd8dd9a2ca45acc83f6c3 @@ -462,7 +462,7 @@ PORT_NUMBER - 5703 + 5432 PRESERVE_RESERVED_WORD_CASE @@ -478,7 +478,7 @@ SUPPORTS_TIMESTAMP_DATA_TYPE - Y + N USE_POOLING @@ -627,14 +627,24 @@ Merge join 14 Y + + combine select + Insert / update + Y + + + total_fy + Merge join 15 + Y + Merge join 14 - combine select + Merge join 15 Y - combine select - Insert / update + Merge join 15 + combine select Y @@ -649,7 +659,7 @@ none - dw bi indoteknik + dw bi indoteknik (localhost) 100 N @@ -746,6 +756,11 @@ fy12 Y + + total_fy + total_fy + Y + @@ -1317,6 +1332,10 @@ fy12 + + total_fy + + N @@ -1344,7 +1363,7 @@ none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as ly_full from account_move_line aml @@ -1463,7 +1482,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as ly_current from account_move_line aml @@ -1582,7 +1601,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) -- query for ratio profit and loss select afrr.id, afrr.name, ( @@ -1702,7 +1721,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy1 from account_move_line aml @@ -1822,7 +1841,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy10 from account_move_line aml @@ -1942,7 +1961,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy11 from account_move_line aml @@ -2062,7 +2081,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy12 from account_move_line aml @@ -2182,7 +2201,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy2 from account_move_line aml @@ -2302,7 +2321,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy3 from account_move_line aml @@ -2422,7 +2441,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy4 from account_move_line aml @@ -2542,7 +2561,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy5 from account_move_line aml @@ -2662,7 +2681,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy6 from account_move_line aml @@ -2782,7 +2801,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy7 from account_move_line aml @@ -2902,7 +2921,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy8 from account_move_line aml @@ -3022,7 +3041,7 @@ order by id none - dw bi indoteknik + dw bi indoteknik (localhost) select afrr.id, afrr.name, ( select 0-coalesce(sum(balance),0) as fy9 from account_move_line aml @@ -3131,6 +3150,159 @@ order by id Y + + total_fy + TableInput + + Y + + 1 + + none + + + dw bi indoteknik (localhost) + select afrr.id, afrr.name, +( + select 0-coalesce(sum(balance),0) as total_fy from account_move_line aml + join account_move am on am.id = aml.move_id + where aml.account_id in( + select account_id from account_account_financial_report aafr + where aafr.report_line_id in( + select id from account_financial_report afr where id = afrr.id + ) + ) + and am.state = 'posted' + and to_char(am."date",'YYYY') = get_now_year() +) +from account_financial_report afrr +where afrr.parent_id = 321 +order by id + 0 + + N + N + N + N + + + Integer + normal + id + 9 + 0 + month12 2 + id + ####0;-####0 + . + , + + none + N + Y + 0 + N + N + N + en_ID + Asia/Bangkok + N + + + String + normal + name + 2147483647 + -1 + month12 2 + name + + . + , + + none + N + Y + 0 + N + N + N + en_ID + Asia/Bangkok + N + + + BigNumber + normal + total_fy + -1 + -1 + month12 2 + total_fy + ######0.0###################;-######0.0################### + . + + + none + N + Y + 0 + N + N + N + en_ID + Asia/Bangkok + N + + + + + + + + + + + + 608 + 336 + Y + + + + Merge join 15 + MergeJoin + + Y + + 1 + + none + + + INNER + Merge join 14 + total_fy + + id + + + id + + + + + + + + + + + 608 + 256 + Y + + -- cgit v1.2.3