diff --git a/client/cypress/e2e/posting-bills/posting-bills.cy.js b/client/cypress/e2e/posting-bills/posting-bills.cy.js
index 3e3ca29aa..888e482ce 100644
--- a/client/cypress/e2e/posting-bills/posting-bills.cy.js
+++ b/client/cypress/e2e/posting-bills/posting-bills.cy.js
@@ -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", () => {
diff --git a/client/src/components/bill-detail-edit/bill-detail-edit-return.component.jsx b/client/src/components/bill-detail-edit/bill-detail-edit-return.component.jsx
index ebd999269..a4b97cea9 100644
--- a/client/src/components/bill-detail-edit/bill-detail-edit-return.component.jsx
+++ b/client/src/components/bill-detail-edit/bill-detail-edit-return.component.jsx
@@ -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"
>