fix(ci): format invoice mock helpers

This commit is contained in:
Adam Moussa 2026-09-25 17:25:19 -04:00
parent 3179ef848b
commit 83529e6354
No known key found for this signature in database

View file

@ -168,29 +168,27 @@ function withRefreshedCatalogFields(invoice: MockInvoice): MockInvoice {
}
function enrichInvoice(core: MockInvoiceCore, index: number): MockInvoice {
return withRefreshedCatalogFields(
{
...core,
hasBolt: index % 3 === 0,
hasBell: index % 2 === 0,
hasEye: true,
actionLabel: actionLabelForStatus(core.status),
lastUpdate: "",
lastUpdateMessage: "",
lastUpdateActorName: "",
lastUpdateAt: "",
invoiceDate: invoiceDateBeforeDue(core.dueDate, index),
processingBegan: core.activity[0]?.createdAt?.slice(0, 10) ?? core.dueDate,
tagging: index % 2 === 0 ? "Ops" : "",
fs: index % 2 === 0 ? "synced" : "",
description: core.memo,
invoiceType: "Standard",
location: "Ronkonkoma",
paymentAccount: paymentAccountFor(core.paymentMethod),
relatedInvoice: null,
rowCount: core.lines.length,
},
);
return withRefreshedCatalogFields({
...core,
hasBolt: index % 3 === 0,
hasBell: index % 2 === 0,
hasEye: true,
actionLabel: actionLabelForStatus(core.status),
lastUpdate: "",
lastUpdateMessage: "",
lastUpdateActorName: "",
lastUpdateAt: "",
invoiceDate: invoiceDateBeforeDue(core.dueDate, index),
processingBegan: core.activity[0]?.createdAt?.slice(0, 10) ?? core.dueDate,
tagging: index % 2 === 0 ? "Ops" : "",
fs: index % 2 === 0 ? "synced" : "",
description: core.memo,
invoiceType: "Standard",
location: "Ronkonkoma",
paymentAccount: paymentAccountFor(core.paymentMethod),
relatedInvoice: null,
rowCount: core.lines.length,
});
}
function cloneInvoice(invoice: MockInvoice): MockInvoice {
@ -580,22 +578,20 @@ export function updateMockInvoicePayDate(id: string, payDate: string | null): Mo
const current = invoiceStore[index];
return replaceInvoice(
index,
withRefreshedCatalogFields(
{
...current,
payDate,
activity: [
...current.activity,
{
id: `activity-pay-date-${Date.now()}`,
actorUserId: "user-1",
actorName: "System",
message: "Pay date updated",
createdAt: new Date().toISOString(),
},
],
},
),
withRefreshedCatalogFields({
...current,
payDate,
activity: [
...current.activity,
{
id: `activity-pay-date-${Date.now()}`,
actorUserId: "user-1",
actorName: "System",
message: "Pay date updated",
createdAt: new Date().toISOString(),
},
],
}),
);
}
@ -605,10 +601,7 @@ export function updateMockInvoiceHeader(id: string, patch: MockInvoiceHeaderPatc
throw new Error(`Mock invoice not found: ${id}`);
}
return replaceInvoice(
index,
withRefreshedCatalogFields({ ...invoiceStore[index], ...patch }),
);
return replaceInvoice(index, withRefreshedCatalogFields({ ...invoiceStore[index], ...patch }));
}
export function updateMockInvoiceLines(id: string, lines: MockInvoiceLine[]): MockInvoice {
@ -619,12 +612,10 @@ export function updateMockInvoiceLines(id: string, lines: MockInvoiceLine[]): Mo
return replaceInvoice(
index,
withRefreshedCatalogFields(
{
...invoiceStore[index],
lines: lines.map((line) => ({ ...line })),
},
),
withRefreshedCatalogFields({
...invoiceStore[index],
lines: lines.map((line) => ({ ...line })),
}),
);
}
@ -651,12 +642,10 @@ export function addMockInvoiceComment(
return replaceInvoice(
index,
withRefreshedCatalogFields(
{
...current,
comments: [...current.comments, nextComment],
},
),
withRefreshedCatalogFields({
...current,
comments: [...current.comments, nextComment],
}),
);
}
@ -684,13 +673,11 @@ export function transitionMockInvoiceStatus(
const updated = replaceInvoice(
index,
withRefreshedCatalogFields(
{
...current,
status,
activity: [...current.activity, nextActivity],
},
),
withRefreshedCatalogFields({
...current,
status,
activity: [...current.activity, nextActivity],
}),
);
if (status === "approved" || status === "rejected") {