| 1 |
import { test, expect } from "@odoo/hoot"; |
| 2 |
import { expectFormattedPrice, setupPosEnv } from "../utils"; |
| 3 |
import { definePosModels } from "../data/generate_model_definitions"; |
| 4 |
import { getFilledOrderForPriceCheck } from "./utils"; |
| 5 |
|
| 6 |
definePosModels(); |
| 7 |
|
| 8 |
test("Prices includes", async () => { |
| 9 |
const store = await setupPosEnv(); |
| 10 |
const order = await getFilledOrderForPriceCheck(store); |
| 11 |
const details = order.prices.taxDetails; |
| 12 |
const line1 = order.lines[0].prices; |
| 13 |
const line2 = order.lines[1].prices; |
| 14 |
|
| 15 |
// Order prices |
| 16 |
expect(details.base_amount).toBe(1100); |
| 17 |
expect(details.tax_amount).toBe(290); |
| 18 |
expect(details.total_amount).toBe(1390); |
| 19 |
|
| 20 |
// First line (25% on 1000) |
| 21 |
expect(line1.total_included).toBe(1250); |
| 22 |
expect(line1.total_excluded).toBe(1000); |
| 23 |
expect(line1.taxes_data[0].tax_amount).toBe(250); |
| 24 |
expect(line1.taxes_data[0].tax.amount).toBe(25); |
| 25 |
|
| 26 |
// Second line (15% + 25% on 100) |
| 27 |
expect(line2.total_included).toBe(140); |
| 28 |
expect(line2.total_excluded).toBe(100); |
| 29 |
expect(line2.taxes_data[0].tax_amount).toBe(15); |
| 30 |
expect(line2.taxes_data[0].tax.amount).toBe(15); |
| 31 |
expect(line2.taxes_data[1].tax_amount).toBe(25); |
| 32 |
expect(line2.taxes_data[1].tax.amount).toBe(25); |
| 33 |
|
| 34 |
// Formatted prices |
| 35 |
expectFormattedPrice(order.currencyDisplayPrice, "$ 1,390.00"); |
| 36 |
expectFormattedPrice(order.currencyAmountTaxes, "$ 290.00"); |
| 37 |
expectFormattedPrice(order.lines[0].currencyDisplayPrice, "$ 1,250.00"); |
| 38 |
expectFormattedPrice(order.lines[0].currencyDisplayPriceUnit, "$ 1,250.00"); |
| 39 |
expectFormattedPrice(order.lines[0].currencyDisplayPriceUnitExcl, "$ 1,000.00"); |
| 40 |
expectFormattedPrice(order.lines[1].currencyDisplayPrice, "$ 140.00"); |
| 41 |
expectFormattedPrice(order.lines[1].currencyDisplayPriceUnit, "$ 140.00"); |
| 42 |
expectFormattedPrice(order.lines[1].currencyDisplayPriceUnitExcl, "$ 100.00"); |
| 43 |
}); |
| 44 |
|
| 45 |
test("Prices excludes", async () => { |
| 46 |
const store = await setupPosEnv(); |
| 47 |
store.config.iface_tax_included = "subtotal"; |
| 48 |
const order = await getFilledOrderForPriceCheck(store); |
| 49 |
|
| 50 |
// Formatted prices |
| 51 |
expectFormattedPrice(order.currencyDisplayPrice, "$ 1,100.00"); |
| 52 |
expectFormattedPrice(order.lines[0].currencyDisplayPrice, "$ 1,000.00"); |
| 53 |
expectFormattedPrice(order.lines[0].currencyDisplayPriceUnit, "$ 1,000.00"); |
| 54 |
expectFormattedPrice(order.lines[1].currencyDisplayPrice, "$ 100.00"); |
| 55 |
expectFormattedPrice(order.lines[1].currencyDisplayPriceUnit, "$ 100.00"); |
| 56 |
}); |