feat_view_invoices_sql (#454)
Reviewed-on: daoyoucloud/tachycode#454 Reviewed-by: sealday <zhanglin@daoyoucloud.com> Co-authored-by: hello@lv <2256334253@qq.com> Co-committed-by: hello@lv <2256334253@qq.com>
This commit is contained in:
parent
18e929a275
commit
6f61b08f81
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user