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,
|
seller_id,
|
||||||
purchaser_id,
|
purchaser_id,
|
||||||
category,
|
category,
|
||||||
TYPE,
|
CAST('进项发票' AS TEXT) AS "type",
|
||||||
"Invoicing_date",
|
"Invoicing_date",
|
||||||
COMMENT,
|
"comment",
|
||||||
inclusive_amount,
|
inclusive_amount,
|
||||||
NAME,
|
"name",
|
||||||
CONTENT,
|
"content",
|
||||||
tax_rate,
|
tax_rate,
|
||||||
tax_amount,
|
tax_amount,
|
||||||
net_amount,
|
net_amount,
|
||||||
authentication_date,
|
authentication_date,
|
||||||
state,
|
"state",
|
||||||
CASE
|
seller_id AS opposite_id,
|
||||||
WHEN "type"::TEXT = 'input_invoice'::TEXT THEN seller_id
|
purchaser_id AS company_id,
|
||||||
ELSE purchaser_id
|
- CAST(tax_rate AS FLOAT8) AS sign_tax_rate,
|
||||||
END AS opposite_id,
|
- CAST(tax_amount AS FLOAT8) AS sign_tax_amount,
|
||||||
CASE
|
- CAST(net_amount AS FLOAT8) AS sign_net_amount
|
||||||
WHEN "type"::TEXT = 'input_invoice'::TEXT THEN purchaser_id
|
|
||||||
ELSE seller_id
|
|
||||||
END AS company_id
|
|
||||||
FROM
|
FROM
|
||||||
invoice_input
|
invoice_input
|
||||||
UNION
|
UNION
|
||||||
@ -40,24 +37,49 @@ SELECT
|
|||||||
seller_id,
|
seller_id,
|
||||||
purchaser_id,
|
purchaser_id,
|
||||||
category,
|
category,
|
||||||
TYPE,
|
CAST('销项发票' AS TEXT) AS "type",
|
||||||
"Invoicing_date",
|
"Invoicing_date",
|
||||||
COMMENT,
|
"comment",
|
||||||
inclusive_amount,
|
inclusive_amount,
|
||||||
NAME,
|
"name",
|
||||||
CONTENT,
|
"content",
|
||||||
tax_rate,
|
tax_rate,
|
||||||
tax_amount,
|
tax_amount,
|
||||||
net_amount,
|
net_amount,
|
||||||
authentication_date,
|
authentication_date,
|
||||||
state,
|
"state",
|
||||||
CASE
|
purchaser_id AS opposite_id,
|
||||||
WHEN "type"::TEXT = 'input_invoice'::TEXT THEN seller_id
|
seller_id AS company_id,
|
||||||
ELSE purchaser_id
|
CAST(tax_rate AS FLOAT8) AS tax_rate,
|
||||||
END AS opposite_id,
|
CAST(tax_amount AS FLOAT8) AS tax_amount,
|
||||||
CASE
|
CAST(net_amount AS FLOAT8) AS net_amount
|
||||||
WHEN "type"::TEXT = 'input_invoice'::TEXT THEN purchaser_id
|
|
||||||
ELSE seller_id
|
|
||||||
END AS company_id
|
|
||||||
FROM
|
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