From 6f61b08f819ab179206d5c348a9de3e84cfe69e5 Mon Sep 17 00:00:00 2001 From: "hello@lv" <2256334253@qq.com> Date: Thu, 21 Mar 2024 17:44:55 +0800 Subject: [PATCH] feat_view_invoices_sql (#454) Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachycode/pulls/454 Reviewed-by: sealday Co-authored-by: hello@lv <2256334253@qq.com> Co-committed-by: hello@lv <2256334253@qq.com> --- .../src/server/sqls/view_invoices.sql | 100 +++++++++++------- 1 file changed, 61 insertions(+), 39 deletions(-) diff --git a/packages/plugins/@hera/plugin-rental/src/server/sqls/view_invoices.sql b/packages/plugins/@hera/plugin-rental/src/server/sqls/view_invoices.sql index 46b4412a2..2105545d1 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/sqls/view_invoices.sql +++ b/packages/plugins/@hera/plugin-rental/src/server/sqls/view_invoices.sql @@ -9,25 +9,22 @@ SELECT seller_id, purchaser_id, category, -TYPE, -"Invoicing_date", -COMMENT, -inclusive_amount, -NAME, -CONTENT, -tax_rate, -tax_amount, -net_amount, -authentication_date, -state, -CASE - WHEN "type"::TEXT = 'input_invoice'::TEXT THEN seller_id - ELSE purchaser_id -END AS opposite_id, -CASE - WHEN "type"::TEXT = 'input_invoice'::TEXT THEN purchaser_id - ELSE seller_id -END AS company_id + CAST('进项发票' AS TEXT) AS "type", + "Invoicing_date", + "comment", + inclusive_amount, + "name", + "content", + tax_rate, + tax_amount, + net_amount, + authentication_date, + "state", + seller_id AS opposite_id, + purchaser_id AS company_id, + - CAST(tax_rate AS FLOAT8) AS sign_tax_rate, + - CAST(tax_amount AS FLOAT8) AS sign_tax_amount, + - CAST(net_amount AS FLOAT8) AS sign_net_amount FROM invoice_input UNION @@ -40,24 +37,49 @@ SELECT seller_id, purchaser_id, category, -TYPE, -"Invoicing_date", -COMMENT, -inclusive_amount, -NAME, -CONTENT, -tax_rate, -tax_amount, -net_amount, -authentication_date, -state, -CASE - WHEN "type"::TEXT = 'input_invoice'::TEXT THEN seller_id - ELSE purchaser_id -END AS opposite_id, -CASE - WHEN "type"::TEXT = 'input_invoice'::TEXT THEN purchaser_id - ELSE seller_id -END AS company_id + CAST('销项发票' AS TEXT) AS "type", + "Invoicing_date", + "comment", + inclusive_amount, + "name", + "content", + tax_rate, + tax_amount, + net_amount, + authentication_date, + "state", + purchaser_id AS opposite_id, + seller_id AS company_id, + CAST(tax_rate AS FLOAT8) AS tax_rate, + CAST(tax_amount AS FLOAT8) AS tax_amount, + CAST(net_amount AS FLOAT8) AS net_amount FROM - invoice_output; + invoice_output +UNION +SELECT + "createdAt", + "updatedAt", + "createdById", + "updatedById", + number, + seller_id, + purchaser_id, + category, + CAST('进项发票' AS TEXT) AS "type", + "Invoicing_date", + "comment", + inclusive_amount, + NULL AS "name", + "content", + '1' AS tax_rate, + tax_amount, + '0' AS net_amount, + authentication_date, + "state", + seller_id AS opposite_id, + purchaser_id AS company_id, + - CAST(1 AS FLOAT8) AS sign_tax_rate, + - CAST(tax_amount AS FLOAT8) AS sign_tax_amount, + CAST(0 AS FLOAT8) AS sign_net_amount +FROM + invoice_receipt