IO-2327 posting bills tests cases

This commit is contained in:
swtmply
2023-07-03 09:06:58 +08:00
parent 39f7a3c870
commit fc09871a47
12 changed files with 370 additions and 46 deletions

View File

@@ -52,10 +52,10 @@ describe(
// fill out form
// data-cy="bill-form-invoice"
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId());
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD246-00-"));
cy.get("#bill-form-date").click();
cy.get('[title="2023-06-22"]').should("be.visible").click();
cy.get('[title="2023-06-30"]').should("be.visible").click();
// get table
cy.get('[data-cy="bill-line-table"]').each(($row) => {
@@ -75,9 +75,7 @@ describe(
});
// Click save
cy.get('[data-cy="bill-form-save-button"]')
.should("not.be.disabled")
.click();
cy.get('[data-cy="bill-form-save-button"]').click();
cy.get(".ant-notification-notice-message").contains(
"Invoice added successfully."
@@ -96,10 +94,10 @@ describe(
// Select Line
cy.antdSelect("bill-line", "-- Not On Estimate --");
// Fill the Form
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("DBP"));
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD246-01-"));
cy.get("#bill-form-date").click();
cy.get('[title="2023-06-22"]').should("be.visible").click();
cy.get('[title="2023-06-30"]').should("be.visible").click();
// get table
cy.get('[data-cy="bill-line-table"]').each(($row) => {
@@ -119,9 +117,7 @@ describe(
});
// Click save
cy.get('[data-cy="bill-form-save-button"]')
.should("not.be.disabled")
.click();
cy.get('[data-cy="bill-form-save-button"]').click();
cy.get(".ant-notification-notice-message").contains(
"Invoice added successfully."
@@ -140,10 +136,10 @@ describe(
// Select Line
cy.antdSelect("bill-line", "-- Not On Estimate --");
// Fill the Form
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("DBP"));
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD246-02-"));
cy.get("#bill-form-date").click();
cy.get('[title="2023-06-22"]').should("be.visible").click();
cy.get('[title="2023-06-30"]').should("be.visible").click();
// get table
cy.get('[data-cy="bill-line-table"]').each(($row) => {
@@ -190,5 +186,257 @@ describe(
.find(".ant-upload #bill-document-upload")
.selectFile("job.json", { force: true });
});
it("marks bill as exported", () => {
cy.get('[data-cy="bills-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("bills-table")
.should("not.have.class", "ant-table-placeholder");
cy.get("@bills-table")
.find('[data-cy="bill-exported-checkbox"]')
.not(":checked")
.first()
.as("export-status")
.parent()
.parent()
.parent()
.parent()
.find('[data-cy="edit-bill-button"]')
.click();
cy.location("search").should("include", "billid");
cy.get('[data-cy="bill-mark-export-button"]')
.as("mark-for-export")
.click();
cy.get("@mark-for-export").should("be.disabled");
});
it("marks bill for re-export", () => {
cy.get('[data-cy="bills-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("bills-table")
.should("not.have.class", "ant-table-placeholder");
cy.get("@bills-table")
.find('[data-cy="bill-exported-checkbox"]')
.filter(":checked")
.first()
.as("export-status")
.parent()
.parent()
.parent()
.parent()
.find('[data-cy="edit-bill-button"]')
.click();
cy.location("search").should("include", "billid");
cy.get('[data-cy="bill-mark-reexport-button"]')
.as("mark-for-reexport")
.click();
cy.get("@mark-for-reexport").should("be.disabled");
});
}
);
describe(
"Validating and calculating bills",
{
defaultCommandTimeout: 5000,
},
() => {
beforeEach(() => {
cy.visit("/manage");
cy.get("body").then(($body) => {
if ($body.text().includes("Login")) {
// Log in
cy.get('[data-cy="username"]').type("john@imex.dev");
cy.get('[data-cy="password"]').type("john123");
cy.get('[data-cy="sign-in-button"]').click();
}
cy.get(".ant-table-tbody")
.should("be.visible")
.find("tr")
.should("not.have.class", "ant-table-placeholder");
cy.get(".ant-table-row").contains("QBD261").click();
cy.url().should("include", "/manage/jobs");
// Go to repair data tab
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
});
});
it("validates auto reconciliation through posting bill", () => {
// Find the first row in the parts order
cy.get('[data-cy="part-orders-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("orders-table")
.should("not.have.class", "ant-table-placeholder");
cy.get("@orders-table")
.first()
.should("be.visible")
.find('[data-cy="receive-bill-button"]')
.click();
// fill out form
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD261-0"));
cy.get("#bill-form-date").click();
cy.get('[title="2023-06-30"]').should("be.visible").click();
cy.get('[data-cy="bill-form-bill-total"]').type("70.46");
cy.get('[data-cy="bill-line-actual-cost"]').type("67.10");
cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
// Click save
cy.get('[data-cy="bill-form-save-button"]').click();
cy.get("#retailtotal").should("have.text", "$83.87");
cy.get(".discrepancy").each(($statistic) => {
cy.wrap($statistic).should("have.text", "$0.00");
});
});
it("returning item and validating statistics", () => {
cy.get('[data-cy="bills-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("bills-table")
.should("not.have.class", "ant-table-placeholder");
cy.get("@bills-table")
.first()
.should("not.be.disabled")
.find('[data-cy="return-items-button"]')
.click();
cy.get('[data-cy="billline-checkbox"]').check();
cy.get('[data-cy="billline-return-items-ok-button"]').click();
cy.get("#order-quantity").type("1", { force: true, multiple: true });
cy.get('[data-cy="part-order-select-none"]').click({
multiple: true,
force: true,
});
cy.get('[data-cy="order-part-submit"]').click({
multiple: true,
force: true,
});
cy.get("#totalReturns").should("have.text", "$83.87");
cy.get("#calculatedcreditsnotreceived").should("have.text", "$83.87");
cy.get("#creditsnotreceived").should("have.text", "$83.87");
});
it("receives credit memo without return part", () => {
// Find the first row in the parts order
cy.get('[data-cy="part-orders-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("orders-table")
.should("not.have.class", "ant-table-placeholder");
cy.get("@orders-table")
.find('[data-cy="part-order-return-checkbox"]')
.filter(":checked")
.first()
.parent()
.parent()
.parent()
.parent()
.find('[data-cy="receive-bill-button"]')
.click();
// fill out form
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD261-01-"));
cy.get("#bill-form-date").click();
cy.get('[title="2023-06-30"]').should("be.visible").click();
cy.get('[data-cy="bill-form-bill-total"]').type("70.46");
cy.get('[data-cy="bill-line-actual-cost"]').type("67.10");
cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
// Click save
cy.get('[data-cy="bill-form-save-button"]').click();
cy.get("#totalReturns").should("have.text", "$83.87");
cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00");
cy.get("#creditsnotreceived").should("have.text", "$83.87");
});
it("receives credit memo with return part", () => {
// Find the first row in the parts order
cy.get('[data-cy="part-orders-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("orders-table")
.should("not.have.class", "ant-table-placeholder");
cy.get("@orders-table")
.find('[data-cy="part-order-return-checkbox"]')
.filter(":checked")
.first()
.parent()
.parent()
.parent()
.parent()
.find('[data-cy="receive-bill-button"]')
.click();
// fill out form
cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD261-02-"));
cy.get("#bill-form-date").click();
cy.get('[title="2023-06-30"]').should("be.visible").click();
cy.get('[data-cy="bill-form-bill-total"]').type("70.46");
cy.get('[data-cy="bill-line-actual-cost"]').type("67.10");
cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
cy.get('[data-cy="mark-as-received-checkbox"]').check();
// Click save
cy.get('[data-cy="bill-form-save-button"]').click();
cy.get("#totalReturns").should("have.text", "$83.87");
cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00");
cy.get("#creditsnotreceived").should("have.text", "$0.00");
});
it("views the row expander if it has the order and bill", () => {
cy.get('[data-cy="tab-repairdata"]').should("be.visible").click();
cy.get('[data-cy="filter-parts-button"]')
.should("not.be.disabled")
.click();
cy.get('[data-cy="repair-data-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.first()
.next()
.find("td")
.first()
.click();
cy.get('[data-cy="parts-bills-order"]')
.should("be.visible")
.find("li")
.first()
.should("not.have.text", "This part has not yet been ordered.");
});
}
);

View File

@@ -117,7 +117,7 @@ export default function BillCmdReturnsTableComponent({
name={[field.name, "cm_received"]}
valuePropName="checked"
>
<Checkbox />
<Checkbox data-cy="mark-as-received-checkbox" />
</Form.Item>
</td>
</tr>

View File

@@ -194,8 +194,14 @@ export function BillDetailEditcontainer({
{t("general.actions.save")}
</Button>
</Popconfirm>
<BillReeportButtonComponent bill={data && data.bills_by_pk} />
<BillMarkExportedButton bill={data && data.bills_by_pk} />
<BillReeportButtonComponent
data-cy="bill-mark-reexport-button"
bill={data && data.bills_by_pk}
/>
<BillMarkExportedButton
data-cy="bill-mark-export-button"
bill={data && data.bills_by_pk}
/>
</Space>
}
/>

View File

@@ -77,11 +77,14 @@ export function BillDetailEditReturn({
return (
<>
<Modal
visible={visible}
open={visible}
onCancel={() => setVisible(false)}
destroyOnClose
title={t("bills.actions.return")}
onOk={() => form.submit()}
okButtonProps={{
"data-cy": "billline-return-items-ok-button",
}}
>
<Form
initialValues={data && data.bills_by_pk}
@@ -124,7 +127,7 @@ export function BillDetailEditReturn({
name={[field.name, "selected"]}
valuePropName="checked"
>
<Checkbox />
<Checkbox data-cy="billline-checkbox" />
</Form.Item>
</td>
<td>
@@ -173,6 +176,7 @@ export function BillDetailEditReturn({
</Form>
</Modal>
<Button
data-cy="return-items-button"
disabled={data.bills_by_pk.is_credit_memo || disabled}
onClick={() => {
setVisible(true);

View File

@@ -411,7 +411,12 @@ export function BillFormComponent({
? "green"
: "red",
}}
value={totals.discrepancy.toFormat()}
// value={totals.discrepancy.toFormat()}
valueRender={() => (
<span id="bill-form-discrepancy">
{totals.discrepancy.toFormat()}
</span>
)}
precision={2}
/>
</Space>

View File

@@ -32,6 +32,7 @@ export function BillMarkExportedButton({
bodyshop,
authLevel,
bill,
...props
}) {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
@@ -92,7 +93,12 @@ export function BillMarkExportedButton({
if (hasAccess)
return (
<Button loading={loading} disabled={bill.exported} onClick={handleUpdate}>
<Button
loading={loading}
disabled={bill.exported}
onClick={handleUpdate}
{...props}
>
{t("bills.labels.markexported")}
</Button>
);

View File

@@ -24,7 +24,12 @@ export default connect(
mapDispatchToProps
)(BillMarkForReexportButton);
export function BillMarkForReexportButton({ bodyshop, authLevel, bill }) {
export function BillMarkForReexportButton({
bodyshop,
authLevel,
bill,
...props
}) {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
@@ -73,6 +78,7 @@ export function BillMarkForReexportButton({ bodyshop, authLevel, bill }) {
loading={loading}
disabled={!bill.exported}
onClick={handleUpdate}
{...props}
>
{t("bills.labels.markforreexport")}
</Button>

View File

@@ -138,7 +138,9 @@ export function BillsListTableComponent({
sorter: (a, b) => a.exported - b.exported,
sortOrder:
state.sortedInfo.columnKey === "exported" && state.sortedInfo.order,
render: (text, record) => <Checkbox checked={record.exported} />,
render: (text, record) => (
<Checkbox data-cy="bill-exported-checkbox" checked={record.exported} />
),
},
{
title: t("general.labels.actions"),

View File

@@ -127,7 +127,10 @@ export default function JobBillsTotalComponent({
>
<Statistic
title={t("bills.labels.retailtotal")}
value={billTotals.toFormat()}
// value={billTotals.toFormat()}
valueRender={() => (
<span id="retailtotal">{billTotals.toFormat()}</span>
)}
/>
</Tooltip>
<Typography.Title>=</Typography.Title>
@@ -145,7 +148,12 @@ export default function JobBillsTotalComponent({
valueStyle={{
color: discrepancy.getAmount() === 0 ? "green" : "red",
}}
value={discrepancy.toFormat()}
// value={discrepancy.toFormat()}
valueRender={() => (
<span id="discrepancy" className="discrepancy">
{discrepancy.toFormat()}
</span>
)}
/>
</Tooltip>
<Typography.Title>+</Typography.Title>
@@ -178,7 +186,12 @@ export default function JobBillsTotalComponent({
valueStyle={{
color: discrepWithLbrAdj.getAmount() === 0 ? "green" : "red",
}}
value={discrepWithLbrAdj.toFormat()}
// value={discrepWithLbrAdj.toFormat()}
valueRender={() => (
<span id="discrepWithLbrAdj" className="discrepancy">
{discrepWithLbrAdj.toFormat()}
</span>
)}
/>
</Tooltip>
<Typography.Title>+</Typography.Title>
@@ -193,7 +206,10 @@ export default function JobBillsTotalComponent({
>
<Statistic
title={t("bills.labels.totalreturns")}
value={totalReturns.toFormat()}
// value={totalReturns.toFormat()}
valueRender={() => (
<span id="totalReturns">{totalReturns.toFormat()}</span>
)}
/>
</Tooltip>
<Typography.Title>=</Typography.Title>
@@ -211,7 +227,12 @@ export default function JobBillsTotalComponent({
valueStyle={{
color: discrepWithCms.getAmount() === 0 ? "green" : "red",
}}
value={discrepWithCms.toFormat()}
// value={discrepWithCms.toFormat()}
valueRender={() => (
<span id="discrepWithCms" className="discrepancy">
{discrepWithCms.toFormat()}
</span>
)}
/>
</Tooltip>
</Space>
@@ -231,7 +252,10 @@ export default function JobBillsTotalComponent({
>
<Statistic
title={t("bills.labels.totalreturns")}
value={totalReturns.toFormat()}
// value={totalReturns.toFormat()}
valueRender={() => (
<span id="totalReturns">{totalReturns.toFormat()}</span>
)}
/>
</Tooltip>
<Tooltip
@@ -253,11 +277,18 @@ export default function JobBillsTotalComponent({
? "green"
: "red",
}}
value={
calculatedCreditsNotReceived.getAmount() >= 0
? calculatedCreditsNotReceived.toFormat()
: Dinero().toFormat()
}
// value={
// calculatedCreditsNotReceived.getAmount() >= 0
// ? calculatedCreditsNotReceived.toFormat()
// : Dinero().toFormat()
// }
valueRender={() => (
<span id="calculatedcreditsnotreceived">
{calculatedCreditsNotReceived.getAmount() >= 0
? calculatedCreditsNotReceived.toFormat()
: Dinero().toFormat()}
</span>
)}
/>
</Tooltip>
<Tooltip
@@ -277,11 +308,18 @@ export default function JobBillsTotalComponent({
? "green"
: "red",
}}
value={
totalReturnsMarkedNotReceived.getAmount() >= 0
? totalReturnsMarkedNotReceived.toFormat()
: Dinero().toFormat()
}
// value={
// totalReturnsMarkedNotReceived.getAmount() >= 0
// ? totalReturnsMarkedNotReceived.toFormat()
// : Dinero().toFormat()
// }
valueRender={() => (
<span id="creditsnotreceived">
{totalReturnsMarkedNotReceived.getAmount() >= 0
? totalReturnsMarkedNotReceived.toFormat()
: Dinero().toFormat()}
</span>
)}
/>
</Tooltip>
</Space>

View File

@@ -22,12 +22,12 @@ export default function JobLinesExpander({ jobline, jobid }) {
if (error) return <AlertComponent message={error.message} type="error" />;
return (
<Row>
<Row data-cy="parts-expanded-row">
<Col md={24} lg={12}>
<Typography.Title level={4}>
{t("parts_orders.labels.parts_orders")}
</Typography.Title>
<Timeline>
<Timeline data-cy="parts-bills-order">
{data.parts_order_lines.length > 0 ? (
data.parts_order_lines.map((line) => (
<Timeline.Item key={line.id}>
@@ -43,7 +43,7 @@ export default function JobLinesExpander({ jobline, jobid }) {
</Timeline.Item>
))
) : (
<Timeline.Item>
<Timeline.Item data-cy="parts-empty-order">
{t("parts_orders.labels.notyetordered")}
</Timeline.Item>
)}
@@ -51,7 +51,7 @@ export default function JobLinesExpander({ jobline, jobid }) {
</Col>
<Col md={24} lg={12}>
<Typography.Title level={4}>{t("bills.labels.bills")}</Typography.Title>
<Timeline>
<Timeline data-cy="parts-bills-order">
{data.billlines.length > 0 ? (
data.billlines.map((line) => (
<Timeline.Item key={line.id}>
@@ -71,7 +71,7 @@ export default function JobLinesExpander({ jobline, jobid }) {
</Col>
<Col span={4}>
<span>
{`${t("billlines.fields.actual_cost")}: `}
{`${t("billlines.fields.actual_cost")}: `}
<CurrencyFormatter>{line.actual_cost}</CurrencyFormatter>
</span>
</Col>
@@ -83,7 +83,7 @@ export default function JobLinesExpander({ jobline, jobid }) {
</Timeline.Item>
))
) : (
<Timeline.Item>
<Timeline.Item data-cy="parts-empty-order">
{t("parts_orders.labels.notyetordered")}
</Timeline.Item>
)}

View File

@@ -246,7 +246,12 @@ export function PartsOrderListTableComponent({
sorter: (a, b) => a.return - b.return,
sortOrder:
state.sortedInfo.columnKey === "return" && state.sortedInfo.order,
render: (text, record) => <Checkbox checked={record.return} />,
render: (text, record) => (
<Checkbox
data-cy="part-order-return-checkbox"
checked={record.return}
/>
),
},
{
title: t("parts_orders.fields.deliver_by"),

View File

@@ -256,7 +256,7 @@ export function PartsOrderModalComponent({
},
]}
>
<InputNumber />
<InputNumber id="order-quantity" />
</Form.Item>
<Form.Item
label={t("parts_orders.fields.act_price")}
@@ -334,7 +334,11 @@ export function PartsOrderModalComponent({
value={sendType}
onChange={(e) => setSendType(e.target.value)}
>
<Radio disabled={is_quote} value={"none"}>
<Radio
data-cy="part-order-select-none"
disabled={is_quote}
value={"none"}
>
{t("general.labels.none")}
</Radio>
<Radio disabled={is_quote} value={"e"}>