diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 0b465c43b..83fbddc1f 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -12826,6 +12826,27 @@ + + payments + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + productionlist false @@ -14683,6 +14704,48 @@ + + created_at + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + exportedat + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + memo false @@ -14704,6 +14767,48 @@ + + payer + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + stripeid + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + transactionid false @@ -14793,6 +14898,74 @@ + + title + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + successes + + + payment + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + stripe + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + @@ -16295,6 +16468,27 @@ + + payments-all + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + productionboard false @@ -16843,6 +17037,27 @@ + + payments-all + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + productionboard false diff --git a/client/src/components/header/header.component.jsx b/client/src/components/header/header.component.jsx index cc15848af..a3bf1fdd7 100644 --- a/client/src/components/header/header.component.jsx +++ b/client/src/components/header/header.component.jsx @@ -81,7 +81,7 @@ function Header({ {bodyshop - - + mode="horizontal" + theme="dark" + className="header-main-menu" + onClick={handleMenuClick} + > + + {t("menus.header.home")} @@ -108,40 +109,41 @@ function Header({ {t("menus.header.jobs")} - }> - - + } + > + + {t("menus.header.schedule")} - - + + {t("menus.header.productionlist")} - - {t("menus.header.activejobs")} + + {t("menus.header.activejobs")} - - {t("menus.header.alljobs")} + + {t("menus.header.alljobs")} - - + + {t("menus.header.availablejobs")} - - + + {t("menus.header.owners")} - - + + {t("menus.header.vehicles")} @@ -153,21 +155,22 @@ function Header({ {t("menus.header.courtesycars")} - }> - - + } + > + + {t("menus.header.courtesycars-all")} - - + + {t("menus.header.courtesycars-contracts")} - - + + {t("menus.header.courtesycars-newcontract")} @@ -179,68 +182,75 @@ function Header({ {t("menus.header.accounting")} - }> + } + > { setPaymentContext({ actions: {}, context: {}, }); - }}> + }} + > {t("menus.header.enterpayment")} { setInvoiceEnterContext({ actions: {}, context: {}, }); - }}> + }} + > {t("menus.header.enterinvoices")} - - {t("menus.header.invoices")} + + {t("menus.header.invoices")} { setTimeTicketContext({ actions: {}, context: {}, }); - }}> + }} + > {t("menus.header.entertimeticket")} - - + + {t("menus.header.accounting-receivables")} - - + + {t("menus.header.accounting-payables")} + + {t("menus.header.payments")} + - - {t("menus.header.shop_config")} + + {t("menus.header.shop_config")} - - + + {t("menus.header.shop_templates")} - - + + {t("menus.header.shop_vendors")} - - {t("menus.header.shop_csi")} + + {t("menus.header.shop_csi")} - }> + } + > signOutStart()}> {t("user.actions.signout")} - + {t("menus.currentuser.profile")} @@ -280,14 +291,15 @@ function Header({ {t("menus.currentuser.languageselector")} - }> - + } + > + {t("general.languages.english")} - + {t("general.languages.french")} - + {t("general.languages.spanish")} diff --git a/client/src/components/jobs-detail-financial/jobs-detail-financial.component.jsx b/client/src/components/jobs-detail-financial/jobs-detail-financial.component.jsx index 39777ba71..a9cba967e 100644 --- a/client/src/components/jobs-detail-financial/jobs-detail-financial.component.jsx +++ b/client/src/components/jobs-detail-financial/jobs-detail-financial.component.jsx @@ -1,130 +1,204 @@ -import { Col, Form, Input, Row } from "antd"; +import { Col, Form, Input, Row, Divider } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; import JobTotalsTable from "../job-totals-table/job-totals-table.component"; import FormRow from "../layout-form-row/layout-form-row.component"; -export default function JobsDetailFinancials({ job }) { +import CurrencyFormatter from "../../utils/CurrencyFormatter"; +import { DateTimeFormatter } from "../../utils/DateFormatter"; + +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); + +const stripeTestEnv = process.env.REACT_APP_STRIPE_PUBLIC_KEY; //.includes("test"); + +export function JobsDetailFinancials({ job, bodyshop }) { const { t } = useTranslation(); + const colSpan = { + sm: { span: 24 }, + lg: { span: 12 }, + }; + return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + {job.payments.map((p, idx) => ( + + + + + + + + + ))} + +
{t("payments.fields.created_at")}{t("payments.fields.payer")}{t("payments.fields.amount")}{t("payments.fields.memo")}{t("payments.fields.transactionid")}{t("payments.fields.stripeid")}
+ {p.created_at} + {p.payer} + {p.amount} + {p.memo}{p.transactionid} + {p.stripeid ? ( + + {p.stripeid} + + ) : null} +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
); } +export default connect(mapStateToProps, null)(JobsDetailFinancials); diff --git a/client/src/components/payment-form/payment-form.component.jsx b/client/src/components/payment-form/payment-form.component.jsx index 4c8ab75a1..3bf9b224b 100644 --- a/client/src/components/payment-form/payment-form.component.jsx +++ b/client/src/components/payment-form/payment-form.component.jsx @@ -1,15 +1,14 @@ -import { Form, Input, Checkbox } from "antd"; +import { CardElement } from "@stripe/react-stripe-js"; +import { Checkbox, Form, Input } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; -import CurrencyInput from "../form-items-formatted/currency-form-item.component"; -import JobSearchSelect from "../job-search-select/job-search-select.component"; -import { CardElement } from "@stripe/react-stripe-js"; -import FormLayoutRow from "../layout-form-row/layout-form-row.component"; -import Alert from "../alert/alert.component"; - import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; +import Alert from "../alert/alert.component"; +import CurrencyInput from "../form-items-formatted/currency-form-item.component"; +import JobSearchSelect from "../job-search-select/job-search-select.component"; + const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, }); diff --git a/client/src/components/payment-modal/payment-modal.container.jsx b/client/src/components/payment-modal/payment-modal.container.jsx index 7d4e4a76d..d3a4bd4d9 100644 --- a/client/src/components/payment-modal/payment-modal.container.jsx +++ b/client/src/components/payment-modal/payment-modal.container.jsx @@ -47,9 +47,10 @@ function InvoiceEnterModalContainer({ const cardValid = !!!stripeState.error && stripeState.cardComplete; const handleFinish = async (values) => { - if (!cardValid) return; + const { useStripe, ...paymentObj } = values; + if (useStripe && !cardValid) return; - if (!stripe || !elements) { + if ((useStripe && !stripe) || !elements) { // Stripe.js has not yet loaded. // Make sure to disable form submission until Stripe.js has loaded. return; @@ -57,8 +58,6 @@ function InvoiceEnterModalContainer({ setLoading(true); - const { useStripe, ...paymentObj } = values; - try { let stripePayment; if (useStripe && bodyshop.stripe_acct_id) { diff --git a/client/src/components/payments-list-paginated/payment-list-paginated.component.jsx b/client/src/components/payments-list-paginated/payment-list-paginated.component.jsx new file mode 100644 index 000000000..a51476d8f --- /dev/null +++ b/client/src/components/payments-list-paginated/payment-list-paginated.component.jsx @@ -0,0 +1,154 @@ +import { SyncOutlined } from "@ant-design/icons"; +import { Button, Input, Table } from "antd"; +import queryString from "query-string"; +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { Link, useHistory, useLocation } from "react-router-dom"; +import CurrencyFormatter from "../../utils/CurrencyFormatter"; +import { DateTimeFormatter } from "../../utils/DateFormatter"; +import { alphaSort } from "../../utils/sorters"; + +export default function PaymentsListPaginated({ + refetch, + loading, + payments, + total, +}) { + const search = queryString.parse(useLocation().search); + const { page, sortcolumn, sortorder } = search; + const history = useHistory(); + const [state, setState] = useState({ + sortedInfo: {}, + filteredInfo: { text: "" }, + }); + + const { t } = useTranslation(); + const columns = [ + { + title: t("jobs.fields.ro_number"), + dataIndex: "ro_number", + key: "ro_number", + sorter: (a, b) => alphaSort(a.job.ro_number, b.job.ro_number), + sortOrder: sortcolumn === "ro_number" && sortorder, + render: (text, record) => ( + {record.job.ro_number} + ), + }, + { + title: t("jobs.fields.est_number"), + dataIndex: "est_number", + key: "est_number", + sorter: (a, b) => a.job.est_number - b.job.est_number, + sortOrder: sortcolumn === "est_number" && sortorder, + render: (text, record) => ( + + {record.job.est_number} + + ), + }, + { + title: t("jobs.fields.owner"), + dataIndex: "owner", + key: "owner", + ellipsis: true, + sorter: (a, b) => alphaSort(a.job.ownr_ln, b.job.ownr_ln), + sortOrder: sortcolumn === "owner" && sortorder, + render: (text, record) => { + return record.job.owner ? ( + + {`${record.job.ownr_fn || ""} ${record.job.ownr_ln || ""}`} + + ) : ( + {`${record.job.ownr_fn || ""} ${ + record.job.ownr_ln || "" + }`} + ); + }, + }, + { + title: t("payments.fields.amount"), + dataIndex: "amount", + key: "amount", + render: (text, record) => ( + {record.amount} + ), + }, + { + title: t("payments.fields.memo"), + dataIndex: "memo", + key: "memo", + }, + { + title: t("payments.fields.transactionid"), + dataIndex: "transactionid", + key: "transactionid", + }, + { + title: t("payments.fields.stripeid"), + dataIndex: "stripeid", + key: "stripeid", + }, + { + title: t("payments.fields.created_at"), + dataIndex: "created_at", + key: "created_at", + render: (text, record) => ( + {record.created_at} + ), + }, + { + title: t("payments.fields.exportedat"), + dataIndex: "exportedat", + key: "exportedat", + render: (text, record) => ( + {record.exportedat} + ), + }, + ]; + + const handleTableChange = (pagination, filters, sorter) => { + setState({ ...state, filteredInfo: filters, sortedInfo: sorter }); + search.page = pagination.current; + search.sortcolumn = sorter.columnKey; + search.sortorder = sorter.order; + history.push({ search: queryString.stringify(search) }); + }; + + return ( +
+ { + return ( +
+ + { + search.search = value; + history.push({ search: queryString.stringify(search) }); + }} + enterButton + /> +
+ ); + }} + /> + + ); +} diff --git a/client/src/components/schedule-event/schedule-event.component.jsx b/client/src/components/schedule-event/schedule-event.component.jsx index 19a537b6c..e1c024a8d 100644 --- a/client/src/components/schedule-event/schedule-event.component.jsx +++ b/client/src/components/schedule-event/schedule-event.component.jsx @@ -1,9 +1,9 @@ +import { Button, Popover } from "antd"; import React from "react"; -import { Popover, Button, Progress } from "antd"; +import { useTranslation } from "react-i18next"; +import { Link } from "react-router-dom"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; import PhoneFormatter from "../../utils/PhoneFormatter"; -import { Link } from "react-router-dom"; -import { useTranslation } from "react-i18next"; import DataLabel from "../data-label/data-label.component"; export default function ScheduleEventComponent({ event, handleCancel }) { diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 778beb580..05073307b 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -269,6 +269,15 @@ export const GET_JOB_BY_PK = gql` lbr_amt op_code_desc } + payments { + id + amount + payer + created_at + stripeid + transactionid + memo + } cccontracts { id status diff --git a/client/src/graphql/payments.queries.js b/client/src/graphql/payments.queries.js index 0a4a83dd2..d7b94263d 100644 --- a/client/src/graphql/payments.queries.js +++ b/client/src/graphql/payments.queries.js @@ -9,3 +9,42 @@ export const INSERT_NEW_PAYMENT = gql` } } `; + +export const QUERY_ALL_PAYMENTS_PAGINATED = gql` + query QUERY_ALL_PAYMENTS_PAGINATED( + $search: String + $offset: Int + $limit: Int + $order: [payments_order_by!]! + ) { + search_payments( + args: { search: $search } + offset: $offset + limit: $limit + order_by: $order + ) { + id + created_at + jobid + job { + id + ro_number + est_number + ownr_fn + ownr_ln + ownr_co_nm + } + transactionid + memo + amount + stripeid + exportedat + stripeid + } + search_payments_aggregate(args: { search: $search }) { + aggregate { + count(distinct: true) + } + } + } +`; diff --git a/client/src/pages/manage/manage.page.component.jsx b/client/src/pages/manage/manage.page.component.jsx index e380ec04d..540cc5110 100644 --- a/client/src/pages/manage/manage.page.component.jsx +++ b/client/src/pages/manage/manage.page.component.jsx @@ -109,6 +109,9 @@ const JobsClose = lazy(() => import("../jobs-close/jobs-close.container")); const ShopCsiPageContainer = lazy(() => import("../shop-csi/shop-csi.container.page") ); +const PaymentsAll = lazy(() => + import("../payments-all/payments-all.container.page") +); const { Content } = Layout; @@ -134,11 +137,11 @@ export function Manage({ match, conflict }) { }, [t]); return ( - + - + {conflict ? ( @@ -147,7 +150,8 @@ export function Manage({ match, conflict }) { - }> + } + > @@ -296,6 +300,11 @@ export function Manage({ match, conflict }) { path={`${match.path}/accounting/payables`} component={AccountingPayables} /> + )} diff --git a/client/src/pages/payments-all/payments-all.container.page.jsx b/client/src/pages/payments-all/payments-all.container.page.jsx new file mode 100644 index 000000000..4caba08df --- /dev/null +++ b/client/src/pages/payments-all/payments-all.container.page.jsx @@ -0,0 +1,68 @@ +import { useQuery } from "@apollo/react-hooks"; +import queryString from "query-string"; +import React, { useEffect } from "react"; +import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { useLocation } from "react-router-dom"; +import { createStructuredSelector } from "reselect"; +import AlertComponent from "../../components/alert/alert.component"; +import PaymentsListPaginated from "../../components/payments-list-paginated/payment-list-paginated.component"; +import { QUERY_ALL_PAYMENTS_PAGINATED } from "../../graphql/payments.queries"; +import { setBreadcrumbs } from "../../redux/application/application.actions"; +import { selectBodyshop } from "../../redux/user/user.selectors"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); + +const mapDispatchToProps = (dispatch) => ({ + setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)), +}); + +export function AllJobs({ bodyshop, setBreadcrumbs }) { + const searchParams = queryString.parse(useLocation().search); + const { page, sortcolumn, sortorder, search } = searchParams; + + const { loading, error, data, refetch } = useQuery( + QUERY_ALL_PAYMENTS_PAGINATED, + { + variables: { + search: search || "", + offset: page ? (page - 1) * 25 : 0, + limit: 25, + order: [ + { + [sortcolumn || "created_at"]: sortorder + ? sortorder === "descend" + ? "desc" + : "asc" + : "desc", + }, + ], + }, + } + ); + const { t } = useTranslation(); + + useEffect(() => { + document.title = t("titles.payments-all"); + setBreadcrumbs([ + { link: "/manage/payments", label: t("titles.bc.payments-all") }, + ]); + }, [t, setBreadcrumbs]); + + if (error) return ; + return ( +
+ +
+ ); +} + +export default connect(mapStateToProps, mapDispatchToProps)(AllJobs); diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 7515edbeb..92c6b5948 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -779,6 +779,7 @@ "invoices": "Invoices", "jobs": "Jobs", "owners": "Owners", + "payments": "All Payments", "productionlist": "Production - List", "schedule": "Schedule", "shop": "My Shop", @@ -915,13 +916,22 @@ "payments": { "fields": { "amount": "Amount", + "created_at": "Created At", + "exportedat": "Exported At", "memo": "Memo", - "transactionid": "Transaction Reference" + "payer": "Payer", + "stripeid": "Stripe ID", + "transactionid": "Transaction ID" }, "labels": { "electronicpayment": "Use Electronic Payment Processing?", "new": "New Payment", - "signup": "Please contact support to sign up for electronic payments." + "signup": "Please contact support to sign up for electronic payments.", + "title": "Payments" + }, + "successes": { + "payment": "Payment created successfully. ", + "stripe": "Credit card transaction charged successfully." } }, "printcenter": { @@ -1027,6 +1037,7 @@ "jobs-new": "Create a New Job", "owner-detail": "{{name}}", "owners": "Owners", + "payments-all": "All Payments", "productionboard": "Production Board", "productionlist": "Production - List", "schedule": "Schedule", @@ -1054,6 +1065,7 @@ "manageroot": "Home | $t(titles.app)", "owners": "All Owners | $t(titles.app)", "owners-detail": "{{name}} | $t(titles.app)", + "payments-all": "Payments | $t(titles.app)", "productionboard": "Production - Board", "productionlist": "Production - List View | $t(titles.app)", "profile": "My Profile | $t(titles.app)", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 87da31b34..9a49572c2 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -779,6 +779,7 @@ "invoices": "", "jobs": "Trabajos", "owners": "propietarios", + "payments": "", "productionlist": "", "schedule": "Programar", "shop": "Mi tienda", @@ -915,13 +916,22 @@ "payments": { "fields": { "amount": "", + "created_at": "", + "exportedat": "", "memo": "", + "payer": "", + "stripeid": "", "transactionid": "" }, "labels": { "electronicpayment": "", "new": "", - "signup": "" + "signup": "", + "title": "" + }, + "successes": { + "payment": "", + "stripe": "" } }, "printcenter": { @@ -1027,6 +1037,7 @@ "jobs-new": "", "owner-detail": "", "owners": "", + "payments-all": "", "productionboard": "", "productionlist": "", "schedule": "", @@ -1054,6 +1065,7 @@ "manageroot": "Casa | $t(titles.app)", "owners": "Todos los propietarios | $t(titles.app)", "owners-detail": "", + "payments-all": "", "productionboard": "", "productionlist": "", "profile": "Mi perfil | $t(titles.app)", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index e5220c596..c98a1917d 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -779,6 +779,7 @@ "invoices": "", "jobs": "Emplois", "owners": "Propriétaires", + "payments": "", "productionlist": "", "schedule": "Programme", "shop": "Mon magasin", @@ -915,13 +916,22 @@ "payments": { "fields": { "amount": "", + "created_at": "", + "exportedat": "", "memo": "", + "payer": "", + "stripeid": "", "transactionid": "" }, "labels": { "electronicpayment": "", "new": "", - "signup": "" + "signup": "", + "title": "" + }, + "successes": { + "payment": "", + "stripe": "" } }, "printcenter": { @@ -1027,6 +1037,7 @@ "jobs-new": "", "owner-detail": "", "owners": "", + "payments-all": "", "productionboard": "", "productionlist": "", "schedule": "", @@ -1054,6 +1065,7 @@ "manageroot": "Accueil | $t(titles.app)", "owners": "Tous les propriétaires | $t(titles.app)", "owners-detail": "", + "payments-all": "", "productionboard": "", "productionlist": "", "profile": "Mon profil | $t(titles.app)", diff --git a/client/src/utils/DateFormatter.jsx b/client/src/utils/DateFormatter.jsx index 07a41d7b4..1989c53ea 100644 --- a/client/src/utils/DateFormatter.jsx +++ b/client/src/utils/DateFormatter.jsx @@ -2,9 +2,13 @@ import React from "react"; import Moment from "react-moment"; export function DateFormatter(props) { - return {props.children || null}; + return props.children ? ( + {props.children} + ) : null; } export function DateTimeFormatter(props) { - return {props.children || ""}; + return props.children ? ( + {props.children} + ) : null; } diff --git a/hasura/migrations/1592324594982_alter_table_public_payments_add_column_payer/down.yaml b/hasura/migrations/1592324594982_alter_table_public_payments_add_column_payer/down.yaml new file mode 100644 index 000000000..8ead0dc0d --- /dev/null +++ b/hasura/migrations/1592324594982_alter_table_public_payments_add_column_payer/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."payments" DROP COLUMN "payer"; + type: run_sql diff --git a/hasura/migrations/1592324594982_alter_table_public_payments_add_column_payer/up.yaml b/hasura/migrations/1592324594982_alter_table_public_payments_add_column_payer/up.yaml new file mode 100644 index 000000000..968dd3294 --- /dev/null +++ b/hasura/migrations/1592324594982_alter_table_public_payments_add_column_payer/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."payments" ADD COLUMN "payer" text NULL; + type: run_sql diff --git a/hasura/migrations/1592324603137_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1592324603137_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..5d9f8f5a0 --- /dev/null +++ b/hasura/migrations/1592324603137_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,36 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_insert_permission +- args: + permission: + check: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - id + - created_at + - updated_at + - jobid + - amount + - transactionid + - memo + - stripeid + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: payments + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1592324603137_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1592324603137_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..248a04f37 --- /dev/null +++ b/hasura/migrations/1592324603137_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_insert_permission +- args: + permission: + check: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - amount + - created_at + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: payments + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1592324618856_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1592324618856_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..87b993f56 --- /dev/null +++ b/hasura/migrations/1592324618856_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,34 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - amount + - memo + - stripeid + - transactionid + - created_at + - updated_at + - id + - jobid + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: payments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1592324618856_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1592324618856_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..d7f198395 --- /dev/null +++ b/hasura/migrations/1592324618856_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,35 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - amount + - created_at + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: payments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1592324625348_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1592324625348_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..8bad2eabf --- /dev/null +++ b/hasura/migrations/1592324625348_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,36 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - amount + - memo + - stripeid + - transactionid + - created_at + - updated_at + - id + - jobid + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: payments + schema: public + type: create_update_permission diff --git a/hasura/migrations/1592324625348_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1592324625348_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..332aef813 --- /dev/null +++ b/hasura/migrations/1592324625348_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - amount + - created_at + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: payments + schema: public + type: create_update_permission diff --git a/hasura/migrations/1592324679227_run_sql_migration/down.yaml b/hasura/migrations/1592324679227_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1592324679227_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1592324679227_run_sql_migration/up.yaml b/hasura/migrations/1592324679227_run_sql_migration/up.yaml new file mode 100644 index 000000000..6215879b1 --- /dev/null +++ b/hasura/migrations/1592324679227_run_sql_migration/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: true + read_only: false + sql: CREATE INDEX idx_payments_payer ON payments USING GIN (payer gin_trgm_ops); + type: run_sql diff --git a/hasura/migrations/1592325045380_run_sql_migration/down.yaml b/hasura/migrations/1592325045380_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1592325045380_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1592325045380_run_sql_migration/up.yaml b/hasura/migrations/1592325045380_run_sql_migration/up.yaml new file mode 100644 index 000000000..35ecb17d1 --- /dev/null +++ b/hasura/migrations/1592325045380_run_sql_migration/up.yaml @@ -0,0 +1,12 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE FUNCTION public.search_payments(search text)\n RETURNS + SETOF payments\n LANGUAGE plpgsql\n STABLE\nAS $function$\n\nBEGIN\n if search + = '' then\n return query select * from payments ;\n else \n return query + SELECT\n *\nFROM\n payments\nWHERE\n search <% (payer) ;\n end if;\n\n\tEND\n$function$;" + type: run_sql +- args: + name: search_payments + schema: public + type: track_function diff --git a/hasura/migrations/1592325133932_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1592325133932_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..d7f198395 --- /dev/null +++ b/hasura/migrations/1592325133932_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,35 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - amount + - created_at + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: payments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1592325133932_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1592325133932_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..7485e333c --- /dev/null +++ b/hasura/migrations/1592325133932_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,35 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - amount + - created_at + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: payments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1592325262313_run_sql_migration/down.yaml b/hasura/migrations/1592325262313_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1592325262313_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1592325262313_run_sql_migration/up.yaml b/hasura/migrations/1592325262313_run_sql_migration/up.yaml new file mode 100644 index 000000000..5d464f7e1 --- /dev/null +++ b/hasura/migrations/1592325262313_run_sql_migration/up.yaml @@ -0,0 +1,7 @@ +- args: + cascade: true + read_only: false + sql: |- + CREATE INDEX idx_payments_memo ON payments USING GIN (memo gin_trgm_ops); + CREATE INDEX idx_payments_txnid ON payments USING GIN (transactionid gin_trgm_ops); + type: run_sql diff --git a/hasura/migrations/1592325288329_run_sql_migration/down.yaml b/hasura/migrations/1592325288329_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1592325288329_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1592325288329_run_sql_migration/up.yaml b/hasura/migrations/1592325288329_run_sql_migration/up.yaml new file mode 100644 index 000000000..4439c7f6f --- /dev/null +++ b/hasura/migrations/1592325288329_run_sql_migration/up.yaml @@ -0,0 +1,9 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE FUNCTION public.search_payments(search text)\n RETURNS + SETOF payments\n LANGUAGE plpgsql\n STABLE\nAS $function$\n\nBEGIN\n if search + = '' then\n return query select * from payments ;\n else \n return query + SELECT\n *\nFROM\n payments\nWHERE\n search <% (payer) OR\n search <% (transactionid) + OR\n search <% (memo);\n end if;\n\n\tEND\n$function$;" + type: run_sql diff --git a/hasura/migrations/1592325952533_alter_table_public_payments_add_column_exportedat/down.yaml b/hasura/migrations/1592325952533_alter_table_public_payments_add_column_exportedat/down.yaml new file mode 100644 index 000000000..101187382 --- /dev/null +++ b/hasura/migrations/1592325952533_alter_table_public_payments_add_column_exportedat/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."payments" DROP COLUMN "exportedat"; + type: run_sql diff --git a/hasura/migrations/1592325952533_alter_table_public_payments_add_column_exportedat/up.yaml b/hasura/migrations/1592325952533_alter_table_public_payments_add_column_exportedat/up.yaml new file mode 100644 index 000000000..8d48bae0a --- /dev/null +++ b/hasura/migrations/1592325952533_alter_table_public_payments_add_column_exportedat/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."payments" ADD COLUMN "exportedat" timestamptz NULL; + type: run_sql diff --git a/hasura/migrations/1592325964121_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1592325964121_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..248a04f37 --- /dev/null +++ b/hasura/migrations/1592325964121_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_insert_permission +- args: + permission: + check: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - amount + - created_at + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: payments + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1592325964121_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1592325964121_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..101107d75 --- /dev/null +++ b/hasura/migrations/1592325964121_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,38 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_insert_permission +- args: + permission: + check: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: payments + schema: public + type: create_insert_permission diff --git a/hasura/migrations/1592325969484_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1592325969484_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..7485e333c --- /dev/null +++ b/hasura/migrations/1592325969484_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,35 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - amount + - created_at + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: payments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1592325969484_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1592325969484_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..bc5c01b3a --- /dev/null +++ b/hasura/migrations/1592325969484_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,36 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: true + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + computed_fields: [] + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: payments + schema: public + type: create_select_permission diff --git a/hasura/migrations/1592325975305_update_permission_user_public_table_payments/down.yaml b/hasura/migrations/1592325975305_update_permission_user_public_table_payments/down.yaml new file mode 100644 index 000000000..332aef813 --- /dev/null +++ b/hasura/migrations/1592325975305_update_permission_user_public_table_payments/down.yaml @@ -0,0 +1,37 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - amount + - created_at + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: payments + schema: public + type: create_update_permission diff --git a/hasura/migrations/1592325975305_update_permission_user_public_table_payments/up.yaml b/hasura/migrations/1592325975305_update_permission_user_public_table_payments/up.yaml new file mode 100644 index 000000000..ca990d8e4 --- /dev/null +++ b/hasura/migrations/1592325975305_update_permission_user_public_table_payments/up.yaml @@ -0,0 +1,38 @@ +- args: + role: user + table: + name: payments + schema: public + type: drop_update_permission +- args: + permission: + columns: + - amount + - created_at + - exportedat + - id + - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at + filter: + job: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + localPresets: + - key: "" + value: "" + set: {} + role: user + table: + name: payments + schema: public + type: create_update_permission diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index c33d6373a..576eac1c7 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -3214,26 +3214,30 @@ tables: - active: _eq: true columns: - - id - - created_at - - updated_at - - jobid - amount - - transactionid + - created_at + - exportedat + - id + - jobid - memo + - payer - stripeid + - transactionid + - updated_at select_permissions: - role: user permission: columns: - amount - - memo - - stripeid - - transactionid - created_at - - updated_at + - exportedat - id - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at filter: job: bodyshop: @@ -3244,18 +3248,21 @@ tables: _eq: X-Hasura-User-Id - active: _eq: true + allow_aggregations: true update_permissions: - role: user permission: columns: - amount - - memo - - stripeid - - transactionid - created_at - - updated_at + - exportedat - id - jobid + - memo + - payer + - stripeid + - transactionid + - updated_at filter: job: bodyshop: @@ -3870,3 +3877,6 @@ functions: - function: schema: public name: search_owner +- function: + schema: public + name: search_payments