IO-2327 tax assertion

This commit is contained in:
swtmply
2023-08-05 12:01:35 +08:00
parent e4671b9bd6
commit 59d9087ca7

View File

@@ -1,4 +1,5 @@
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 moment from "moment"; import moment from "moment";
const uuid = () => Cypress._.random(0, 1e6); const uuid = () => Cypress._.random(0, 1e6);
@@ -246,202 +247,242 @@ describe(
} }
); );
// describe( describe.only(
// "Validating and calculating bills", "Validating and calculating bills",
// { {
// defaultCommandTimeout: 5000, defaultCommandTimeout: 5000,
// }, },
// () => { () => {
// beforeEach(() => { const today = moment(new Date()).format("YYYY-MM-DD");
// cy.visit("/manage");
// cy.get("body").then(($body) => { beforeEach(() => {
// if ($body.text().includes("Login")) { cy.viewport(1280, 720);
// // Log in cy.visit("/manage/jobs");
// 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") cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
// .should("be.visible") if (req.body.operationName === "SEARCH_VENDOR_AUTOCOMPLETE") {
// .find("tr") req.alias = "vendors";
// .should("not.have.class", "ant-table-placeholder"); }
});
// cy.get(".ant-table-row").contains("QBD261").click(); cy.get('[data-cy="active-jobs-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("active-jobs-table")
.should("not.have.class", "ant-table-placeholder");
// cy.url().should("include", "/manage/jobs"); cy.get("@active-jobs-table")
.contains(job2.clm_no)
.first()
.parent()
.find('[data-cy="active-job-link"]')
.click();
// // Go to repair data tab // Go to repair data tab
// cy.get('[data-cy="tab-partssublet"]').should("be.visible").click(); cy.get('[data-cy="tab-partssublet"]').should("be.visible").click();
// }); });
// });
// it("validates auto reconciliation through posting bill", () => { it.only("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")
// .find("> tr:not(.ant-table-measure-row)") .find("> tr:not(.ant-table-measure-row)")
// .as("orders-table") .as("orders-table")
// .should("not.have.class", "ant-table-placeholder"); .should("not.have.class", "ant-table-placeholder");
// cy.get("@orders-table") cy.get("@orders-table")
// .first() .first()
// .should("be.visible") .should("be.visible")
// .find('[data-cy="receive-bill-button"]') .find('[data-cy="receive-bill-button"]')
// .click(); .click();
// // fill out form // fill out form
// cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-0")); cy.get('[data-cy="bill-form-invoice"]').type(uuid());
// cy.get("#bill-form-date").click(); cy.get("#bill-form-date").click();
// cy.get('[title="2023-07-06"]').should("be.visible").click(); cy.get(`[title="${today}"]`).should("be.visible").click();
// cy.get('[data-cy="bill-form-bill-total"]').type("70.46"); cy.get('[data-cy="bill-line-table"]').each(($row) => {
// cy.get('[data-cy="bill-line-actual-cost"]').type("67.10"); // get retail amount
cy.wrap($row)
.find('[data-cy="bill-line-actual-price"]')
.as("retailPrice")
.click({ force: true, multiple: true });
cy.wrap($row)
.find('[data-cy="bill-line-actual-cost"]')
.click({ multiple: true });
});
// cy.get("#bill-form-discrepancy").should("have.text", "$0.00"); cy.get('[data-cy="bill-line-actual-cost"]').then((cells) => {
const totals = cells.toArray().map((el) => Number(el.value));
const sum = Cypress._.sum(totals);
// // Click save cy.get('[data-cy="bill-form-bill-total"]').type(sum);
// cy.get('[data-cy="bill-form-save-button"]').click();
// cy.get("#retailtotal").should("have.text", "$83.87"); // Get taxes add it to the sum
cy.get('[data-cy="bill-form-tax"]').then((taxes) => {
const subtotals = taxes
.toArray()
.map((el) => Number(el.innerText.substring(1)));
const totalTax = Cypress._.sum(subtotals);
// cy.get(".discrepancy").each(($statistic) => { const billAmount = sum + totalTax;
// cy.wrap($statistic).should("have.text", "$0.00");
// });
// });
// it("returning item and validating statistics", () => { cy.get('[data-cy="bill-form-bill-total"]')
// cy.get('[data-cy="bills-table"]') .find("input")
// .find(".ant-table-tbody") .clear()
// .find("> tr:not(.ant-table-measure-row)") .type(billAmount);
// .as("bills-table") });
// .should("not.have.class", "ant-table-placeholder"); });
// cy.get("@bills-table") cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
// .first()
// .should("not.be.disabled")
// .find('[data-cy="return-items-button"]')
// .click();
// cy.get('[data-cy="billline-checkbox"]').check(); // Click save
// cy.get('[data-cy="billline-return-items-ok-button"]').click(); // cy.get('[data-cy="bill-form-save-button"]').click();
// cy.get("#order-quantity").type("1", { force: true, multiple: true }); cy.get("@retailPrice")
// cy.get('[data-cy="part-order-select-none"]').click({ .invoke("val")
// multiple: true, .then((val) => {
// force: true, cy.get("#retailtotal").should("have.text", `$${val}`);
// }); });
// cy.get('[data-cy="order-part-submit"]').click({
// multiple: true,
// force: true,
// });
// cy.get("#totalReturns").should("have.text", "$83.87"); // TODO get total of discrepancy
// cy.get("#calculatedcreditsnotreceived").should("have.text", "$83.87");
// cy.get("#creditsnotreceived").should("have.text", "$83.87");
// });
// it("receives credit memo without return part", () => { // cy.get(".discrepancy").each(($statistic) => {
// // Find the first row in the parts order // cy.wrap($statistic).should("have.text", "$0.00");
// 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") it("returning item and validating statistics", () => {
// .find('[data-cy="part-order-return-checkbox"]') cy.get('[data-cy="bills-table"]')
// .filter(":checked") .find(".ant-table-tbody")
// .first() .find("> tr:not(.ant-table-measure-row)")
// .parent() .as("bills-table")
// .parent() .should("not.have.class", "ant-table-placeholder");
// .parent()
// .parent()
// .find('[data-cy="receive-bill-button"]')
// .click();
// // fill out form cy.get("@bills-table")
// cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-01-")); .first()
.should("not.be.disabled")
.find('[data-cy="return-items-button"]')
.click();
// cy.get("#bill-form-date").click(); cy.get('[data-cy="billline-checkbox"]').check();
// cy.get('[title="2023-07-06"]').should("be.visible").click(); cy.get('[data-cy="billline-return-items-ok-button"]').click();
// cy.get('[data-cy="bill-form-bill-total"]').type("70.46"); cy.get("#order-quantity").type("1", { force: true, multiple: true });
// cy.get('[data-cy="bill-line-actual-cost"]').type("67.10"); 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("#bill-form-discrepancy").should("have.text", "$0.00"); cy.get("#totalReturns").should("have.text", "$83.87");
cy.get("#calculatedcreditsnotreceived").should("have.text", "$83.87");
cy.get("#creditsnotreceived").should("have.text", "$83.87");
});
// // Click save it("receives credit memo without return part", () => {
// cy.get('[data-cy="bill-form-save-button"]').click(); // 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("#totalReturns").should("have.text", "$83.87"); cy.get("@orders-table")
// cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00"); .find('[data-cy="part-order-return-checkbox"]')
// cy.get("#creditsnotreceived").should("have.text", "$83.87"); .filter(":checked")
// }); .first()
.parent()
.parent()
.parent()
.parent()
.find('[data-cy="receive-bill-button"]')
.click();
// it("receives credit memo with return part", () => { // fill out form
// // Find the first row in the parts order cy.get('[data-cy="bill-form-invoice"]').type(uuid());
// 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") cy.get("#bill-form-date").click();
// .find('[data-cy="part-order-return-checkbox"]') cy.get('[title="2023-07-06"]').should("be.visible").click();
// .filter(":checked")
// .first()
// .parent()
// .parent()
// .parent()
// .parent()
// .find('[data-cy="receive-bill-button"]')
// .click();
// // fill out form cy.get('[data-cy="bill-form-bill-total"]').type("70.46");
// cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-02-")); cy.get('[data-cy="bill-line-actual-cost"]').type("67.10");
// cy.get("#bill-form-date").click(); cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
// cy.get('[title="2023-07-06"]').should("be.visible").click();
// cy.get('[data-cy="bill-form-bill-total"]').type("70.46"); // Click save
// cy.get('[data-cy="bill-line-actual-cost"]').type("67.10"); cy.get('[data-cy="bill-form-save-button"]').click();
// cy.get("#bill-form-discrepancy").should("have.text", "$0.00"); cy.get("#totalReturns").should("have.text", "$83.87");
cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00");
cy.get("#creditsnotreceived").should("have.text", "$83.87");
});
// cy.get('[data-cy="mark-as-received-checkbox"]').check(); 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");
// // Click save cy.get("@orders-table")
// cy.get('[data-cy="bill-form-save-button"]').click(); .find('[data-cy="part-order-return-checkbox"]')
.filter(":checked")
.first()
.parent()
.parent()
.parent()
.parent()
.find('[data-cy="receive-bill-button"]')
.click();
// cy.get("#totalReturns").should("have.text", "$83.87"); // fill out form
// cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00"); cy.get('[data-cy="bill-form-invoice"]').type(uuid());
// cy.get("#creditsnotreceived").should("have.text", "$0.00");
// });
// it("views the row expander if it has the order and bill", () => { cy.get("#bill-form-date").click();
// cy.get('[data-cy="tab-repairdata"]').should("be.visible").click(); cy.get('[title="2023-07-06"]').should("be.visible").click();
// cy.get('[data-cy="filter-parts-button"]') cy.get('[data-cy="bill-form-bill-total"]').type("70.46");
// .should("not.be.disabled") cy.get('[data-cy="bill-line-actual-cost"]').type("67.10");
// .click();
// cy.get('[data-cy="repair-data-table"]') cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
// .find(".ant-table-tbody")
// .find("> tr:not(.ant-table-measure-row)")
// .first()
// .next()
// .find("td")
// .first()
// .click();
// cy.get('[data-cy="parts-bills-order"]') cy.get('[data-cy="mark-as-received-checkbox"]').check();
// .should("be.visible")
// .find("li") // Click save
// .first() cy.get('[data-cy="bill-form-save-button"]').click();
// .should("not.have.text", "This part has not yet been ordered.");
// }); 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.");
});
}
);