diff --git a/packages/plugins/@hera/plugin-core/src/server/sqls/view_invoices.sql b/packages/plugins/@hera/plugin-core/src/server/sqls/view_invoices.sql deleted file mode 100644 index 891c68a41..000000000 --- a/packages/plugins/@hera/plugin-core/src/server/sqls/view_invoices.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE OR REPLACE VIEW - public.view_invoice AS -SELECT "createdAt", - "updatedAt", - sort, - "createdById", - "updatedById", - id, - seller_id, - purchaser_id, - category, - type, - "Invoicing_date", - comment, - number, - inclusive_amount, - name, - conten, - 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 - FROM invoice_new; 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 new file mode 100644 index 000000000..46b4412a2 --- /dev/null +++ b/packages/plugins/@hera/plugin-rental/src/server/sqls/view_invoices.sql @@ -0,0 +1,63 @@ +CREATE OR REPLACE VIEW + public.view_invoice_all AS +SELECT + "createdAt", + "updatedAt", + "createdById", + "updatedById", + number, + 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 +FROM + invoice_input +UNION +SELECT + "createdAt", + "updatedAt", + "createdById", + "updatedById", + number, + 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 +FROM + invoice_output;