Migrations for invoices and invoice lines. Added invoice enter modal.

This commit is contained in:
Patrick Fic
2020-02-24 17:09:17 -08:00
parent 13faf47044
commit f70627b5da
31 changed files with 730 additions and 23 deletions

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: DROP TABLE "public"."invoices";
type: run_sql

View File

@@ -0,0 +1,28 @@
- args:
cascade: false
read_only: false
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
cascade: false
read_only: false
sql: "CREATE TABLE \"public\".\"invoices\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"vendorid\" uuid NOT NULL, \"jobid\" uuid NOT NULL,
\"date\" date NOT NULL DEFAULT now(), \"due_date\" date, \"exported\" boolean
NOT NULL DEFAULT false, \"exported_at\" timestamptz, \"is_credit_memo\" boolean
NOT NULL DEFAULT false, \"total\" numeric NOT NULL DEFAULT 0, \"invoice_number\"
text NOT NULL, PRIMARY KEY (\"id\") , FOREIGN KEY (\"jobid\") REFERENCES \"public\".\"jobs\"(\"id\")
ON UPDATE restrict ON DELETE cascade, FOREIGN KEY (\"vendorid\") REFERENCES
\"public\".\"vendors\"(\"id\") ON UPDATE restrict ON DELETE restrict, UNIQUE
(\"jobid\"));\nCREATE OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS
TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\"
= NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_invoices_updated_at\"\nBEFORE
UPDATE ON \"public\".\"invoices\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_invoices_updated_at\" ON \"public\".\"invoices\" \nIS
'trigger to set value of column \"updated_at\" to current timestamp on row update';"
type: run_sql
- args:
name: invoices
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,24 @@
- args:
relationship: job
table:
name: invoices
schema: public
type: drop_relationship
- args:
relationship: vendor
table:
name: invoices
schema: public
type: drop_relationship
- args:
relationship: invoice
table:
name: jobs
schema: public
type: drop_relationship
- args:
relationship: invoices
table:
name: vendors
schema: public
type: drop_relationship

View File

@@ -0,0 +1,41 @@
- args:
name: job
table:
name: invoices
schema: public
using:
foreign_key_constraint_on: jobid
type: create_object_relationship
- args:
name: vendor
table:
name: invoices
schema: public
using:
foreign_key_constraint_on: vendorid
type: create_object_relationship
- args:
name: invoice
table:
name: jobs
schema: public
using:
manual_configuration:
column_mapping:
id: jobid
remote_table:
name: invoices
schema: public
type: create_object_relationship
- args:
name: invoices
table:
name: vendors
schema: public
using:
foreign_key_constraint_on:
column: vendorid
table:
name: invoices
schema: public
type: create_array_relationship

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: invoices
schema: public
type: drop_insert_permission

View File

@@ -0,0 +1,35 @@
- args:
permission:
allow_upsert: true
check:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- vendorid
- jobid
- date
- due_date
- exported
- exported_at
- is_credit_memo
- total
- invoice_number
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: invoices
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: invoices
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,33 @@
- args:
permission:
allow_aggregations: false
columns:
- exported
- is_credit_memo
- date
- due_date
- total
- invoice_number
- created_at
- exported_at
- updated_at
- id
- jobid
- vendorid
computed_fields: []
filter:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: invoices
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: invoices
schema: public
type: drop_update_permission

View File

@@ -0,0 +1,34 @@
- args:
permission:
columns:
- exported
- is_credit_memo
- date
- due_date
- total
- invoice_number
- created_at
- exported_at
- updated_at
- id
- jobid
- vendorid
filter:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: invoices
schema: public
type: create_update_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: DROP TABLE "public"."invoicelines";
type: run_sql

View File

@@ -0,0 +1,26 @@
- args:
cascade: false
read_only: false
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
cascade: false
read_only: false
sql: "CREATE TABLE \"public\".\"invoicelines\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"invoiceid\" uuid NOT NULL, \"line_desc\" text, \"actual_price\"
numeric NOT NULL DEFAULT 0, \"actual_cost\" numeric NOT NULL DEFAULT 0, \"cost_center\"
text NOT NULL, \"estlindid\" uuid, PRIMARY KEY (\"id\") , FOREIGN KEY (\"invoiceid\")
REFERENCES \"public\".\"invoices\"(\"id\") ON UPDATE restrict ON DELETE cascade);\nCREATE
OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS
TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\"
= NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_invoicelines_updated_at\"\nBEFORE
UPDATE ON \"public\".\"invoicelines\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_invoicelines_updated_at\" ON \"public\".\"invoicelines\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';"
type: run_sql
- args:
name: invoicelines
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,12 @@
- args:
relationship: invoice
table:
name: invoicelines
schema: public
type: drop_relationship
- args:
relationship: invoicelines
table:
name: invoices
schema: public
type: drop_relationship

View File

@@ -0,0 +1,20 @@
- args:
name: invoice
table:
name: invoicelines
schema: public
using:
foreign_key_constraint_on: invoiceid
type: create_object_relationship
- args:
name: invoicelines
table:
name: invoices
schema: public
using:
foreign_key_constraint_on:
column: invoiceid
table:
name: invoicelines
schema: public
type: create_array_relationship

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: invoicelines
schema: public
type: drop_insert_permission

View File

@@ -0,0 +1,33 @@
- args:
permission:
allow_upsert: true
check:
invoice:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- invoiceid
- line_desc
- actual_price
- actual_cost
- cost_center
- estlindid
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: invoicelines
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: invoicelines
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,31 @@
- args:
permission:
allow_aggregations: false
columns:
- actual_cost
- actual_price
- cost_center
- line_desc
- created_at
- updated_at
- estlindid
- id
- invoiceid
computed_fields: []
filter:
invoice:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: invoicelines
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: invoicelines
schema: public
type: drop_update_permission

View File

@@ -0,0 +1,32 @@
- args:
permission:
columns:
- actual_cost
- actual_price
- cost_center
- line_desc
- created_at
- updated_at
- estlindid
- id
- invoiceid
filter:
invoice:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: invoicelines
schema: public
type: create_update_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: invoicelines
schema: public
type: drop_delete_permission

View File

@@ -0,0 +1,18 @@
- args:
permission:
filter:
invoice:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: invoicelines
schema: public
type: create_delete_permission