IO-2327 posting bills test cases

This commit is contained in:
swtmply
2023-08-08 12:44:36 +08:00
parent 6db0947454
commit 2cf4853960
4 changed files with 48 additions and 30 deletions

View File

@@ -1,6 +1,7 @@
import job from "../../fixtures/jobs/job-3.json";
import job2 from "../../fixtures/jobs/job-4.json";
import moment from "moment";
import Dinero from "dinero.js";
const uuid = () => Cypress._.random(0, 1e6);
@@ -250,10 +251,17 @@ describe(
describe.only(
"Validating and calculating bills",
{
defaultCommandTimeout: 5000,
defaultCommandTimeout: 10000,
},
() => {
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(() => {
cy.viewport(1280, 720);
@@ -282,7 +290,7 @@ describe.only(
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
cy.get('[data-cy="part-orders-table"]')
.find(".ant-table-tbody")
@@ -300,7 +308,7 @@ describe.only(
cy.get('[data-cy="bill-form-invoice"]').type(uuid());
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) => {
// get retail amount
@@ -338,22 +346,28 @@ describe.only(
cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
// Click save
// cy.get('[data-cy="bill-form-save-button"]').click();
cy.get('[data-cy="bill-form-save-button"]').click();
cy.get("@retailPrice")
.invoke("val")
.then((val) => {
const discrepancy = linesTotal - Number(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"]')
.find(".ant-table-tbody")
.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-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");
cy.get('[data-cy="billline-actual-price"]')
.find(".ant-form-item-control-input-content")
.invoke("text")
.then((value) => {
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", value);
cy.get("#calculatedcreditsnotreceived").should("have.text", value);
cy.get("#creditsnotreceived").should("have.text", value);
});
});
it("receives credit memo without return part", () => {

View File

@@ -153,6 +153,7 @@ export function BillDetailEditReturn({
// label={t("joblines.fields.actual_price")}
key={`${index}actual_price`}
name={[field.name, "actual_price"]}
data-cy="billline-actual-price"
>
<ReadOnlyFormItemComponent type="currency" />
</Form.Item>

View File

@@ -5,13 +5,11 @@ const ReadOnlyFormItem = ({ value, type = "text", onChange }, ref) => {
if (!value) return null;
switch (type) {
case "text":
return <div>{value}</div>;
return <>{value}</>;
case "currency":
return (
<div>{Dinero({ amount: Math.round(value * 100) }).toFormat()}</div>
);
return <>{Dinero({ amount: Math.round(value * 100) }).toFormat()}</>;
default:
return <div>{value}</div>;
return <>{value}</>;
}
};
export default forwardRef(ReadOnlyFormItem);

View File

@@ -84,6 +84,8 @@ export default function JobBillsTotalComponent({
})
);
console.log(totals.parts.parts.total);
const totalPartsSublet = Dinero(totals.parts.parts.total)
.add(Dinero(totals.parts.sublets.total))
.add(Dinero(totals.additional.shipping))