Extended responsibility center config + added individual invoice line generation. BOD-83
This commit is contained in:
@@ -1085,6 +1085,48 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>responsibilitycenter_accountdesc</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>responsibilitycenter_accountitem</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>responsibilitycenter_accountname</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -1127,9 +1169,72 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>responsibilitycenter_rate</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<folder_node>
|
||||
<name>responsibilitycenters</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>ap</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>ar</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>atp</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
@@ -16,10 +16,6 @@ export default connect(
|
||||
mapDispatchToProps
|
||||
)(function Test({ bodyshop }) {
|
||||
const handle = async () => {
|
||||
console.log(
|
||||
"await auth.currentUser.getIdToken(true)",
|
||||
await auth.currentUser.getIdToken(true)
|
||||
);
|
||||
const response = await axios.post(
|
||||
"/accounting/iif/receivables",
|
||||
{ jobId: "661dd1d5-bf06-426f-8bd2-bd9e41de8eb1" },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DeleteFilled } from "@ant-design/icons";
|
||||
import { Button, Form, Input, Select } from "antd";
|
||||
import { Button, Form, Input, Select, InputNumber } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
@@ -100,6 +100,38 @@ export default function ShopInfoResponsibilityCenterComponent({ form }) {
|
||||
>
|
||||
<Input onBlur={handleBlur} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
style={{ padding: 0, margin: 2 }}
|
||||
label={t(
|
||||
"bodyshop.fields.responsibilitycenter_accountdesc"
|
||||
)}
|
||||
key={`${index}accountdesc`}
|
||||
name={[field.name, "accountdesc"]}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input onBlur={handleBlur} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
style={{ padding: 0, margin: 2 }}
|
||||
label={t(
|
||||
"bodyshop.fields.responsibilitycenter_accountitem"
|
||||
)}
|
||||
key={`${index}accountitem`}
|
||||
name={[field.name, "accountitem"]}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input onBlur={handleBlur} />
|
||||
</Form.Item>
|
||||
<DeleteFilled
|
||||
onClick={() => {
|
||||
remove(field.name);
|
||||
@@ -179,6 +211,38 @@ export default function ShopInfoResponsibilityCenterComponent({ form }) {
|
||||
>
|
||||
<Input onBlur={handleBlur} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
style={{ padding: 0, margin: 2 }}
|
||||
label={t(
|
||||
"bodyshop.fields.responsibilitycenter_accountdesc"
|
||||
)}
|
||||
key={`${index}accountdesc`}
|
||||
name={[field.name, "accountdesc"]}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input onBlur={handleBlur} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
style={{ padding: 0, margin: 2 }}
|
||||
label={t(
|
||||
"bodyshop.fields.responsibilitycenter_accountitem"
|
||||
)}
|
||||
key={`${index}accountitem`}
|
||||
name={[field.name, "accountitem"]}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input onBlur={handleBlur} />
|
||||
</Form.Item>
|
||||
<DeleteFilled
|
||||
onClick={() => {
|
||||
remove(field.name);
|
||||
@@ -1028,7 +1092,7 @@ export default function ShopInfoResponsibilityCenterComponent({ form }) {
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"federal",
|
||||
"account_name",
|
||||
"accountname",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
@@ -1045,108 +1109,371 @@ export default function ShopInfoResponsibilityCenterComponent({ form }) {
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"federal",
|
||||
"account_number",
|
||||
"accountnumber",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountdesc")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"federal",
|
||||
"accountdesc",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountitem")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"federal",
|
||||
"accountitem",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_rate")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "taxes", "federal", "rate"]}
|
||||
>
|
||||
<InputNumber precision={2} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
<div style={{ display: "flex" }}>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenters.state_tax")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "taxes", "state", "name"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountnumber")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"state",
|
||||
"accountname",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountname")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"state",
|
||||
"accountnumber",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountdesc")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"state",
|
||||
"accountdesc",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountitem")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"state",
|
||||
"accountitem",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_rate")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "taxes", "state", "rate"]}
|
||||
>
|
||||
<InputNumber precision={2} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
<div style={{ display: "flex" }}>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenters.local_tax")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "taxes", "local", "name"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountnumber")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"local",
|
||||
"accountname",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountname")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"local",
|
||||
"accountnumber",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountdesc")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"local",
|
||||
"accountdesc",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountitem")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"local",
|
||||
"accountitem",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_rate")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "taxes", "local", "rate"]}
|
||||
>
|
||||
<InputNumber precision={2} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div style={{ display: "flex" }}>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenters.ar")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "ar", "name"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountnumber")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "ar", "accountname"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountname")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "ar", "accountnumber"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountdesc")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "ar", "accountdesc"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountitem")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "ar", "accountitem"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</div>
|
||||
<div style={{ display: "flex" }}>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenters.state_tax")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "taxes", "state", "name"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountnumber")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"state",
|
||||
"account_name",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountname")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"state",
|
||||
"account_number",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</div>
|
||||
<div style={{ display: "flex" }}>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenters.local_tax")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "taxes", "local", "name"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountnumber")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"local",
|
||||
"account_name",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountname")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={[
|
||||
"md_responsibility_centers",
|
||||
"taxes",
|
||||
"local",
|
||||
"account_number",
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</div>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenters.ar")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "ap", "name"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountnumber")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "ap", "accountname"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountname")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "ap", "accountnumber"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountdesc")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "ap", "accountdesc"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.responsibilitycenter_accountitem")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_responsibility_centers", "ap", "accountitem"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -140,7 +140,7 @@ export function* checkInstanceIdSaga({ payload: uid }) {
|
||||
} catch (error) {
|
||||
console.log("error", error);
|
||||
//TODO error handling
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function* onSignInSuccess() {
|
||||
|
||||
@@ -86,9 +86,14 @@
|
||||
"invoice_state_tax_rate": "Invoices - State Tax Rate %",
|
||||
"logo_img_path": "Shop Logo",
|
||||
"responsibilitycenter": "Responsibility Center",
|
||||
"responsibilitycenter_accountdesc": "Account Description",
|
||||
"responsibilitycenter_accountitem": "Item",
|
||||
"responsibilitycenter_accountname": "Account Name",
|
||||
"responsibilitycenter_accountnumber": "Account Number",
|
||||
"responsibilitycenter_rate": "Rate",
|
||||
"responsibilitycenters": {
|
||||
"ap": "Accounts Payable",
|
||||
"ar": "Accounts Receivable",
|
||||
"atp": "ATP",
|
||||
"federal_tax": "Federal Tax",
|
||||
"lab": "Body",
|
||||
|
||||
@@ -86,9 +86,14 @@
|
||||
"invoice_state_tax_rate": "",
|
||||
"logo_img_path": "",
|
||||
"responsibilitycenter": "",
|
||||
"responsibilitycenter_accountdesc": "",
|
||||
"responsibilitycenter_accountitem": "",
|
||||
"responsibilitycenter_accountname": "",
|
||||
"responsibilitycenter_accountnumber": "",
|
||||
"responsibilitycenter_rate": "",
|
||||
"responsibilitycenters": {
|
||||
"ap": "",
|
||||
"ar": "",
|
||||
"atp": "",
|
||||
"federal_tax": "",
|
||||
"lab": "",
|
||||
|
||||
@@ -86,9 +86,14 @@
|
||||
"invoice_state_tax_rate": "",
|
||||
"logo_img_path": "",
|
||||
"responsibilitycenter": "",
|
||||
"responsibilitycenter_accountdesc": "",
|
||||
"responsibilitycenter_accountitem": "",
|
||||
"responsibilitycenter_accountname": "",
|
||||
"responsibilitycenter_accountnumber": "",
|
||||
"responsibilitycenter_rate": "",
|
||||
"responsibilitycenters": {
|
||||
"ap": "",
|
||||
"ar": "",
|
||||
"atp": "",
|
||||
"federal_tax": "",
|
||||
"lab": "",
|
||||
|
||||
@@ -7,6 +7,7 @@ require("dotenv").config({
|
||||
),
|
||||
});
|
||||
const queries = require("../../graphql-client/queries");
|
||||
const Dinero = require("dinero.js");
|
||||
|
||||
exports.default = async (req, res) => {
|
||||
const BearerToken = req.headers.authorization;
|
||||
@@ -23,14 +24,89 @@ exports.default = async (req, res) => {
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.QUERY_JOBS_FOR_RECEIVABLES_EXPORT, { id: jobId });
|
||||
|
||||
const { jobs_by_pk } = result;
|
||||
const { bodyshop } = jobs_by_pk;
|
||||
//Build the IIF file.
|
||||
const response = [];
|
||||
response.push(TRNS_HEADER);
|
||||
response.push(generateInvoiceHeader(result.jobs_by_pk));
|
||||
response.push(
|
||||
generateInvoiceHeader(jobs_by_pk, bodyshop.md_responsibility_centers.ar)
|
||||
);
|
||||
|
||||
//Allocations
|
||||
const invoice_allocation = jobs_by_pk.invoice_allocation;
|
||||
Object.keys(invoice_allocation.partsAllocations).forEach(
|
||||
(partsAllocationKey) => {
|
||||
if (
|
||||
!!!invoice_allocation.partsAllocations[partsAllocationKey].allocations
|
||||
)
|
||||
return;
|
||||
|
||||
invoice_allocation.partsAllocations[
|
||||
partsAllocationKey
|
||||
].allocations.forEach((alloc) => {
|
||||
response.push(
|
||||
generateInvoiceLine(
|
||||
jobs_by_pk,
|
||||
alloc,
|
||||
bodyshop.md_responsibility_centers
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
Object.keys(invoice_allocation.labMatAllocations).forEach(
|
||||
(AllocationKey) => {
|
||||
if (!!!invoice_allocation.labMatAllocations[AllocationKey].allocations)
|
||||
return;
|
||||
|
||||
invoice_allocation.labMatAllocations[AllocationKey].allocations.forEach(
|
||||
(alloc) => {
|
||||
response.push(
|
||||
generateInvoiceLine(
|
||||
jobs_by_pk,
|
||||
alloc,
|
||||
bodyshop.md_responsibility_centers
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
//End Allocations
|
||||
|
||||
//Taxes
|
||||
const taxMapping = bodyshop.md_responsibility_centers.taxes;
|
||||
const { federal_tax, state_tax, local_tax } = JSON.parse(
|
||||
jobs_by_pk.job_totals
|
||||
).totals;
|
||||
const federal_tax_dinero = Dinero(federal_tax);
|
||||
const state_tax_dinero = Dinero(state_tax);
|
||||
const local_tax_dinero = Dinero(local_tax);
|
||||
|
||||
if (federal_tax_dinero.getAmount() > 0) {
|
||||
response.push(
|
||||
generateTaxLine(jobs_by_pk, federal_tax_dinero, "federal", taxMapping)
|
||||
);
|
||||
}
|
||||
if (state_tax_dinero.getAmount() > 0) {
|
||||
response.push(
|
||||
generateTaxLine(jobs_by_pk, state_tax_dinero, "state", taxMapping)
|
||||
);
|
||||
}
|
||||
if (local_tax_dinero.getAmount() > 0) {
|
||||
response.push(
|
||||
generateTaxLine(jobs_by_pk, local_tax_dinero, "local", taxMapping)
|
||||
);
|
||||
}
|
||||
//End Taxes
|
||||
|
||||
response.push(END_TRNS);
|
||||
|
||||
//Prep the response and send it.
|
||||
res.setHeader("Content-type", "application/octet-stream");
|
||||
res.setHeader("Content-disposition", "attachment; filename=file.txt");
|
||||
res.setHeader("filename", `${result.jobs_by_pk.ro_number}-RECEIVABLES.iif`);
|
||||
res.setHeader("filename", `${jobs_by_pk.ro_number}-RECEIVABLES.iif`);
|
||||
res.send(response.join("\n"));
|
||||
} catch (error) {
|
||||
console.log("error", error);
|
||||
@@ -42,17 +118,51 @@ const TRNS_HEADER = `!TRNS TRNSID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM M
|
||||
!SPL SPLID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR QNTY PRICE INVITEM PAYMETH TAXABLE VALADJ SERVICEDATE OTHER2 EXTRA
|
||||
!ENDTRNS`;
|
||||
|
||||
const generateInvoiceHeader = (job) =>
|
||||
`TRNS INVOICE ${new Date(job.date_invoiced).getMonth() + 1}/${new Date(
|
||||
job.date_invoiced
|
||||
).getDate()}/${new Date(
|
||||
job.date_invoiced
|
||||
).getFullYear()} Accounts Receivable GUO DA Acct.# ${job.ownr_id}:${
|
||||
job.ro_number
|
||||
} 0100 ${job.clm_total} ${job.ro_number} N N Y GUO DA Acct.# ${job.ownr_id}:${
|
||||
job.ro_number
|
||||
} ${job.ownr_addr1} ${job.ownr_city} ${job.ownr_st} ${job.ownr_zip} `;
|
||||
const generateInvoiceLine = (line) =>
|
||||
`SPL INVOICE 05/21/2020 Sales:Total Labour:Sales, Body Shop Labour 0100 -572.60 114519 Labor Body N 572.60 Total Labour:4015 Y N `;
|
||||
const generateInvoiceHeader = (job, arMapping) =>
|
||||
`TRNS INVOICE ${generateJobInvoiceDate(job)} ${arMapping.name} GUO DA Acct.# ${
|
||||
job.ownerid
|
||||
}:${job.ro_number} 0100 ${job.clm_total} ${job.ro_number} N N Y GUO DA Acct.# ${
|
||||
job.ownr_id
|
||||
}:${job.ro_number} ${job.ownr_addr1} ${job.ownr_city} ${job.ownr_st} ${
|
||||
job.ownr_zip
|
||||
} `;
|
||||
|
||||
const generateInvoiceLine = (job, allocation, responsibilityCenters) => {
|
||||
const { amount, center } = allocation;
|
||||
const DineroAmount = Dinero(amount);
|
||||
const account = responsibilityCenters.profits.find(
|
||||
(i) => i.name.toLowerCase() === center.toLowerCase()
|
||||
);
|
||||
|
||||
if (!!!account) {
|
||||
throw new Error(
|
||||
`A matching account does not exist for the allocation. Center: ${center}`
|
||||
);
|
||||
}
|
||||
|
||||
return `SPL INVOICE ${generateJobInvoiceDate(job)} ${
|
||||
account.accountname
|
||||
} 0100 ${DineroAmount.multiply(-1).toFormat(DineroQbFormat)} ${job.ro_number} ${
|
||||
account.accountdesc
|
||||
} N ${DineroAmount.toFormat(DineroQbFormat)} ${account.accountitem} Y N `;
|
||||
};
|
||||
|
||||
const generateTaxLine = (job, amount, type, taxMapping) => {
|
||||
return `SPL INVOICE ${generateJobInvoiceDate(job)} ${
|
||||
taxMapping[type].accountname
|
||||
} ${taxMapping[type].accountdesc} 0100 ${amount
|
||||
.multiply(-1)
|
||||
.toFormat(DineroQbFormat)} ${job.ro_number} N ${taxMapping[type].rate.toFixed(
|
||||
2
|
||||
)}% ${taxMapping[type].accountitem} N N AUTOSTAX `;
|
||||
};
|
||||
|
||||
const END_TRNS = `ENDTRNS`;
|
||||
|
||||
const DineroQbFormat = "0,0.0";
|
||||
|
||||
const generateJobInvoiceDate = (job) => {
|
||||
return `${new Date(job.date_invoiced).getMonth() + 1}/${new Date(
|
||||
job.date_invoiced
|
||||
).getDate()}/${new Date(job.date_invoiced).getFullYear()}`;
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ mutation UPDATE_MESSAGE($msid: String!, $fields: messages_set_input!) {
|
||||
`;
|
||||
|
||||
exports.QUERY_JOBS_FOR_RECEIVABLES_EXPORT = `
|
||||
query QUERY_JOBS_FOR_RECEIVABLES_EXPORT($id: uuid!){
|
||||
query QUERY_JOBS_FOR_RECEIVABLES_EXPORT($id: uuid!) {
|
||||
jobs_by_pk(id: $id) {
|
||||
id
|
||||
job_totals
|
||||
@@ -55,11 +55,10 @@ query QUERY_JOBS_FOR_RECEIVABLES_EXPORT($id: uuid!){
|
||||
ownr_zip
|
||||
ownr_city
|
||||
ownr_st
|
||||
|
||||
}
|
||||
bodyshops{
|
||||
id
|
||||
md_responsibility_centers
|
||||
bodyshop {
|
||||
id
|
||||
md_responsibility_centers
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user