diff --git a/client/src/components/parts-order-modal/parts-order-modal.container.jsx b/client/src/components/parts-order-modal/parts-order-modal.container.jsx index 5c1f1da2a..17065d67d 100644 --- a/client/src/components/parts-order-modal/parts-order-modal.container.jsx +++ b/client/src/components/parts-order-modal/parts-order-modal.container.jsx @@ -117,13 +117,14 @@ export function PartsOrderModalContainer({ let invoiceToPost = { vendorid: bodyshop.inhousevendorid, + isinhouse: true, jobid: jobId, total: 0, - invoice_number: `${jobId}`, + invoice_number: "ih", federal_tax_rate: bodyshop.bill_tax_rates.federal_tax_rate || 0, state_tax_rate: bodyshop.bill_tax_rates.state_tax_rate || 0, local_tax_rate: bodyshop.bill_tax_rates.local_tax_rate || 0, - invoicelines: { + billlines: { data: values.parts_order_lines.data.map((p) => { return { joblineid: p.job_line_id, diff --git a/hasura/config.yaml b/hasura/config.yaml index 6794b3325..3dda55b42 100644 --- a/hasura/config.yaml +++ b/hasura/config.yaml @@ -1,2 +1,2 @@ endpoint: https://bodyshop-dev-db.herokuapp.com -#endpoint: https://db.imex.online +admin_secret: Dev-BodyShopAppBySnaptSoftware! \ No newline at end of file diff --git a/hasura/migrations/1608740311503_alter_table_public_bills_add_column_isinhouse/down.yaml b/hasura/migrations/1608740311503_alter_table_public_bills_add_column_isinhouse/down.yaml new file mode 100644 index 000000000..fc4449e03 --- /dev/null +++ b/hasura/migrations/1608740311503_alter_table_public_bills_add_column_isinhouse/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."bills" DROP COLUMN "isinhouse"; + type: run_sql diff --git a/hasura/migrations/1608740311503_alter_table_public_bills_add_column_isinhouse/up.yaml b/hasura/migrations/1608740311503_alter_table_public_bills_add_column_isinhouse/up.yaml new file mode 100644 index 000000000..ff82fb10e --- /dev/null +++ b/hasura/migrations/1608740311503_alter_table_public_bills_add_column_isinhouse/up.yaml @@ -0,0 +1,6 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."bills" ADD COLUMN "isinhouse" boolean NOT NULL DEFAULT + false; + type: run_sql diff --git a/hasura/migrations/1608740361292_update_permission_user_public_table_bills/down.yaml b/hasura/migrations/1608740361292_update_permission_user_public_table_bills/down.yaml new file mode 100644 index 000000000..c330bf854 --- /dev/null +++ b/hasura/migrations/1608740361292_update_permission_user_public_table_bills/down.yaml @@ -0,0 +1,40 @@ +- args: + role: user + table: + name: bills + schema: public + type: drop_insert_permission +- args: + permission: + check: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - created_at + - date + - due_date + - exported + - exported_at + - federal_tax_rate + - id + - invoice_number + - is_credit_memo + - jobid + - local_tax_rate + - state_tax_rate + - total + - updated_at + - vendorid + set: {} + role: user + table: + name: bills + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1608740361292_update_permission_user_public_table_bills/up.yaml b/hasura/migrations/1608740361292_update_permission_user_public_table_bills/up.yaml new file mode 100644 index 000000000..4ae0f86f9 --- /dev/null +++ b/hasura/migrations/1608740361292_update_permission_user_public_table_bills/up.yaml @@ -0,0 +1,41 @@ +- args: + role: user + table: + name: bills + schema: public + type: drop_insert_permission +- args: + permission: + check: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - created_at + - date + - due_date + - exported + - exported_at + - federal_tax_rate + - id + - invoice_number + - is_credit_memo + - isinhouse + - jobid + - local_tax_rate + - state_tax_rate + - total + - updated_at + - vendorid + set: {} + role: user + table: + name: bills + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1608740373347_update_permission_user_public_table_bills/down.yaml b/hasura/migrations/1608740373347_update_permission_user_public_table_bills/down.yaml new file mode 100644 index 000000000..c47a3967d --- /dev/null +++ b/hasura/migrations/1608740373347_update_permission_user_public_table_bills/down.yaml @@ -0,0 +1,41 @@ +- args: + role: user + table: + name: bills + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - created_at + - date + - due_date + - exported + - exported_at + - federal_tax_rate + - id + - invoice_number + - is_credit_memo + - jobid + - local_tax_rate + - state_tax_rate + - total + - updated_at + - vendorid + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: bills + schema: public + type: create_select_permission diff --git a/hasura/migrations/1608740373347_update_permission_user_public_table_bills/up.yaml b/hasura/migrations/1608740373347_update_permission_user_public_table_bills/up.yaml new file mode 100644 index 000000000..ebc89d0e3 --- /dev/null +++ b/hasura/migrations/1608740373347_update_permission_user_public_table_bills/up.yaml @@ -0,0 +1,42 @@ +- args: + role: user + table: + name: bills + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - created_at + - date + - due_date + - exported + - exported_at + - federal_tax_rate + - id + - invoice_number + - is_credit_memo + - isinhouse + - jobid + - local_tax_rate + - state_tax_rate + - total + - updated_at + - vendorid + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: bills + schema: public + type: create_select_permission diff --git a/hasura/migrations/1608740385538_update_permission_user_public_table_bills/down.yaml b/hasura/migrations/1608740385538_update_permission_user_public_table_bills/down.yaml new file mode 100644 index 000000000..432c2aa01 --- /dev/null +++ b/hasura/migrations/1608740385538_update_permission_user_public_table_bills/down.yaml @@ -0,0 +1,40 @@ +- args: + role: user + table: + name: bills + schema: public + type: drop_update_permission +- args: + permission: + columns: + - created_at + - date + - due_date + - exported + - exported_at + - federal_tax_rate + - id + - invoice_number + - is_credit_memo + - jobid + - local_tax_rate + - state_tax_rate + - total + - updated_at + - vendorid + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: bills + schema: public + type: create_update_permission diff --git a/hasura/migrations/1608740385538_update_permission_user_public_table_bills/up.yaml b/hasura/migrations/1608740385538_update_permission_user_public_table_bills/up.yaml new file mode 100644 index 000000000..ca0eb70d4 --- /dev/null +++ b/hasura/migrations/1608740385538_update_permission_user_public_table_bills/up.yaml @@ -0,0 +1,41 @@ +- args: + role: user + table: + name: bills + schema: public + type: drop_update_permission +- args: + permission: + columns: + - created_at + - date + - due_date + - exported + - exported_at + - federal_tax_rate + - id + - invoice_number + - is_credit_memo + - isinhouse + - jobid + - local_tax_rate + - state_tax_rate + - total + - updated_at + - vendorid + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + set: {} + role: user + table: + name: bills + schema: public + type: create_update_permission diff --git a/hasura/migrations/1608740480171_run_sql_migration/down.yaml b/hasura/migrations/1608740480171_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1608740480171_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1608740480171_run_sql_migration/up.yaml b/hasura/migrations/1608740480171_run_sql_migration/up.yaml new file mode 100644 index 000000000..7e89bac75 --- /dev/null +++ b/hasura/migrations/1608740480171_run_sql_migration/up.yaml @@ -0,0 +1,10 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE FUNCTION public.assign_ibh_number()\r\n RETURNS trigger\r\n + LANGUAGE plpgsql\r\nAS $function$\r\n begin\r\n IF NEW.isinhouse + = true and (new.invoice_number is null or new.invoice_number = '') THEN\r\n + \ UPDATE counters\r\n\tSET count = count + 1 where shopid=new.shopid + AND countertype = 'ihbnum'\r\n\tRETURNING concat(prefix,count) into new.invoice_number;\r\n\r\n + \ END IF;\r\n RETURN NEW;\r\n END;\r\n $function$\r\n;" + type: run_sql diff --git a/hasura/migrations/1608740577735_run_sql_migration/down.yaml b/hasura/migrations/1608740577735_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1608740577735_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1608740577735_run_sql_migration/up.yaml b/hasura/migrations/1608740577735_run_sql_migration/up.yaml new file mode 100644 index 000000000..310e90b0f --- /dev/null +++ b/hasura/migrations/1608740577735_run_sql_migration/up.yaml @@ -0,0 +1,6 @@ +- args: + cascade: true + read_only: false + sql: "create trigger bills_assign_ihb_num before\r\nupdate\r\n on\r\n public.bills + for each row execute procedure assign_ibh_number();" + type: run_sql diff --git a/hasura/migrations/1608740773551_run_sql_migration/down.yaml b/hasura/migrations/1608740773551_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1608740773551_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1608740773551_run_sql_migration/up.yaml b/hasura/migrations/1608740773551_run_sql_migration/up.yaml new file mode 100644 index 000000000..8e9e00f8c --- /dev/null +++ b/hasura/migrations/1608740773551_run_sql_migration/up.yaml @@ -0,0 +1,10 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE FUNCTION public.assign_ibh_number()\r\n RETURNS trigger\r\n + LANGUAGE plpgsql\r\nAS $function$\r\n begin\r\n IF NEW.isinhouse + = true and (new.invoice_number is null or new.invoice_number = 'ih') THEN\r\n + \ UPDATE counters\r\n\tSET count = count + 1 where shopid=new.shopid + AND countertype = 'ihbnum'\r\n\tRETURNING concat(prefix,count) into new.invoice_number;\r\n\r\n + \ END IF;\r\n RETURN NEW;\r\n END;\r\n $function$\r\n;" + type: run_sql diff --git a/hasura/migrations/1608741009417_run_sql_migration/down.yaml b/hasura/migrations/1608741009417_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1608741009417_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1608741009417_run_sql_migration/up.yaml b/hasura/migrations/1608741009417_run_sql_migration/up.yaml new file mode 100644 index 000000000..79fb86b36 --- /dev/null +++ b/hasura/migrations/1608741009417_run_sql_migration/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: true + read_only: false + sql: drop trigger if exists bills_assign_ihb_num on bills; + type: run_sql diff --git a/hasura/migrations/1608741053957_run_sql_migration/down.yaml b/hasura/migrations/1608741053957_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1608741053957_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1608741053957_run_sql_migration/up.yaml b/hasura/migrations/1608741053957_run_sql_migration/up.yaml new file mode 100644 index 000000000..8af751e35 --- /dev/null +++ b/hasura/migrations/1608741053957_run_sql_migration/up.yaml @@ -0,0 +1,6 @@ +- args: + cascade: true + read_only: false + sql: "create trigger bills_assign_ihbnum before\r\ninsert\r\n on\r\n public.jobs + for each row execute procedure assign_ibh_number();" + type: run_sql diff --git a/hasura/migrations/1608741063718_run_sql_migration/down.yaml b/hasura/migrations/1608741063718_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1608741063718_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1608741063718_run_sql_migration/up.yaml b/hasura/migrations/1608741063718_run_sql_migration/up.yaml new file mode 100644 index 000000000..6351a66ea --- /dev/null +++ b/hasura/migrations/1608741063718_run_sql_migration/up.yaml @@ -0,0 +1,6 @@ +- args: + cascade: true + read_only: false + sql: "create trigger bills_assign_ihbnum before\r\ninsert\r\n on\r\n public.bills + for each row execute procedure assign_ibh_number();" + type: run_sql diff --git a/hasura/migrations/1608741100308_run_sql_migration/down.yaml b/hasura/migrations/1608741100308_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1608741100308_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1608741100308_run_sql_migration/up.yaml b/hasura/migrations/1608741100308_run_sql_migration/up.yaml new file mode 100644 index 000000000..0e54aaa9e --- /dev/null +++ b/hasura/migrations/1608741100308_run_sql_migration/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: true + read_only: false + sql: drop trigger if exists bills_assign_ihbnum on jobs; + type: run_sql diff --git a/hasura/migrations/1608741387779_run_sql_migration/down.yaml b/hasura/migrations/1608741387779_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1608741387779_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1608741387779_run_sql_migration/up.yaml b/hasura/migrations/1608741387779_run_sql_migration/up.yaml new file mode 100644 index 000000000..e529f741c --- /dev/null +++ b/hasura/migrations/1608741387779_run_sql_migration/up.yaml @@ -0,0 +1,11 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE FUNCTION public.assign_ibh_number()\r\n RETURNS trigger\r\n + LANGUAGE plpgsql\r\nAS $function$\r\n begin\r\n IF NEW.isinhouse + = true and (new.invoice_number is null or new.invoice_number = '') THEN\r\n + \ UPDATE counters\r\n\tSET count = count + 1\r\n\tfrom jobs\r\n\twhere + jobs.id=new.jobid and counters.shopid = jobs.shopid AND countertype = 'ihbnum'\r\n\tRETURNING + concat(prefix,count) into new.invoice_number;\r\n\r\n END IF;\r\n RETURN + NEW;\r\n END;\r\n $function$\r\n;" + type: run_sql diff --git a/hasura/migrations/1608741701614_run_sql_migration/down.yaml b/hasura/migrations/1608741701614_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1608741701614_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1608741701614_run_sql_migration/up.yaml b/hasura/migrations/1608741701614_run_sql_migration/up.yaml new file mode 100644 index 000000000..699edcff7 --- /dev/null +++ b/hasura/migrations/1608741701614_run_sql_migration/up.yaml @@ -0,0 +1,11 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE FUNCTION public.assign_ibh_number()\r\n RETURNS trigger\r\n + LANGUAGE plpgsql\r\nAS $function$\r\n begin\r\n IF NEW.isinhouse + = true and (new.invoice_number is null or new.invoice_number = '') THEN\r\n + \ UPDATE counters\r\n\tSET count = count + 1\r\n\tfrom bodyshops \r\n\twhere + bodyshops.id = (select shopid from jobs where jobs.id = new.jobid)\r\n\tAND + countertype = 'ihbnum'\r\n\tRETURNING concat(prefix,count) into new.invoice_number;\r\n\r\n + \ END IF;\r\n RETURN NEW;\r\n END;\r\n $function$\r\n;" + type: run_sql diff --git a/hasura/migrations/1608741738380_run_sql_migration/down.yaml b/hasura/migrations/1608741738380_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1608741738380_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1608741738380_run_sql_migration/up.yaml b/hasura/migrations/1608741738380_run_sql_migration/up.yaml new file mode 100644 index 000000000..9456d1abc --- /dev/null +++ b/hasura/migrations/1608741738380_run_sql_migration/up.yaml @@ -0,0 +1,11 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE FUNCTION public.assign_ibh_number()\r\n RETURNS trigger\r\n + LANGUAGE plpgsql\r\nAS $function$\r\n begin\r\n IF NEW.isinhouse + = true and (new.invoice_number is null or new.invoice_number = 'ih') THEN\r\n + \ UPDATE counters\r\n\tSET count = count + 1\r\n\tfrom bodyshops \r\n\twhere + bodyshops.id = (select shopid from jobs where jobs.id = new.jobid)\r\n\tAND + countertype = 'ihbnum'\r\n\tRETURNING concat(prefix,count) into new.invoice_number;\r\n\r\n + \ END IF;\r\n RETURN NEW;\r\n END;\r\n $function$\r\n;" + type: run_sql diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index 2a64644be..7b5fd15f1 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -509,6 +509,7 @@ tables: - id - invoice_number - is_credit_memo + - isinhouse - jobid - local_tax_rate - state_tax_rate @@ -528,6 +529,7 @@ tables: - id - invoice_number - is_credit_memo + - isinhouse - jobid - local_tax_rate - state_tax_rate @@ -558,6 +560,7 @@ tables: - id - invoice_number - is_credit_memo + - isinhouse - jobid - local_tax_rate - state_tax_rate