[REF] point_of_sale,*: redefine format_currency{_no_symbol} using web's formatMonetary
*: l10n_ae_pos,l10n_fr_pos_cert,l10n_gcc_pos,pos_loyalty,pos_restaurant,
pos_sale,pos_sale_product_configurator
This commit is the start of a series of changes in the definitions of formatters
and rounders used in pos. We are introducing a new service called
`contextual_utils_service` that loads when the `pos` service is ready making
sure the currency is loaded. In this service, we define `formatCurrency`
(potentially others) which is the replacement to `format_currency{_no_symbol}`.
Also, instead of defining our own formatter, we are depending on web's
`formatMonetary`.
In this commit, we are replacing all uses of `format_currency{_no_symbol}` with
`formatCurrency` that's based on web's `formatMonetary`.
Part-of: odoo/odoo#120317
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<div id='post_receipt_taxes_container'>
|
||||
<t t-if="env.pos.company.country.code == 'AE'">VAT</t>
|
||||
<t t-else="">Total Taxes</t>
|
||||
<span t-esc="env.pos.format_currency(receipt.total_tax)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.total_tax)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
Old unit price:
|
||||
<span class="oldPrice">
|
||||
<s>
|
||||
<t t-out="env.pos.format_currency(line.taxed_lst_unit_price, 'Product Price')" /> / Units
|
||||
<t t-out="env.utils.formatCurrency(line.taxed_lst_unit_price)" /> / Units
|
||||
</s>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
Old unit price:
|
||||
<span class="oldPrice">
|
||||
<s>
|
||||
<t t-out="env.pos.format_currency(props.line.get_taxed_lst_unit_price(),'Product Price')" /> / Units
|
||||
<t t-out="env.utils.formatCurrency(props.line.get_taxed_lst_unit_price())" /> / Units
|
||||
</s>
|
||||
</span>
|
||||
</li>
|
||||
|
||||
@@ -24,73 +24,73 @@
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.subtotal)']/.." position="attributes">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.subtotal)']/.." position="attributes">
|
||||
<attribute name="t-if">!receipt.is_gcc_country</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.subtotal)']/.." position="after">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.subtotal)']/.." position="after">
|
||||
<div t-if="receipt.is_gcc_country" t-translation="off">
|
||||
Subtotal / الإجمالي الفرعي
|
||||
<span t-esc="env.pos.format_currency(receipt.subtotal)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.subtotal)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.total_with_tax)']/.." position="attributes">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.total_with_tax)']/.." position="attributes">
|
||||
<attribute name="t-if">!receipt.is_gcc_country</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.total_with_tax)']/.." position="after">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.total_with_tax)']/.." position="after">
|
||||
<div t-if="receipt.is_gcc_country" class="pos-receipt-amount pos-receipt-amount-arabic" t-translation="off">
|
||||
TOTAL / الإجمالي
|
||||
<span t-esc="env.pos.format_currency(receipt.total_with_tax)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.total_with_tax)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.rounding_applied)']/.." position="attributes">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.rounding_applied)']/.." position="attributes">
|
||||
<attribute name="t-if">!receipt.is_gcc_country</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.rounding_applied)']/.." position="after">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.rounding_applied)']/.." position="after">
|
||||
<div t-if="receipt.is_gcc_country" class="pos-receipt-amount pos-receipt-amount-arabic" t-translation="off">
|
||||
Rounding / التقريب
|
||||
<span t-esc="env.pos.format_currency(receipt.rounding_applied)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.rounding_applied)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.total_rounded)']/.." position="attributes">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.total_rounded)']/.." position="attributes">
|
||||
<attribute name="t-if">!receipt.is_gcc_country</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.total_rounded)']/.." position="after">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.total_rounded)']/.." position="after">
|
||||
<div t-if="receipt.is_gcc_country" class="pos-receipt-amount pos-receipt-amount-arabic" t-translation="off">
|
||||
To Pay / للسداد
|
||||
<span t-esc="env.pos.format_currency(receipt.total_rounded)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.total_rounded)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.change)']/.." position="attributes">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.change)']/.." position="attributes">
|
||||
<attribute name="t-if">!receipt.is_gcc_country</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.change)']/.." position="after">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.change)']/.." position="after">
|
||||
<div t-if="receipt.is_gcc_country" class="pos-receipt-amount receipt-change pos-receipt-amount-arabic" t-translation="off">
|
||||
CHANGE / الباقي
|
||||
<span t-esc="env.pos.format_currency(receipt.change)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.change)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.total_discount)']/.." position="attributes">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.total_discount)']/.." position="attributes">
|
||||
<attribute name="t-if">!receipt.is_gcc_country</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.total_discount)']/.." position="after">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.total_discount)']/.." position="after">
|
||||
<div t-if="receipt.is_gcc_country" t-translation="off">
|
||||
Discounts / الخصومات
|
||||
<span t-esc="env.pos.format_currency(receipt.total_discount)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.total_discount)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.total_tax)']/.." position="attributes">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.total_tax)']/.." position="attributes">
|
||||
<attribute name="t-if">!receipt.is_gcc_country</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//span[@t-esc='env.pos.format_currency(receipt.total_tax)']/.." position="after">
|
||||
<xpath expr="//span[@t-esc='env.utils.formatCurrency(receipt.total_tax)']/.." position="after">
|
||||
<div t-if="receipt.is_gcc_country" t-translation="off">
|
||||
Total Taxes / إجمالي الضرائب
|
||||
<span t-esc="env.pos.format_currency(receipt.total_tax)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.total_tax)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</t>
|
||||
@@ -102,9 +102,9 @@
|
||||
<xpath expr="//t[@t-if='isSimple(line)']/WrappedProductNameLines" position="after">
|
||||
<div class="responsive-price" t-if="receipt.is_gcc_country">
|
||||
<div class="pos-receipt-left-padding" style="display: inline-flex;">
|
||||
<div t-translation="off">Taxes / الضرائب</div>:<span t-esc="env.pos.format_currency_no_symbol(line.tax)" style="margin-left: 5px"/>
|
||||
<div t-translation="off">Taxes / الضرائب</div>:<span t-esc="env.utils.formatCurrency(line.tax, false)" style="margin-left: 5px"/>
|
||||
</div>
|
||||
<span t-esc="env.pos.format_currency_no_symbol(line.price_display)" class="price_display pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(line.price_display, false)" class="price_display pos-receipt-right-align"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
@@ -117,13 +117,13 @@
|
||||
<t t-esc="Math.round(line.quantity * Math.pow(10, env.pos.dp['Product Unit of Measure'])) / Math.pow(10, env.pos.dp['Product Unit of Measure'])"/>
|
||||
<t t-if="!line.is_in_unit" t-esc="line.unit_name" />
|
||||
x
|
||||
<t t-esc="env.pos.format_currency_no_symbol(line.price_display_one)" />
|
||||
<t t-esc="env.utils.formatCurrency(line.price_display_one, false)" />
|
||||
</div>
|
||||
<div class="responsive-price">
|
||||
<div class="pos-receipt-left-padding" style="display: inline-flex;">
|
||||
<div t-translation="off">Taxes / الضرائب</div>:<span t-esc="env.pos.format_currency_no_symbol(line.tax)" style="margin-left: 5px"/>
|
||||
<div t-translation="off">Taxes / الضرائب</div>:<span t-esc="env.utils.formatCurrency(line.tax, false)" style="margin-left: 5px"/>
|
||||
</div>
|
||||
<span t-esc="env.pos.format_currency_no_symbol(line.price_display)" class="price_display pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(line.price_display, false)" class="price_display pos-receipt-right-align"/>
|
||||
</div>
|
||||
</t>
|
||||
</xpath>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { formatMonetary } from "@web/views/fields/formatters";
|
||||
import { registry } from "@web/core/registry";
|
||||
|
||||
/**
|
||||
* This service introduces `utils` namespace in the `env` which can contain
|
||||
* functions that are parameterized by the data in `pos` service.
|
||||
*/
|
||||
export const contextualUtilsService = {
|
||||
dependencies: ["pos"],
|
||||
start(env, { pos }) {
|
||||
const currency = pos.globalState.currency;
|
||||
|
||||
const formatCurrency = (value, hasSymbol = true) => {
|
||||
return formatMonetary(value, {
|
||||
currencyId: currency.id,
|
||||
noSymbol: !hasSymbol,
|
||||
});
|
||||
};
|
||||
|
||||
env.utils = {
|
||||
formatCurrency,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
registry.category("services").add("contextual_utils_service", contextualUtilsService);
|
||||
@@ -45,7 +45,7 @@ export class CashMovePopup extends AbstractAwaitablePopup {
|
||||
this.state.errorMessage = this.env._t("Insert a positive amount");
|
||||
return;
|
||||
}
|
||||
const formattedAmount = this.pos.globalState.format_currency(amount);
|
||||
const formattedAmount = this.env.utils.formatCurrency(amount);
|
||||
if (!amount) {
|
||||
this.notification.add(
|
||||
sprintf(_t("Cash in/out of %s is ignored."), formattedAmount),
|
||||
|
||||
@@ -29,6 +29,7 @@ export class SaleDetailsButton extends Component {
|
||||
Object.assign({}, saleDetails, {
|
||||
date: new Date().toLocaleString(),
|
||||
pos: this.env.pos,
|
||||
formatCurrency: this.env.utils.formatCurrency,
|
||||
})
|
||||
);
|
||||
const { successful, message } = await this.hardwareProxy.printer.printReceipt(report);
|
||||
|
||||
@@ -15,7 +15,7 @@ export class MobileOrderWidget extends Component {
|
||||
}
|
||||
get total() {
|
||||
const _total = this.order ? this.order.get_total_with_tax() : 0;
|
||||
return this.env.pos.format_currency(_total);
|
||||
return this.env.utils.formatCurrency(_total);
|
||||
}
|
||||
get items_number() {
|
||||
return this.order
|
||||
|
||||
@@ -57,7 +57,7 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
|
||||
"The maximum difference allowed is %s.\n\
|
||||
Please contact your manager to accept the closing difference."
|
||||
),
|
||||
this.pos.globalState.format_currency(this.amountAuthorizedDiff)
|
||||
this.env.utils.formatCurrency(this.amountAuthorizedDiff)
|
||||
),
|
||||
confirmText: this.env._t("OK"),
|
||||
});
|
||||
@@ -80,7 +80,7 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
|
||||
const { total, moneyDetailsNotes, moneyDetails } = payload;
|
||||
this.state.payments[this.defaultCashDetails.id].counted = total;
|
||||
this.state.payments[this.defaultCashDetails.id].difference =
|
||||
this.pos.globalState.round_decimals_currency(
|
||||
this.env.utils.roundCurrency(
|
||||
this.state.payments[[this.defaultCashDetails.id]].counted -
|
||||
this.defaultCashDetails.amount
|
||||
);
|
||||
@@ -106,7 +106,7 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
|
||||
} else {
|
||||
expectedAmount = this.otherPaymentMethods.find((pm) => paymentId === pm.id).amount;
|
||||
}
|
||||
this.state.payments[paymentId].difference = this.pos.globalState.round_decimals_currency(
|
||||
this.state.payments[paymentId].difference = this.env.utils.roundCurrency(
|
||||
this.state.payments[paymentId].counted - expectedAmount
|
||||
);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export class MoneyDetailsPopup extends AbstractAwaitablePopup {
|
||||
if (this.state.moneyDetails[bill.value]) {
|
||||
moneyDetailsNotes += ` - ${
|
||||
this.state.moneyDetails[bill.value]
|
||||
} x ${this.pos.globalState.format_currency(bill.value)}\n`;
|
||||
} x ${this.env.utils.formatCurrency(bill.value)}\n`;
|
||||
}
|
||||
});
|
||||
return {
|
||||
|
||||
@@ -430,11 +430,11 @@ export class PaymentScreen extends Component {
|
||||
body:
|
||||
this.env._t("Are you sure that the customer wants to pay") +
|
||||
" " +
|
||||
this.env.pos.format_currency(this.currentOrder.get_total_paid()) +
|
||||
this.env.utils.formatCurrency(this.currentOrder.get_total_paid()) +
|
||||
" " +
|
||||
this.env._t("for an order of") +
|
||||
" " +
|
||||
this.env.pos.format_currency(this.currentOrder.get_total_with_tax()) +
|
||||
this.env.utils.formatCurrency(this.currentOrder.get_total_with_tax()) +
|
||||
" " +
|
||||
this.env._t('? Clicking "Confirm" will validate the payment.'),
|
||||
})
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ export class PaymentScreenPaymentLines extends Component {
|
||||
static template = "PaymentScreenPaymentLines";
|
||||
|
||||
formatLineAmount(paymentline) {
|
||||
return this.env.pos.format_currency_no_symbol(paymentline.get_amount());
|
||||
return this.env.utils.formatCurrency(paymentline.get_amount(), false);
|
||||
}
|
||||
selectedLineClass(line) {
|
||||
return { "payment-terminal": line.get_payment_status() };
|
||||
|
||||
@@ -6,15 +6,15 @@ export class PaymentScreenStatus extends Component {
|
||||
static template = "PaymentScreenStatus";
|
||||
|
||||
get changeText() {
|
||||
return this.env.pos.format_currency(this.props.order.get_change());
|
||||
return this.env.utils.formatCurrency(this.props.order.get_change());
|
||||
}
|
||||
get totalDueText() {
|
||||
return this.env.pos.format_currency(
|
||||
return this.env.utils.formatCurrency(
|
||||
this.props.order.get_total_with_tax() + this.props.order.get_rounding_applied()
|
||||
);
|
||||
}
|
||||
get remainingText() {
|
||||
return this.env.pos.format_currency(
|
||||
return this.env.utils.formatCurrency(
|
||||
this.props.order.get_due() > 0 ? this.props.order.get_due() : 0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export class OrderSummary extends Component {
|
||||
static template = "OrderSummary";
|
||||
|
||||
getTotal() {
|
||||
return this.env.pos.format_currency(this.props.order.get_total_with_tax());
|
||||
return this.env.utils.formatCurrency(this.props.order.get_total_with_tax());
|
||||
}
|
||||
getTax() {
|
||||
const total = this.props.order.get_total_with_tax();
|
||||
@@ -15,7 +15,7 @@ export class OrderSummary extends Component {
|
||||
const taxAmount = total - totalWithoutTax;
|
||||
return {
|
||||
hasTax: !floatIsZero(taxAmount, this.env.pos.currency.decimal_places),
|
||||
displayAmount: this.env.pos.format_currency(taxAmount),
|
||||
displayAmount: this.env.utils.formatCurrency(taxAmount),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,8 @@ export class ProductItem extends Component {
|
||||
return this.env.pos.default_pricelist;
|
||||
}
|
||||
get price() {
|
||||
const formattedUnitPrice = this.env.pos.format_currency(
|
||||
this.props.product.get_display_price(this.pricelist, 1),
|
||||
"Product Price"
|
||||
const formattedUnitPrice = this.env.utils.formatCurrency(
|
||||
this.props.product.get_display_price(this.pricelist, 1)
|
||||
);
|
||||
if (this.props.product.to_weight) {
|
||||
return `${formattedUnitPrice}/${
|
||||
|
||||
@@ -98,11 +98,11 @@ export class ReceiptScreen extends AbstractReceiptScreen {
|
||||
.get_orderlines()
|
||||
.find((line) => tip_product_id && line.product.id === tip_product_id);
|
||||
const tipAmount = tipLine ? tipLine.get_all_prices().priceWithTax : 0;
|
||||
const orderAmountStr = this.env.pos.format_currency(orderTotalAmount - tipAmount);
|
||||
const orderAmountStr = this.env.utils.formatCurrency(orderTotalAmount - tipAmount);
|
||||
if (!tipAmount) {
|
||||
return orderAmountStr;
|
||||
}
|
||||
const tipAmountStr = this.env.pos.format_currency(tipAmount);
|
||||
const tipAmountStr = this.env.utils.formatCurrency(tipAmount);
|
||||
return `${orderAmountStr} + ${tipAmountStr} tip`;
|
||||
}
|
||||
get nextScreen() {
|
||||
|
||||
@@ -83,7 +83,7 @@ export class ScaleScreen extends Component {
|
||||
return weightstr;
|
||||
}
|
||||
get computedPriceString() {
|
||||
return this.env.pos.format_currency(this.productPrice * this.state.weight);
|
||||
return this.env.utils.formatCurrency(this.productPrice * this.state.weight);
|
||||
}
|
||||
get productPrice() {
|
||||
const product = this.props.product;
|
||||
|
||||
@@ -17,9 +17,9 @@ export class OrderDetails extends Component {
|
||||
return this.order ? this.order.orderlines : [];
|
||||
}
|
||||
get total() {
|
||||
return this.env.pos.format_currency(this.order ? this.order.get_total_with_tax() : 0);
|
||||
return this.env.utils.formatCurrency(this.order ? this.order.get_total_with_tax() : 0);
|
||||
}
|
||||
get tax() {
|
||||
return this.env.pos.format_currency(this.order ? this.order.get_total_tax() : 0);
|
||||
return this.env.utils.formatCurrency(this.order ? this.order.get_total_tax() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ export class OrderlineDetails extends Component {
|
||||
return this.line.productName;
|
||||
}
|
||||
get totalPrice() {
|
||||
return this.env.pos.format_currency(this.line.totalPrice);
|
||||
return this.env.utils.formatCurrency(this.line.totalPrice);
|
||||
}
|
||||
get quantity() {
|
||||
return this.line.quantity;
|
||||
}
|
||||
get unitPrice() {
|
||||
return this.env.pos.format_currency(this.line.unitPrice);
|
||||
return this.env.utils.formatCurrency(this.line.unitPrice);
|
||||
}
|
||||
get unit() {
|
||||
return this.line.unit;
|
||||
|
||||
@@ -334,7 +334,7 @@ export class TicketScreen extends IndependentToOrderScreen {
|
||||
return moment(order.validation_date).format("YYYY-MM-DD hh:mm A");
|
||||
}
|
||||
getTotal(order) {
|
||||
return this.env.pos.format_currency(order.get_total_with_tax());
|
||||
return this.env.utils.formatCurrency(order.get_total_with_tax());
|
||||
}
|
||||
getPartner(order) {
|
||||
return order.get_partner_name();
|
||||
|
||||
@@ -837,14 +837,14 @@ export class PosGlobalState extends PosModel {
|
||||
const orderCost = order.get_total_cost();
|
||||
const orderMargin = orderPriceWithoutTax - orderCost;
|
||||
|
||||
const costCurrency = this.format_currency(product.standard_price);
|
||||
const marginCurrency = this.format_currency(margin);
|
||||
const costCurrency = this.env.utils.formatCurrency(product.standard_price);
|
||||
const marginCurrency = this.env.utils.formatCurrency(margin);
|
||||
const marginPercent = priceWithoutTax
|
||||
? Math.round((margin / priceWithoutTax) * 10000) / 100
|
||||
: 0;
|
||||
const orderPriceWithoutTaxCurrency = this.format_currency(orderPriceWithoutTax);
|
||||
const orderCostCurrency = this.format_currency(orderCost);
|
||||
const orderMarginCurrency = this.format_currency(orderMargin);
|
||||
const orderPriceWithoutTaxCurrency = this.env.utils.formatCurrency(orderPriceWithoutTax);
|
||||
const orderCostCurrency = this.env.utils.formatCurrency(orderCost);
|
||||
const orderMarginCurrency = this.env.utils.formatCurrency(orderMargin);
|
||||
const orderMarginPercent = orderPriceWithoutTax
|
||||
? Math.round((orderMargin / orderPriceWithoutTax) * 10000) / 100
|
||||
: 0;
|
||||
@@ -958,6 +958,7 @@ export class PosGlobalState extends PosModel {
|
||||
|
||||
return renderToString("CustomerFacingDisplayOrder", {
|
||||
pos: this,
|
||||
formatCurrency: this.env.utils.formatCurrency,
|
||||
origin: window.location.origin,
|
||||
order,
|
||||
productImages,
|
||||
@@ -1496,36 +1497,6 @@ export class PosGlobalState extends PosModel {
|
||||
});
|
||||
}
|
||||
|
||||
format_currency(amount, precision) {
|
||||
amount = this.format_currency_no_symbol(amount, precision, this.currency);
|
||||
|
||||
if (this.currency.position === "after") {
|
||||
return amount + " " + (this.currency.symbol || "");
|
||||
} else {
|
||||
return (this.currency.symbol || "") + " " + amount;
|
||||
}
|
||||
}
|
||||
|
||||
format_currency_no_symbol(amount, precision, currency) {
|
||||
if (!currency) {
|
||||
currency = this.currency;
|
||||
}
|
||||
var decimals = currency.decimal_places;
|
||||
|
||||
if (precision && this.dp[precision] !== undefined) {
|
||||
decimals = this.dp[precision];
|
||||
}
|
||||
|
||||
if (typeof amount === "number") {
|
||||
amount = round_di(amount, decimals).toFixed(decimals);
|
||||
amount = formatFloat(round_di(amount, decimals), {
|
||||
digits: [69, decimals],
|
||||
});
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
format_pr(value, precision) {
|
||||
var decimals =
|
||||
precision > 0 ? Math.max(0, Math.ceil(Math.log(1.0 / precision) / Math.log(10))) : 0;
|
||||
@@ -2378,8 +2349,8 @@ export class Orderline extends PosModel {
|
||||
return this.compute_all(product_taxes, lst_price, 1, this.pos.currency.rounding)
|
||||
.total_included;
|
||||
}
|
||||
var digits = this.pos.dp['Product Price'];
|
||||
return lst_price.toFixed(digits)
|
||||
var digits = this.pos.dp["Product Price"];
|
||||
return lst_price.toFixed(digits);
|
||||
}
|
||||
get_price_without_tax() {
|
||||
return this.get_all_prices().priceWithoutTax;
|
||||
@@ -3399,7 +3370,9 @@ export class Order extends PosModel {
|
||||
var self = this;
|
||||
this.pricelist = pricelist;
|
||||
|
||||
var lines_to_recompute = this.get_orderlines().filter((line) => !(line.price_manually_set || line.price_automatically_set));
|
||||
var lines_to_recompute = this.get_orderlines().filter(
|
||||
(line) => !(line.price_manually_set || line.price_automatically_set)
|
||||
);
|
||||
lines_to_recompute.forEach((line) => {
|
||||
line.set_unit_price(
|
||||
line.product.get_price(self.pricelist, line.get_quantity(), line.get_price_extra())
|
||||
@@ -3650,9 +3623,14 @@ export class Order extends PosModel {
|
||||
return [];
|
||||
}
|
||||
_reduce_total_discount_callback(sum, orderLine) {
|
||||
sum += (orderLine.get_unit_price() * (orderLine.get_discount()/100) * orderLine.get_quantity());
|
||||
if (orderLine.display_discount_policy() === 'without_discount'){
|
||||
sum += ((orderLine.get_taxed_lst_unit_price() - orderLine.get_unit_price()) * orderLine.get_quantity());
|
||||
sum +=
|
||||
orderLine.get_unit_price() *
|
||||
(orderLine.get_discount() / 100) *
|
||||
orderLine.get_quantity();
|
||||
if (orderLine.display_discount_policy() === "without_discount") {
|
||||
sum +=
|
||||
(orderLine.get_taxed_lst_unit_price() - orderLine.get_unit_price()) *
|
||||
orderLine.get_quantity();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
+4
-4
@@ -33,7 +33,7 @@
|
||||
<span class="total-amount-formatting">TOTAL</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="pos_total-amount" t-esc="pos.format_currency(order and order.get_total_with_tax() || 0)"/>
|
||||
<span class="pos_total-amount" t-esc="formatCurrency(order and order.get_total_with_tax() || 0)"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<div><div t-attf-style="background-image:url(#{productImages[orderline.product.id]})"/></div>
|
||||
<div t-esc="orderline.get_full_product_name()"/>
|
||||
<div t-esc="orderline.get_quantity_str()"/>
|
||||
<div t-esc="pos.format_currency(orderline.get_display_price())"/>
|
||||
<div t-esc="formatCurrency(orderline.get_display_price())"/>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
@@ -78,7 +78,7 @@
|
||||
<span><t t-esc="paymentline.name"/>:</span>
|
||||
</div>
|
||||
<div>
|
||||
<span t-esc="pos.format_currency(paymentline.get_amount())"/>
|
||||
<span t-esc="formatCurrency(paymentline.get_amount())"/>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
@@ -87,7 +87,7 @@
|
||||
<span class="pos-change_title">Change</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="pos-change_amount" t-esc="pos.format_currency(order and order.get_change() || 0)"/>
|
||||
<span class="pos-change_amount" t-esc="formatCurrency(order and order.get_change() || 0)"/>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="title">Closing Session</div>
|
||||
<div class="total-orders">
|
||||
Total <t t-esc="ordersDetails.quantity"/> orders:
|
||||
<span class="amount" t-esc="pos.globalState.format_currency(ordersDetails.amount)"/>
|
||||
<span class="amount" t-esc="env.utils.formatCurrency(ordersDetails.amount)"/>
|
||||
</div>
|
||||
</header>
|
||||
<main class="body">
|
||||
@@ -25,20 +25,20 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td t-esc="defaultCashDetails.name"/>
|
||||
<td t-esc="pos.globalState.format_currency(defaultCashDetails.amount)"/>
|
||||
<td t-esc="env.utils.formatCurrency(defaultCashDetails.amount)"/>
|
||||
<td class="flex" t-on-input="() => this.handleInputChange(defaultCashDetails.id)">
|
||||
<input class="pos-input" type="number" t-model.number="state.payments[defaultCashDetails.id].counted"/>
|
||||
<div class="button icon" t-on-click="openDetailsPopup">
|
||||
<i class="fa fa-calculator" role="img" title="Open the money details popup"/>
|
||||
</div>
|
||||
</td>
|
||||
<td t-esc="pos.globalState.format_currency(state.payments[defaultCashDetails.id].difference)" t-att-class="{'warning': state.payments[defaultCashDetails.id].difference}"/>
|
||||
<td t-esc="env.utils.formatCurrency(state.payments[defaultCashDetails.id].difference)" t-att-class="{'warning': state.payments[defaultCashDetails.id].difference}"/>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody class="cash-overview">
|
||||
<tr>
|
||||
<td>Opening</td>
|
||||
<td t-esc="pos.globalState.format_currency(defaultCashDetails.opening)"/>
|
||||
<td t-esc="env.utils.formatCurrency(defaultCashDetails.opening)"/>
|
||||
</tr>
|
||||
<tr t-foreach="defaultCashDetails.moves" t-as="move" t-key="move_index">
|
||||
<td>
|
||||
@@ -47,7 +47,7 @@
|
||||
<t t-esc="move.name"/>
|
||||
</div>
|
||||
</td>
|
||||
<td t-esc="pos.globalState.format_currency(Math.abs(move.amount))"/>
|
||||
<td t-esc="env.utils.formatCurrency(Math.abs(move.amount))"/>
|
||||
</tr>
|
||||
<tr t-if="defaultCashDetails.payment_amount">
|
||||
<td>
|
||||
@@ -56,17 +56,17 @@
|
||||
Payments in <t t-esc="defaultCashDetails.name"/>
|
||||
</div>
|
||||
</td>
|
||||
<td t-esc="pos.globalState.format_currency(Math.abs(defaultCashDetails.payment_amount))"/>
|
||||
<td t-esc="env.utils.formatCurrency(Math.abs(defaultCashDetails.payment_amount))"/>
|
||||
</tr>
|
||||
</tbody>
|
||||
</t>
|
||||
<tbody t-if="otherPaymentMethods.length > 0">
|
||||
<tr t-foreach="otherPaymentMethods" t-as="pm" t-key="pm.id">
|
||||
<td t-esc="pm.name"/>
|
||||
<td t-esc="pos.globalState.format_currency(pm.amount)"/>
|
||||
<td t-esc="env.utils.formatCurrency(pm.amount)"/>
|
||||
<t t-set="_showDiff" t-value="_getShowDiff(pm)" />
|
||||
<td t-if="_showDiff" t-on-input="() => this.handleInputChange(pm.id)"><input class="pos-input" type="number" t-model.number="state.payments[pm.id].counted"/></td>
|
||||
<td t-if="_showDiff" t-esc="pos.globalState.format_currency(state.payments[pm.id].difference)" t-att-class="{'warning': state.payments[pm.id].difference}"/>
|
||||
<td t-if="_showDiff" t-esc="env.utils.formatCurrency(state.payments[pm.id].difference)" t-att-class="{'warning': state.payments[pm.id].difference}"/>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
<div class="total-section">
|
||||
<span>Total </span>
|
||||
<CurrencyAmount currency="currency" amount="pos.globalState.format_currency_no_symbol(state.total)"/>
|
||||
<CurrencyAmount currency="currency" amount="env.utils.formatCurrency(state.total, false)"/>
|
||||
</div>
|
||||
</main>
|
||||
<footer class="footer footer-flex">
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</div>
|
||||
<div t-if="value.price_extra" class="price-extra-cell">
|
||||
<span class="price_extra">
|
||||
+ <t t-esc="pos.globalState.format_currency(value.price_extra)"/>
|
||||
+ <t t-esc="env.utils.formatCurrency(value.price_extra)"/>
|
||||
</span>
|
||||
</div>
|
||||
<div t-if="value.id == state.selected_value && value.is_custom" class="custom-value-cell">
|
||||
@@ -59,7 +59,7 @@
|
||||
<t t-set="is_custom" t-value="is_custom || (value.is_custom && value.id == state.selected_value)"/>
|
||||
<t t-esc="value.name"/>
|
||||
<t t-if="value.price_extra">
|
||||
+ <t t-esc="pos.globalState.format_currency(value.price_extra)"/>
|
||||
+ <t t-esc="env.utils.formatCurrency(value.price_extra)"/>
|
||||
</t>
|
||||
</option>
|
||||
</select>
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
<span><t t-if="props.product.default_code" t-esc="props.product.default_code"/> <t t-if="props.product.default_code and props.product.barcode"> - </t> <t t-if="props.product.barcode" t-esc="props.product.barcode"/></span>
|
||||
</div>
|
||||
<div class="column flex-end">
|
||||
<span t-esc="pos.globalState.format_currency(productInfo.all_prices.price_with_tax)" class="global-info-title" />
|
||||
<span t-esc="env.utils.formatCurrency(productInfo.all_prices.price_with_tax)" class="global-info-title" />
|
||||
<t t-foreach="productInfo.all_prices.tax_details" t-as="tax" t-key="tax.name">
|
||||
<div><t t-esc="tax.name"/>: <t t-esc="pos.globalState.format_currency(tax.amount)"/></div>
|
||||
<div><t t-esc="tax.name"/>: <t t-esc="env.utils.formatCurrency(tax.amount)"/></div>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
@@ -27,7 +27,7 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td>Price excl. VAT:</td>
|
||||
<td><t t-esc="pos.globalState.format_currency(productInfo.all_prices.price_without_tax)"/></td>
|
||||
<td><t t-esc="env.utils.formatCurrency(productInfo.all_prices.price_without_tax)"/></td>
|
||||
</tr>
|
||||
<tr t-if="_hasMarginsCostsAccessRights()">
|
||||
<td>Cost:</td>
|
||||
@@ -42,7 +42,7 @@
|
||||
<t t-foreach="productInfo.pricelists" t-as="pricelist" t-key="pricelist.name">
|
||||
<tr>
|
||||
<td t-esc="pricelist.name"/>
|
||||
<td t-esc="pos.globalState.format_currency(pricelist.price)"/>
|
||||
<td t-esc="env.utils.formatCurrency(pricelist.price)"/>
|
||||
</tr>
|
||||
</t>
|
||||
</table>
|
||||
@@ -77,7 +77,7 @@
|
||||
<td><span t-esc="supplier.name" class="table-name"/>:</td>
|
||||
<div class="mobile-line">
|
||||
<td><t t-esc="supplier.delay"/> Days</td>
|
||||
<td t-if="_hasMarginsCostsAccessRights()"><t t-esc="pos.globalState.format_currency(supplier.price)"/></td>
|
||||
<td t-if="_hasMarginsCostsAccessRights()"><t t-esc="env.utils.formatCurrency(supplier.price)"/></td>
|
||||
</div>
|
||||
</tr>
|
||||
</t>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<t t-esc="line.uom" />
|
||||
</t>
|
||||
x
|
||||
<t t-esc="pos.format_currency_no_symbol(line.price_unit)" />
|
||||
<t t-esc="formatCurrency(line.price_unit, false)" />
|
||||
</span>
|
||||
</div>
|
||||
<t t-if="line.discount !== 0">
|
||||
@@ -57,7 +57,7 @@
|
||||
<t t-esc="line.uom" />
|
||||
</t>
|
||||
x
|
||||
<t t-esc="pos.format_currency_no_symbol(line.price_unit)" />
|
||||
<t t-esc="formatCurrency(line.price_unit, false)" />
|
||||
</span>
|
||||
</div>
|
||||
<t t-if="line.discount !== 0">
|
||||
@@ -76,7 +76,7 @@
|
||||
</div>
|
||||
<div t-foreach="payments" t-as="payment" t-key="payment_index">
|
||||
<t t-esc="payment['name']" />
|
||||
<span t-esc="pos.format_currency_no_symbol(payment['total'])" class="pos-receipt-right-align"/>
|
||||
<span t-esc="formatCurrency(payment['total'], false)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
@@ -88,7 +88,7 @@
|
||||
</div>
|
||||
<div t-foreach="taxes" t-as="tax" t-key="tax_index">
|
||||
<t t-esc="tax.name" />
|
||||
<span t-esc="pos.format_currency_no_symbol(tax.tax_amount)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="formatCurrency(tax.tax_amount, false)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
@@ -97,7 +97,7 @@
|
||||
|
||||
<div>
|
||||
Total:
|
||||
<span t-esc="pos.format_currency_no_symbol(total_paid)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="formatCurrency(total_paid, false)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<div t-if="env.pos.config.tip_product_id" class="button js_tip"
|
||||
t-att-class="{ highlight: currentOrder.get_tip() }"
|
||||
t-on-click="addTip">
|
||||
<i class="fa fa-heart" /> Tip <t t-if="currentOrder.get_tip() != 0">(<t t-esc="env.pos.format_currency(currentOrder.get_tip())"/>)</t>
|
||||
<i class="fa fa-heart" /> Tip <t t-if="currentOrder.get_tip() != 0">(<t t-esc="env.utils.formatCurrency(currentOrder.get_tip())"/>)</t>
|
||||
</div>
|
||||
<div t-if="env.pos.config.iface_cashdrawer" class="button js_cashdrawer"
|
||||
t-on-click="openCashbox">
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div class="payment-amount">
|
||||
<t t-if="line and line.payment_status and ['done', 'waitingCard', 'waiting', 'reversing', 'reversed'].includes(line.payment_status)">
|
||||
<t t-esc="env.pos.format_currency_no_symbol(line.get_amount())" />
|
||||
<t t-esc="env.utils.formatCurrency(line.get_amount(), false)" />
|
||||
</t>
|
||||
<t t-else="">
|
||||
<t t-esc="formatLineAmount(line)" />
|
||||
@@ -109,7 +109,7 @@
|
||||
</div>
|
||||
<div class="payment-amount">
|
||||
<t t-if="line and line.payment_status and ['done', 'waitingCard', 'waiting', 'reversing', 'reversed'].includes(line.payment_status)">
|
||||
<t t-esc="env.pos.format_currency_no_symbol(line.get_amount())" />
|
||||
<t t-esc="env.utils.formatCurrency(line.get_amount(), false)" />
|
||||
</t>
|
||||
<t t-else="">
|
||||
<t t-esc="formatLineAmount(line)" />
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</t>
|
||||
</span>
|
||||
<span class="price">
|
||||
<t t-esc="env.pos.format_currency(props.line.get_display_price())"/>
|
||||
<t t-esc="env.utils.formatCurrency(props.line.get_display_price())"/>
|
||||
</span>
|
||||
<ul class="info-list">
|
||||
<t t-if="props.line.get_quantity_str() !== '1' || props.line.selected ">
|
||||
@@ -39,12 +39,12 @@
|
||||
<t t-if="props.line.display_discount_policy() == 'without_discount' and
|
||||
env.pos.round_decimals_currency(props.line.get_unit_display_price()) < env.pos.round_decimals_currency(props.line.get_taxed_lst_unit_price())">
|
||||
<s>
|
||||
<t t-esc="env.pos.format_currency(props.line.get_taxed_lst_unit_price(),'Product Price')" />
|
||||
<t t-esc="env.utils.formatCurrency(props.line.get_taxed_lst_unit_price())" />
|
||||
</s>
|
||||
<t t-esc="env.pos.format_currency(props.line.get_unit_display_price(),'Product Price')" />
|
||||
<t t-esc="env.utils.formatCurrency(props.line.get_unit_display_price())" />
|
||||
</t>
|
||||
<t t-else="">
|
||||
<t t-esc="env.pos.format_currency(props.line.get_unit_display_price(),'Product Price')" />
|
||||
<t t-esc="env.utils.formatCurrency(props.line.get_unit_display_price())" />
|
||||
</t>
|
||||
/
|
||||
<t t-esc="props.line.get_unit().name" />
|
||||
|
||||
@@ -52,11 +52,11 @@
|
||||
<t t-if="!isTaxIncluded">
|
||||
<div class="pos-receipt-right-align">--------</div>
|
||||
<br/>
|
||||
<div>Subtotal<span t-esc="env.pos.format_currency(receipt.subtotal)" class="pos-receipt-right-align"/></div>
|
||||
<div>Subtotal<span t-esc="env.utils.formatCurrency(receipt.subtotal)" class="pos-receipt-right-align"/></div>
|
||||
<t t-foreach="receipt.tax_details" t-as="tax" t-key="tax.name">
|
||||
<div class="responsive-price">
|
||||
<t t-esc="tax.name" />
|
||||
<span t-esc='env.pos.format_currency_no_symbol(tax.amount)' class="pos-receipt-right-align"/>
|
||||
<span t-esc='env.utils.formatCurrency(tax.amount, false)' class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
@@ -66,16 +66,16 @@
|
||||
<br/>
|
||||
<div class="pos-receipt-amount">
|
||||
TOTAL
|
||||
<span t-esc="env.pos.format_currency(receipt.total_with_tax)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.total_with_tax)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
<t t-if="receipt.total_rounded != receipt.total_with_tax">
|
||||
<div class="pos-receipt-amount">
|
||||
Rounding
|
||||
<span t-esc='env.pos.format_currency(receipt.rounding_applied)' class="pos-receipt-right-align"/>
|
||||
<span t-esc='env.utils.formatCurrency(receipt.rounding_applied)' class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
<div class="pos-receipt-amount">
|
||||
To Pay
|
||||
<span t-esc='env.pos.format_currency(receipt.total_rounded)' class="pos-receipt-right-align"/>
|
||||
<span t-esc='env.utils.formatCurrency(receipt.total_rounded)' class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</t>
|
||||
<br/><br/>
|
||||
@@ -85,14 +85,14 @@
|
||||
<t t-foreach="receipt.paymentlines" t-as="line" t-key="line.cid">
|
||||
<div>
|
||||
<t t-esc="line.name" />
|
||||
<span t-esc="env.pos.format_currency_no_symbol(line.amount)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(line.amount, false)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</t>
|
||||
<br/>
|
||||
|
||||
<div class="pos-receipt-amount receipt-change">
|
||||
CHANGE
|
||||
<span t-esc="env.pos.format_currency(receipt.change)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.change)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
@@ -101,19 +101,19 @@
|
||||
<t t-if="receipt.total_discount">
|
||||
<div>
|
||||
Discounts
|
||||
<span t-esc="env.pos.format_currency(receipt.total_discount)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.total_discount)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</t>
|
||||
<t t-if="isTaxIncluded">
|
||||
<t t-foreach="receipt.tax_details" t-as="tax" t-key="tax.name">
|
||||
<div>
|
||||
<t t-esc="tax.name" />
|
||||
<span t-esc="env.pos.format_currency_no_symbol(tax.amount)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(tax.amount, false)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</t>
|
||||
<div id="post_receipt_taxes_container">
|
||||
Total Taxes
|
||||
<span t-esc="env.pos.format_currency(receipt.total_tax)" class="pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(receipt.total_tax)" class="pos-receipt-right-align"/>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
<t t-if="isSimple(line)">
|
||||
<div class="responsive-price">
|
||||
<t t-esc="line.product_name_wrapped[0]" />
|
||||
<span t-esc="env.pos.format_currency_no_symbol(line.price_display)" class="price_display pos-receipt-right-align"/>
|
||||
<span t-esc="env.utils.formatCurrency(line.price_display, false)" class="price_display pos-receipt-right-align"/>
|
||||
</div>
|
||||
<WrappedProductNameLines line="line" />
|
||||
</t>
|
||||
@@ -190,18 +190,18 @@
|
||||
<WrappedProductNameLines line="line" />
|
||||
<t t-if="line.display_discount_policy == 'without_discount' and line.price != line.price_lst">
|
||||
<div class="pos-receipt-left-padding">
|
||||
<t t-esc="env.pos.format_currency_no_symbol(line.price_lst)" />
|
||||
<t t-esc="env.utils.formatCurrency(line.price_lst, false)" />
|
||||
->
|
||||
<t t-esc="env.pos.format_currency_no_symbol(line.price)" />
|
||||
<t t-esc="env.utils.formatCurrency(line.price, false)" />
|
||||
</div>
|
||||
</t>
|
||||
<t t-elif="line.discount !== 0">
|
||||
<div class="pos-receipt-left-padding">
|
||||
<t t-if="env.pos.config.iface_tax_included === 'total'">
|
||||
<t t-esc="env.pos.format_currency_no_symbol(line.price_with_tax_before_discount)"/>
|
||||
<t t-esc="env.utils.formatCurrency(line.price_with_tax_before_discount, false)"/>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<t t-esc="env.pos.format_currency_no_symbol(line.price)"/>
|
||||
<t t-esc="env.utils.formatCurrency(line.price, false)"/>
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
@@ -214,9 +214,9 @@
|
||||
<t t-esc="Math.round(line.quantity * Math.pow(10, env.pos.dp['Product Unit of Measure'])) / Math.pow(10, env.pos.dp['Product Unit of Measure'])"/>
|
||||
<t t-if="!line.is_in_unit" t-esc="line.unit_name" />
|
||||
x
|
||||
<t t-esc="env.pos.format_currency(line.price_display_one)" />
|
||||
<t t-esc="env.utils.formatCurrency(line.price_display_one)" />
|
||||
<span class="price_display pos-receipt-right-align">
|
||||
<t t-esc="env.pos.format_currency_no_symbol(line.price_display)" />
|
||||
<t t-esc="env.utils.formatCurrency(line.price_display, false)" />
|
||||
</span>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</div>
|
||||
<div class="product-price">
|
||||
<t
|
||||
t-esc="env.pos.format_currency(productPrice) + '/' + productUom" />
|
||||
t-esc="env.utils.formatCurrency(productPrice) + '/' + productUom" />
|
||||
</div>
|
||||
<div class="computed-price">
|
||||
<t t-esc="computedPriceString" />
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Chrome } from "@point_of_sale/../tests/tours/helpers/ChromeTourMethods"
|
||||
import { NumberPopup } from "@point_of_sale/../tests/tours/helpers/NumberPopupTourMethods";
|
||||
import { getSteps, startSteps } from "@point_of_sale/../tests/tours/helpers/utils";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { nbsp } from "@web/core/utils/strings";
|
||||
|
||||
startSteps();
|
||||
|
||||
@@ -54,7 +55,7 @@ PaymentScreen.check.emptyPaymentlines("31.0");
|
||||
PaymentScreen.do.clickPaymentMethod("Cash");
|
||||
PaymentScreen.do.clickValidate();
|
||||
ReceiptScreen.check.receiptIsThere();
|
||||
ReceiptScreen.check.totalAmountContains("$ 30.00 + $ 1.00 tip");
|
||||
ReceiptScreen.check.totalAmountContains(`$${nbsp}30.00 + $${nbsp}1.00 tip`);
|
||||
ReceiptScreen.do.clickNextOrder();
|
||||
|
||||
// Test customer note in receipt
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
import { roundDecimals as round_di } from "@web/core/utils/numbers";
|
||||
import { nbsp } from "@web/core/utils/strings";
|
||||
|
||||
function assert(condition, message) {
|
||||
if (!condition) {
|
||||
@@ -192,7 +193,7 @@ steps = steps.concat([
|
||||
},
|
||||
{
|
||||
content: "verify that unit price of shelf changed to $1",
|
||||
trigger: ".total > .value:contains('$ 2.00')",
|
||||
trigger: `.total > .value:contains('$${nbsp}2.00')`,
|
||||
run: function () {},
|
||||
},
|
||||
{
|
||||
@@ -247,7 +248,7 @@ steps = steps.concat([
|
||||
{
|
||||
content:
|
||||
"verify that the boni shelf have been recomputed and the shelf have not (their price was manually overridden)",
|
||||
trigger: ".total > .value:contains('$ 8.96')",
|
||||
trigger: `.total > .value:contains('$${nbsp}8.96')`,
|
||||
},
|
||||
{
|
||||
content: "click pricelist button",
|
||||
|
||||
@@ -24,8 +24,8 @@ patch(Orderline.prototype, "pos_loyalty.Orderline", {
|
||||
_getGiftCardOrEWalletBalance() {
|
||||
const coupon = this.env.pos.couponCache[this.props.line.coupon_id];
|
||||
if (coupon) {
|
||||
return this.env.pos.format_currency(coupon.balance);
|
||||
return this.env.utils.formatCurrency(coupon.balance);
|
||||
}
|
||||
return this.env.pos.format_currency(0);
|
||||
return this.env.utils.formatCurrency(0);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ patch(PartnerLine.prototype, "pos_loyalty.PartnerLine", {
|
||||
_getLoyaltyPointsRepr(loyaltyCard) {
|
||||
const program = this.env.pos.program_by_id[loyaltyCard.program_id];
|
||||
if (program.program_type === "ewallet") {
|
||||
return `${program.name}: ${this.env.pos.format_currency(loyaltyCard.balance)}`;
|
||||
return `${program.name}: ${this.env.utils.formatCurrency(loyaltyCard.balance)}`;
|
||||
}
|
||||
const balanceRepr = this.env.pos.format_pr(loyaltyCard.balance, 0.01);
|
||||
if (program.portal_visible) {
|
||||
|
||||
@@ -160,7 +160,7 @@ export class TipCell extends Component {
|
||||
useAutofocus();
|
||||
}
|
||||
get tipAmountStr() {
|
||||
return this.env.pos.format_currency(parseFloat(this.orderUiState.inputTipAmount || "0"));
|
||||
return this.env.utils.formatCurrency(parseFloat(this.orderUiState.inputTipAmount || "0"));
|
||||
}
|
||||
onBlur() {
|
||||
this.state.isEditing = false;
|
||||
|
||||
@@ -28,9 +28,9 @@ export class TipScreen extends Component {
|
||||
}
|
||||
get overallAmountStr() {
|
||||
const tipAmount = parseFloat(this.state.inputTipAmount || "0");
|
||||
const original = this.env.pos.format_currency(this.totalAmount);
|
||||
const tip = this.env.pos.format_currency(tipAmount);
|
||||
const overall = this.env.pos.format_currency(this.totalAmount + tipAmount);
|
||||
const original = this.env.utils.formatCurrency(this.totalAmount);
|
||||
const tip = this.env.utils.formatCurrency(tipAmount);
|
||||
const overall = this.env.utils.formatCurrency(this.totalAmount + tipAmount);
|
||||
return `${original} + ${tip} tip = ${overall}`;
|
||||
}
|
||||
get totalAmount() {
|
||||
@@ -70,7 +70,7 @@ export class TipScreen extends Component {
|
||||
if (amount > 0.25 * this.totalAmount) {
|
||||
const { confirmed } = await this.popup.add(ConfirmPopup, {
|
||||
title: "Are you sure?",
|
||||
body: `${this.env.pos.format_currency(
|
||||
body: `${this.env.utils.formatCurrency(
|
||||
amount
|
||||
)} is more than 25% of the order's total amount. Are you sure of this tip amount?`,
|
||||
});
|
||||
@@ -122,7 +122,7 @@ export class TipScreen extends Component {
|
||||
var receipt = renderToElement("TipReceipt", {
|
||||
receipt: this.currentOrder.getOrderReceiptEnv().receipt,
|
||||
data: data,
|
||||
total: this.env.pos.format_currency(this.totalAmount),
|
||||
total: this.env.utils.formatCurrency(this.totalAmount),
|
||||
});
|
||||
|
||||
if (this.hardwareProxy.printer) {
|
||||
|
||||
@@ -26,19 +26,19 @@
|
||||
<div class="option">
|
||||
<div>15%</div>
|
||||
<div class="amount">
|
||||
<t t-esc="env.pos.format_currency(receipt.total_with_tax * 0.15)"></t>
|
||||
<t t-esc="env.utils.formatCurrency(receipt.total_with_tax * 0.15)"></t>
|
||||
</div>
|
||||
</div>
|
||||
<div class="option">
|
||||
<div>20%</div>
|
||||
<div class="amount">
|
||||
<t t-esc="env.pos.format_currency(receipt.total_with_tax * 0.20)"></t>
|
||||
<t t-esc="env.utils.formatCurrency(receipt.total_with_tax * 0.20)"></t>
|
||||
</div>
|
||||
</div>
|
||||
<div class="option">
|
||||
<div>25%</div>
|
||||
<div class="amount">
|
||||
<t t-esc="env.pos.format_currency(receipt.total_with_tax * 0.25)"></t>
|
||||
<t t-esc="env.utils.formatCurrency(receipt.total_with_tax * 0.25)"></t>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<div class="controls">
|
||||
<div class="order-info">
|
||||
<span class="subtotal">
|
||||
<t t-esc="env.pos.format_currency(newOrder.get_subtotal())" />
|
||||
<t t-esc="env.utils.formatCurrency(newOrder.get_subtotal())" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="pay-button">
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<t t-esc="props.line.get_product().display_name" />
|
||||
</span>
|
||||
<span class="price">
|
||||
<t t-esc="env.pos.format_currency(props.line.get_display_price())" />
|
||||
<t t-esc="env.utils.formatCurrency(props.line.get_display_price())" />
|
||||
</span>
|
||||
<ul class="info-list">
|
||||
<t t-if="props.line.get_quantity_str() !== '1'">
|
||||
@@ -26,7 +26,7 @@
|
||||
</t>
|
||||
<t t-esc="props.line.get_unit().name" />
|
||||
at
|
||||
<t t-esc="env.pos.format_currency(props.line.get_unit_price())" />
|
||||
<t t-esc="env.utils.formatCurrency(props.line.get_unit_price())" />
|
||||
/
|
||||
<t t-esc="props.line.get_unit().name" />
|
||||
</li>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<t t-esc="tip.percentage"></t>
|
||||
</div>
|
||||
<div class="amount">
|
||||
<t t-esc="env.pos.format_currency(tip.amount)" />
|
||||
<t t-esc="env.utils.formatCurrency(tip.amount)" />
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -285,7 +285,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo
|
||||
const { confirmed, payload } = await this.popup.add(NumberPopup, {
|
||||
title: sprintf(
|
||||
this.env._t("Percentage of %s"),
|
||||
this.env.pos.format_currency(sale_order.amount_total)
|
||||
this.env.utils.formatCurrency(sale_order.amount_total)
|
||||
),
|
||||
startingValue: 0,
|
||||
});
|
||||
@@ -298,11 +298,11 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo
|
||||
this.env._t(
|
||||
"You have tried to charge a down payment of %s but only %s remains to be paid, %s will be applied to the purchase order line."
|
||||
),
|
||||
this.env.pos.format_currency(down_payment),
|
||||
this.env.pos.format_currency(sale_order.amount_unpaid),
|
||||
this.env.utils.formatCurrency(down_payment),
|
||||
this.env.utils.formatCurrency(sale_order.amount_unpaid),
|
||||
sale_order.amount_unpaid > 0
|
||||
? this.env.pos.format_currency(sale_order.amount_unpaid)
|
||||
: this.env.pos.format_currency(0)
|
||||
? this.env.utils.formatCurrency(sale_order.amount_unpaid)
|
||||
: this.env.utils.formatCurrency(0)
|
||||
);
|
||||
await this.popup.add(ErrorPopup, {
|
||||
title: "Error amount too high",
|
||||
|
||||
@@ -32,7 +32,7 @@ export class SaleOrderRow extends Component {
|
||||
return partner ? partner[1] : null;
|
||||
}
|
||||
get total() {
|
||||
return this.env.pos.format_currency(this.order.amount_total);
|
||||
return this.env.utils.formatCurrency(this.order.amount_total);
|
||||
}
|
||||
/**
|
||||
* Returns true if the order has unpaid amount, but the unpaid amount
|
||||
@@ -43,7 +43,7 @@ export class SaleOrderRow extends Component {
|
||||
return this.order.amount_total != this.order.amount_unpaid;
|
||||
}
|
||||
get amountUnpaidRepr() {
|
||||
return this.env.pos.format_currency(this.order.amount_unpaid);
|
||||
return this.env.utils.formatCurrency(this.order.amount_unpaid);
|
||||
}
|
||||
get state() {
|
||||
const state_mapping = {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<t t-esc="line['product_name']" />
|
||||
</td>
|
||||
<td>:</td>
|
||||
<td><t t-esc="env.pos.format_currency(line['total'])" /> (tax incl.)</td>
|
||||
<td><t t-esc="env.utils.formatCurrency(line['total'])" /> (tax incl.)</td>
|
||||
</tr>
|
||||
</t>
|
||||
</table>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<tr>
|
||||
<td><span class="searchable" t-esc="optional.name" t-on-click="() => this.searchProduct(optional.name)"/></td>
|
||||
<td class="table-value">
|
||||
from <t t-esc="pos.globalState.format_currency(optional.price)"/>
|
||||
from <t t-esc="env.utils.formatCurrency(optional.price)"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user