IO-1914 Inventory bugfixes.

This commit is contained in:
Patrick Fic
2022-06-07 11:41:27 -07:00
parent 9bf3974ba0
commit fe5e2a247a
8 changed files with 74 additions and 25 deletions

View File

@@ -2181,6 +2181,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>existinginventoryline</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> <concept_node>
<name>exporting</name> <name>exporting</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>

View File

@@ -15,7 +15,8 @@ export default function BillDeleteButton({ bill }) {
setLoading(true); setLoading(true);
const result = await deleteBill({ const result = await deleteBill({
variables: { billId: bill.id }, variables: { billId: bill.id },
update(cache) { update(cache, { errors }) {
if (errors) return;
cache.modify({ cache.modify({
fields: { fields: {
bills(existingBills, { readField }) { bills(existingBills, { readField }) {
@@ -36,11 +37,22 @@ export default function BillDeleteButton({ bill }) {
if (!!!result.errors) { if (!!!result.errors) {
notification["success"]({ message: t("bills.successes.deleted") }); notification["success"]({ message: t("bills.successes.deleted") });
} else { } else {
notification["error"]({ //Check if it's an fkey violation.
message: t("bills.errors.deleting", { const error = JSON.stringify(result.errors);
error: JSON.stringify(result.errors),
}), if (error.toLowerCase().includes("inventory_billid_fkey")) {
}); notification["error"]({
message: t("bills.errors.deleting", {
error: t("bills.errors.existinginventoryline"),
}),
});
} else {
notification["error"]({
message: t("bills.errors.deleting", {
error: JSON.stringify(result.errors),
}),
});
}
} }
setLoading(false); setLoading(false);

View File

@@ -485,22 +485,33 @@ export function BillEnterModalLinesComponent({
dataIndex: "actions", dataIndex: "actions",
render: (text, record) => ( render: (text, record) => (
<Space wrap> <Form.Item shouldUpdate noStyle>
<Button disabled={disabled} onClick={() => remove(record.name)}> {() => (
<DeleteFilled /> <Space wrap>
</Button> <Button
<Form.Item shouldUpdate noStyle> disabled={
{() => disabled ||
Simple_Inventory.treatment === "on" && ( getFieldValue("billlines")[record.fieldKey]?.inventories
?.length > 0
}
onClick={() => remove(record.name)}
>
<DeleteFilled />
</Button>
{Simple_Inventory.treatment === "on" && (
<BilllineAddInventory <BilllineAddInventory
disabled={!billEdit || form.isFieldsTouched()} disabled={
!billEdit ||
form.isFieldsTouched() ||
form.getFieldValue("is_credit_memo")
}
billline={getFieldValue("billlines")[record.fieldKey]} billline={getFieldValue("billlines")[record.fieldKey]}
jobid={getFieldValue("jobid")} jobid={getFieldValue("jobid")}
/> />
) )}
} </Space>
</Form.Item> )}
</Space> </Form.Item>
), ),
}, },
]; ];

View File

@@ -64,9 +64,9 @@ export function BilllineAddInventory({
cost_center: billline.cost_center, cost_center: billline.cost_center,
deductedfromlbr: billline.deductedfromlbr, deductedfromlbr: billline.deductedfromlbr,
applicable_taxes: { applicable_taxes: {
local: false, //billline.applicable_taxes.local, local: billline.applicable_taxes.local,
state: false, //billline.applicable_taxes.state, state: billline.applicable_taxes.state,
federal: false, // billline.applicable_taxes.federal, federal: billline.applicable_taxes.federal,
}, },
}, },
], ],
@@ -76,7 +76,9 @@ export function BilllineAddInventory({
const insertResult = await insertInventoryLine({ const insertResult = await insertInventoryLine({
variables: { variables: {
joblineId: billline.joblineid, joblineId:
billline.joblineid === "noline" ? billline.id : billline.joblineid, //This will return null as there will be no jobline that has the id of the bill line.
//Unfortunately, we can't send null as the GQL syntax validation fails.
joblineStatus: bodyshop.md_order_statuses.default_returned, joblineStatus: bodyshop.md_order_statuses.default_returned,
inv: { inv: {
shopid: bodyshop.id, shopid: bodyshop.id,
@@ -99,8 +101,9 @@ export function BilllineAddInventory({
act_price: billline.actual_price, act_price: billline.actual_price,
cost: billline.actual_cost, cost: billline.actual_cost,
quantity: billline.quantity, quantity: billline.quantity,
job_line_id: billline.joblineid, job_line_id:
part_type: billline.jobline.part_type, billline.joblineid === "noline" ? null : billline.joblineid,
part_type: billline.jobline && billline.jobline.part_type,
cm_received: true, cm_received: true,
}, },
], ],

View File

@@ -6,7 +6,6 @@ export const getJobMedia = (jobid) => ({
}); });
export const getBillMedia = ({ jobid, invoice_number }) => { export const getBillMedia = ({ jobid, invoice_number }) => {
console.log("in the action");
return { return {
type: MediaActionTypes.GET_MEDIA_FOR_BILL, type: MediaActionTypes.GET_MEDIA_FOR_BILL,
payload: { jobid, invoice_number }, payload: { jobid, invoice_number },

View File

@@ -147,6 +147,7 @@
"errors": { "errors": {
"creating": "Error adding bill. {{error}}", "creating": "Error adding bill. {{error}}",
"deleting": "Error deleting bill. {{error}}", "deleting": "Error deleting bill. {{error}}",
"existinginventoryline": "This bill cannot be deleted as it is tied to items in inventory.",
"exporting": "Error exporting payable(s). {{error}}", "exporting": "Error exporting payable(s). {{error}}",
"exporting-partner": "Unable to connect to ImEX Partner. Please ensure it is running and logged in.", "exporting-partner": "Unable to connect to ImEX Partner. Please ensure it is running and logged in.",
"invalidro": "Not a valid RO.", "invalidro": "Not a valid RO.",

View File

@@ -147,6 +147,7 @@
"errors": { "errors": {
"creating": "", "creating": "",
"deleting": "", "deleting": "",
"existinginventoryline": "",
"exporting": "", "exporting": "",
"exporting-partner": "", "exporting-partner": "",
"invalidro": "", "invalidro": "",

View File

@@ -147,6 +147,7 @@
"errors": { "errors": {
"creating": "", "creating": "",
"deleting": "", "deleting": "",
"existinginventoryline": "",
"exporting": "", "exporting": "",
"exporting-partner": "", "exporting-partner": "",
"invalidro": "", "invalidro": "",