IO-2327 posting bills test cases
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import job from "../../fixtures/jobs/job-3.json";
|
import job from "../../fixtures/jobs/job-3.json";
|
||||||
import job2 from "../../fixtures/jobs/job-4.json";
|
import job2 from "../../fixtures/jobs/job-4.json";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import Dinero from "dinero.js";
|
||||||
|
|
||||||
const uuid = () => Cypress._.random(0, 1e6);
|
const uuid = () => Cypress._.random(0, 1e6);
|
||||||
|
|
||||||
@@ -250,10 +251,17 @@ describe(
|
|||||||
describe.only(
|
describe.only(
|
||||||
"Validating and calculating bills",
|
"Validating and calculating bills",
|
||||||
{
|
{
|
||||||
defaultCommandTimeout: 5000,
|
defaultCommandTimeout: 10000,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
const today = moment(new Date()).format("YYYY-MM-DD");
|
const today = moment(new Date()).format("YYYY-MM-DD");
|
||||||
|
const jobLines = job2.joblines.data.filter(
|
||||||
|
(line) => line.part_type === "PAS" || line.part_type === "PAE"
|
||||||
|
);
|
||||||
|
const linesTotal = jobLines.reduce(
|
||||||
|
(prev, line) => prev + line.act_price,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.viewport(1280, 720);
|
cy.viewport(1280, 720);
|
||||||
@@ -282,7 +290,7 @@ describe.only(
|
|||||||
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
|
cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
|
||||||
});
|
});
|
||||||
|
|
||||||
it.only("validates auto reconciliation through posting bill", () => {
|
it("validates auto reconciliation through posting bill", () => {
|
||||||
// Find the first row in the parts order
|
// Find the first row in the parts order
|
||||||
cy.get('[data-cy="part-orders-table"]')
|
cy.get('[data-cy="part-orders-table"]')
|
||||||
.find(".ant-table-tbody")
|
.find(".ant-table-tbody")
|
||||||
@@ -300,7 +308,7 @@ describe.only(
|
|||||||
cy.get('[data-cy="bill-form-invoice"]').type(uuid());
|
cy.get('[data-cy="bill-form-invoice"]').type(uuid());
|
||||||
|
|
||||||
cy.get("#bill-form-date").click();
|
cy.get("#bill-form-date").click();
|
||||||
cy.get(`[title="${today}"]`).should("be.visible").click();
|
cy.get(`[title="${today}"]`).should("be.visible").click({ force: true });
|
||||||
|
|
||||||
cy.get('[data-cy="bill-line-table"]').each(($row) => {
|
cy.get('[data-cy="bill-line-table"]').each(($row) => {
|
||||||
// get retail amount
|
// get retail amount
|
||||||
@@ -338,22 +346,28 @@ describe.only(
|
|||||||
cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
|
cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
|
||||||
|
|
||||||
// Click save
|
// Click save
|
||||||
// cy.get('[data-cy="bill-form-save-button"]').click();
|
cy.get('[data-cy="bill-form-save-button"]').click();
|
||||||
|
|
||||||
cy.get("@retailPrice")
|
cy.get("@retailPrice")
|
||||||
.invoke("val")
|
.invoke("val")
|
||||||
.then((val) => {
|
.then((val) => {
|
||||||
|
const discrepancy = linesTotal - Number(val);
|
||||||
|
|
||||||
cy.get("#retailtotal").should("have.text", `$${val}`);
|
cy.get("#retailtotal").should("have.text", `$${val}`);
|
||||||
|
|
||||||
|
cy.get(".discrepancy").each(($statistic) => {
|
||||||
|
cy.wrap($statistic).should(
|
||||||
|
"have.text",
|
||||||
|
Dinero({
|
||||||
|
amount: discrepancy,
|
||||||
|
precision: 0,
|
||||||
|
}).toFormat()
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO get total of discrepancy
|
|
||||||
|
|
||||||
// cy.get(".discrepancy").each(($statistic) => {
|
|
||||||
// cy.wrap($statistic).should("have.text", "$0.00");
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returning item and validating statistics", () => {
|
it.only("returning item and validating statistics", () => {
|
||||||
cy.get('[data-cy="bills-table"]')
|
cy.get('[data-cy="bills-table"]')
|
||||||
.find(".ant-table-tbody")
|
.find(".ant-table-tbody")
|
||||||
.find("> tr:not(.ant-table-measure-row)")
|
.find("> tr:not(.ant-table-measure-row)")
|
||||||
@@ -368,20 +382,23 @@ describe.only(
|
|||||||
|
|
||||||
cy.get('[data-cy="billline-checkbox"]').check();
|
cy.get('[data-cy="billline-checkbox"]').check();
|
||||||
cy.get('[data-cy="billline-return-items-ok-button"]').click();
|
cy.get('[data-cy="billline-return-items-ok-button"]').click();
|
||||||
|
cy.get('[data-cy="billline-actual-price"]')
|
||||||
cy.get("#order-quantity").type("1", { force: true, multiple: true });
|
.find(".ant-form-item-control-input-content")
|
||||||
cy.get('[data-cy="part-order-select-none"]').click({
|
.invoke("text")
|
||||||
multiple: true,
|
.then((value) => {
|
||||||
force: true,
|
cy.get("#order-quantity").type("1", { force: true, multiple: true });
|
||||||
});
|
cy.get('[data-cy="part-order-select-none"]').click({
|
||||||
cy.get('[data-cy="order-part-submit"]').click({
|
multiple: true,
|
||||||
multiple: true,
|
force: true,
|
||||||
force: true,
|
});
|
||||||
});
|
cy.get('[data-cy="order-part-submit"]').click({
|
||||||
|
multiple: true,
|
||||||
cy.get("#totalReturns").should("have.text", "$83.87");
|
force: true,
|
||||||
cy.get("#calculatedcreditsnotreceived").should("have.text", "$83.87");
|
});
|
||||||
cy.get("#creditsnotreceived").should("have.text", "$83.87");
|
cy.get("#totalReturns").should("have.text", value);
|
||||||
|
cy.get("#calculatedcreditsnotreceived").should("have.text", value);
|
||||||
|
cy.get("#creditsnotreceived").should("have.text", value);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("receives credit memo without return part", () => {
|
it("receives credit memo without return part", () => {
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ export function BillDetailEditReturn({
|
|||||||
// label={t("joblines.fields.actual_price")}
|
// label={t("joblines.fields.actual_price")}
|
||||||
key={`${index}actual_price`}
|
key={`${index}actual_price`}
|
||||||
name={[field.name, "actual_price"]}
|
name={[field.name, "actual_price"]}
|
||||||
|
data-cy="billline-actual-price"
|
||||||
>
|
>
|
||||||
<ReadOnlyFormItemComponent type="currency" />
|
<ReadOnlyFormItemComponent type="currency" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ const ReadOnlyFormItem = ({ value, type = "text", onChange }, ref) => {
|
|||||||
if (!value) return null;
|
if (!value) return null;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "text":
|
case "text":
|
||||||
return <div>{value}</div>;
|
return <>{value}</>;
|
||||||
case "currency":
|
case "currency":
|
||||||
return (
|
return <>{Dinero({ amount: Math.round(value * 100) }).toFormat()}</>;
|
||||||
<div>{Dinero({ amount: Math.round(value * 100) }).toFormat()}</div>
|
|
||||||
);
|
|
||||||
default:
|
default:
|
||||||
return <div>{value}</div>;
|
return <>{value}</>;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export default forwardRef(ReadOnlyFormItem);
|
export default forwardRef(ReadOnlyFormItem);
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ export default function JobBillsTotalComponent({
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(totals.parts.parts.total);
|
||||||
|
|
||||||
const totalPartsSublet = Dinero(totals.parts.parts.total)
|
const totalPartsSublet = Dinero(totals.parts.parts.total)
|
||||||
.add(Dinero(totals.parts.sublets.total))
|
.add(Dinero(totals.parts.sublets.total))
|
||||||
.add(Dinero(totals.additional.shipping))
|
.add(Dinero(totals.additional.shipping))
|
||||||
|
|||||||
Reference in New Issue
Block a user