From 522dc070587ec2b9a72327ffe343f1b4ce4389e3 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 5 May 2020 12:15:25 -0700 Subject: [PATCH] BOD-63 added tax fields to form + schema for track tax on an item level --- bodyshop_translations.babel | 126 ++++++++++++++++++ .../invoice-detail-edit.container.jsx | 3 +- .../invoice-enter-modal.container.jsx | 11 +- .../invoice-form/invoice-form.component.jsx | 47 +++++++ .../invoice-form.lines.component.jsx | 29 +++- .../invoice-line-search-select.component.jsx | 4 +- .../shop-info/shop-info.component.jsx | 20 ++- client/src/graphql/bodyshop.queries.js | 2 + client/src/graphql/invoices.queries.js | 1 + client/src/translations/en_us/common.json | 6 + client/src/translations/es/common.json | 6 + client/src/translations/fr/common.json | 6 + .../down.yaml | 5 + .../up.yaml | 6 + .../down.yaml | 5 + .../up.yaml | 6 + .../down.yaml | 5 + .../up.yaml | 6 + .../down.yaml | 40 ++++++ .../up.yaml | 43 ++++++ .../down.yaml | 38 ++++++ .../up.yaml | 41 ++++++ .../down.yaml | 40 ++++++ .../up.yaml | 43 ++++++ .../down.yaml | 5 + .../up.yaml | 5 + .../down.yaml | 47 +++++++ .../up.yaml | 48 +++++++ .../down.yaml | 45 +++++++ .../up.yaml | 46 +++++++ .../down.yaml | 5 + .../up.yaml | 5 + .../down.yaml | 38 ++++++ .../up.yaml | 39 ++++++ .../down.yaml | 36 +++++ .../up.yaml | 37 +++++ .../down.yaml | 38 ++++++ .../up.yaml | 39 ++++++ 38 files changed, 963 insertions(+), 9 deletions(-) create mode 100644 hasura/migrations/1588704131761_alter_table_public_invoices_add_column_federal_tax_rate/down.yaml create mode 100644 hasura/migrations/1588704131761_alter_table_public_invoices_add_column_federal_tax_rate/up.yaml create mode 100644 hasura/migrations/1588704142534_alter_table_public_invoices_add_column_state_tax_rate/down.yaml create mode 100644 hasura/migrations/1588704142534_alter_table_public_invoices_add_column_state_tax_rate/up.yaml create mode 100644 hasura/migrations/1588704154625_alter_table_public_invoices_add_column_local_tax_rate/down.yaml create mode 100644 hasura/migrations/1588704154625_alter_table_public_invoices_add_column_local_tax_rate/up.yaml create mode 100644 hasura/migrations/1588704166538_update_permission_user_public_table_invoices/down.yaml create mode 100644 hasura/migrations/1588704166538_update_permission_user_public_table_invoices/up.yaml create mode 100644 hasura/migrations/1588704173695_update_permission_user_public_table_invoices/down.yaml create mode 100644 hasura/migrations/1588704173695_update_permission_user_public_table_invoices/up.yaml create mode 100644 hasura/migrations/1588704180439_update_permission_user_public_table_invoices/down.yaml create mode 100644 hasura/migrations/1588704180439_update_permission_user_public_table_invoices/up.yaml create mode 100644 hasura/migrations/1588704900361_alter_table_public_bodyshops_add_column_invoice_tax_rates/down.yaml create mode 100644 hasura/migrations/1588704900361_alter_table_public_bodyshops_add_column_invoice_tax_rates/up.yaml create mode 100644 hasura/migrations/1588704928185_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1588704928185_update_permission_user_public_table_bodyshops/up.yaml create mode 100644 hasura/migrations/1588704935620_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1588704935620_update_permission_user_public_table_bodyshops/up.yaml create mode 100644 hasura/migrations/1588705546595_alter_table_public_invoicelines_add_column_applicable_taxes/down.yaml create mode 100644 hasura/migrations/1588705546595_alter_table_public_invoicelines_add_column_applicable_taxes/up.yaml create mode 100644 hasura/migrations/1588705553835_update_permission_user_public_table_invoicelines/down.yaml create mode 100644 hasura/migrations/1588705553835_update_permission_user_public_table_invoicelines/up.yaml create mode 100644 hasura/migrations/1588705558916_update_permission_user_public_table_invoicelines/down.yaml create mode 100644 hasura/migrations/1588705558916_update_permission_user_public_table_invoicelines/up.yaml create mode 100644 hasura/migrations/1588705564365_update_permission_user_public_table_invoicelines/down.yaml create mode 100644 hasura/migrations/1588705564365_update_permission_user_public_table_invoicelines/up.yaml diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 64e8faa9d..fa49e0b22 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -959,6 +959,69 @@ + + invoice_federal_tax_rate + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + invoice_local_tax_rate + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + invoice_state_tax_rate + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + logo_img_path false @@ -5074,6 +5137,27 @@ + + federal_tax_rate + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + invoice_number false @@ -5116,6 +5200,27 @@ + + local_tax_rate + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + ro_number false @@ -5137,6 +5242,27 @@ + + state_tax_rate + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + total false diff --git a/client/src/components/invoice-detail-edit/invoice-detail-edit.container.jsx b/client/src/components/invoice-detail-edit/invoice-detail-edit.container.jsx index 1799e23fc..32add3dc6 100644 --- a/client/src/components/invoice-detail-edit/invoice-detail-edit.container.jsx +++ b/client/src/components/invoice-detail-edit/invoice-detail-edit.container.jsx @@ -3,7 +3,6 @@ import { Form } from "antd"; import moment from "moment"; 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"; @@ -19,7 +18,7 @@ const mapStateToProps = createStructuredSelector({ export function InvoiceDetailEditContainer({ bodyshop }) { const search = queryString.parse(useLocation().search); - const { t } = useTranslation(); + const [form] = Form.useForm(); const { loading, error, data } = useQuery(QUERY_INVOICE_BY_PK, { diff --git a/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx b/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx index bb8b7ab8c..f549702cb 100644 --- a/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx +++ b/client/src/components/invoice-enter-modal/invoice-enter-modal.container.jsx @@ -6,17 +6,23 @@ import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { INSERT_NEW_INVOICE } from "../../graphql/invoices.queries"; import { toggleModalVisible } from "../../redux/modals/modals.actions"; +import { selectBodyshop } from "../../redux/user/user.selectors"; import { selectInvoiceEnterModal } from "../../redux/modals/modals.selectors"; import InvoiceFormContainer from "../invoice-form/invoice-form.container"; const mapStateToProps = createStructuredSelector({ invoiceEnterModal: selectInvoiceEnterModal, + bodyshop: selectBodyshop, }); const mapDispatchToProps = (dispatch) => ({ toggleModalVisible: () => dispatch(toggleModalVisible("invoiceEnter")), }); -function InvoiceEnterModalContainer({ invoiceEnterModal, toggleModalVisible }) { +function InvoiceEnterModalContainer({ + invoiceEnterModal, + toggleModalVisible, + bodyshop, +}) { const [form] = Form.useForm(); const { t } = useTranslation(); const [enterAgain, setEnterAgain] = useState(false); @@ -113,6 +119,9 @@ function InvoiceEnterModalContainer({ invoiceEnterModal, toggleModalVisible }) { (invoiceEnterModal.context.job && invoiceEnterModal.context.job.id) || null, + federal_tax_rate: bodyshop.invoice_tax_rates.federal_tax_rate || 0, + state_tax_rate: bodyshop.invoice_tax_rates.state_tax_rate || 0, + local_tax_rate: bodyshop.invoice_tax_rates.local_tax_rate || 0, }} > diff --git a/client/src/components/invoice-form/invoice-form.component.jsx b/client/src/components/invoice-form/invoice-form.component.jsx index 76b171f41..9f0d3e800 100644 --- a/client/src/components/invoice-form/invoice-form.component.jsx +++ b/client/src/components/invoice-form/invoice-form.component.jsx @@ -6,6 +6,7 @@ import CurrencyInput from "../form-items-formatted/currency-form-item.component" import JobSearchSelect from "../job-search-select/job-search-select.component"; import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component"; import InvoiceFormLines from "./invoice-form.lines.component"; +import Dinero from "dinero.js"; export default function InvoiceFormComponent({ form, @@ -107,6 +108,42 @@ export default function InvoiceFormComponent({ > + + + + + + + + + + + {() => { + return ( +
+ {JSON.stringify(form.getFieldsValue(["invoicelines", "total"]))} +
+ ); + }} +
+