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>
</translations>
</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>
<name>exporting</name>
<definition_loaded>false</definition_loaded>

View File

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

View File

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

View File

@@ -64,9 +64,9 @@ export function BilllineAddInventory({
cost_center: billline.cost_center,
deductedfromlbr: billline.deductedfromlbr,
applicable_taxes: {
local: false, //billline.applicable_taxes.local,
state: false, //billline.applicable_taxes.state,
federal: false, // billline.applicable_taxes.federal,
local: billline.applicable_taxes.local,
state: billline.applicable_taxes.state,
federal: billline.applicable_taxes.federal,
},
},
],
@@ -76,7 +76,9 @@ export function BilllineAddInventory({
const insertResult = await insertInventoryLine({
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,
inv: {
shopid: bodyshop.id,
@@ -99,8 +101,9 @@ export function BilllineAddInventory({
act_price: billline.actual_price,
cost: billline.actual_cost,
quantity: billline.quantity,
job_line_id: billline.joblineid,
part_type: billline.jobline.part_type,
job_line_id:
billline.joblineid === "noline" ? null : billline.joblineid,
part_type: billline.jobline && billline.jobline.part_type,
cm_received: true,
},
],

View File

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

View File

@@ -147,6 +147,7 @@
"errors": {
"creating": "Error adding 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-partner": "Unable to connect to ImEX Partner. Please ensure it is running and logged in.",
"invalidro": "Not a valid RO.",

View File

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

View File

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