IO-2327 posting bills test cases
This commit is contained in:
@@ -367,7 +367,7 @@ describe.only(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
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)")
|
||||||
@@ -375,8 +375,14 @@ describe.only(
|
|||||||
.should("not.have.class", "ant-table-placeholder");
|
.should("not.have.class", "ant-table-placeholder");
|
||||||
|
|
||||||
cy.get("@bills-table")
|
cy.get("@bills-table")
|
||||||
|
.find('[data-cy="credit-memo-checkbox"]')
|
||||||
|
.filter(":not(:checked)")
|
||||||
.first()
|
.first()
|
||||||
.should("not.be.disabled")
|
.should("not.be.disabled")
|
||||||
|
.parent()
|
||||||
|
.parent()
|
||||||
|
.parent()
|
||||||
|
.parent()
|
||||||
.find('[data-cy="return-items-button"]')
|
.find('[data-cy="return-items-button"]')
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
@@ -384,20 +390,26 @@ describe.only(
|
|||||||
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('[data-cy="billline-actual-price"]')
|
||||||
.find(".ant-form-item-control-input-content")
|
.find(".ant-form-item-control-input-content")
|
||||||
.invoke("text")
|
.then((prices) => {
|
||||||
.then((value) => {
|
const totals = prices
|
||||||
cy.get("#order-quantity").type("1", { force: true, multiple: true });
|
.toArray()
|
||||||
cy.get('[data-cy="part-order-select-none"]').click({
|
.map((el) => Number(el.innerText.substring(1)));
|
||||||
multiple: true,
|
const sum = Cypress._.sum(totals);
|
||||||
force: true,
|
|
||||||
|
const price = Dinero({
|
||||||
|
amount: sum * 100,
|
||||||
|
}).toFormat();
|
||||||
|
|
||||||
|
cy.get('[data-cy="order-quantity"]').each((input) => {
|
||||||
|
cy.wrap(input).type("1");
|
||||||
});
|
});
|
||||||
cy.get('[data-cy="order-part-submit"]').click({
|
cy.get('[data-cy="part-order-select-none"]').click();
|
||||||
multiple: true,
|
|
||||||
force: true,
|
cy.get('[data-cy="order-part-submit"]').click();
|
||||||
});
|
|
||||||
cy.get("#totalReturns").should("have.text", value);
|
cy.get("#totalReturns").should("have.text", price);
|
||||||
cy.get("#calculatedcreditsnotreceived").should("have.text", value);
|
cy.get("#calculatedcreditsnotreceived").should("have.text", price);
|
||||||
cy.get("#creditsnotreceived").should("have.text", value);
|
cy.get("#creditsnotreceived").should("have.text", price);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -437,36 +449,57 @@ describe.only(
|
|||||||
});
|
});
|
||||||
|
|
||||||
cy.get('[data-cy="bill-line-actual-cost"]').then((cells) => {
|
cy.get('[data-cy="bill-line-actual-cost"]').then((cells) => {
|
||||||
const totals = cells.toArray().map((el) => Number(el.value));
|
cy.get('[data-cy="bill-line-actual-price"]').then((priceCells) => {
|
||||||
const sum = Cypress._.sum(totals);
|
const totals = cells.toArray().map((el) => Number(el.value));
|
||||||
|
const priceTotals = priceCells
|
||||||
cy.get('[data-cy="bill-form-bill-total"]').type(sum);
|
|
||||||
|
|
||||||
// Get taxes add it to the sum
|
|
||||||
cy.get('[data-cy="bill-form-tax"]').then((taxes) => {
|
|
||||||
const subtotals = taxes
|
|
||||||
.toArray()
|
.toArray()
|
||||||
.map((el) => Number(el.innerText.substring(1)));
|
.map((el) => Number(el.value));
|
||||||
const totalTax = Cypress._.sum(subtotals);
|
const sum = Cypress._.sum(totals);
|
||||||
|
const priceSum = Cypress._.sum(priceTotals);
|
||||||
|
|
||||||
const billAmount = sum + totalTax;
|
cy.get('[data-cy="bill-form-bill-total"]').type(sum);
|
||||||
|
|
||||||
cy.get('[data-cy="bill-form-bill-total"]')
|
// Get taxes add it to the sum
|
||||||
.find("input")
|
cy.get('[data-cy="bill-form-tax"]').then((taxes) => {
|
||||||
.clear()
|
const subtotals = taxes
|
||||||
.type(billAmount);
|
.toArray()
|
||||||
|
.map((el) => Number(el.innerText.substring(1)));
|
||||||
|
const totalTax = Cypress._.sum(subtotals);
|
||||||
|
|
||||||
|
const billAmount = sum + totalTax;
|
||||||
|
|
||||||
|
cy.get('[data-cy="bill-form-bill-total"]')
|
||||||
|
.find("input")
|
||||||
|
.clear()
|
||||||
|
.type(billAmount);
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
|
||||||
|
|
||||||
|
cy.get('[data-cy="bill-form-save-button"]').click();
|
||||||
|
|
||||||
|
cy.get("#totalReturns")
|
||||||
|
.invoke("text")
|
||||||
|
.then((value) => {
|
||||||
|
// TODO check if negative transform to 0
|
||||||
|
const totalReturns =
|
||||||
|
Number(value.substring(1)) - priceSum < 0
|
||||||
|
? 0
|
||||||
|
: Number(value.substring(1)) - priceSum;
|
||||||
|
|
||||||
|
cy.get("#calculatedcreditsnotreceived").should(
|
||||||
|
"have.text",
|
||||||
|
Dinero({
|
||||||
|
amount: totalReturns,
|
||||||
|
precision: 0,
|
||||||
|
}).toFormat()
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
cy.get("#bill-form-discrepancy").should("have.text", "$0.00");
|
|
||||||
|
|
||||||
cy.get('[data-cy="bill-form-save-button"]').click();
|
|
||||||
|
|
||||||
// TODO add other totals to assert the posted CNR
|
|
||||||
cy.get("#calculatedcreditsnotreceived").should("have.text", "$0.00");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it.only("receives credit memo with return part", () => {
|
it("receives credit memo with return part", () => {
|
||||||
// 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")
|
||||||
|
|||||||
Reference in New Issue
Block a user