blob: 35f6ec5df22fea7d146dade77db4a24d3db40ecf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
odoo.define('point_of_sale.OrderlineDetails', function (require) {
'use strict';
const PosComponent = require('point_of_sale.PosComponent');
const Registries = require('point_of_sale.Registries');
const { format } = require('web.field_utils');
const { round_precision: round_pr } = require('web.utils');
/**
* @props {pos.order.line} line
*/
class OrderlineDetails extends PosComponent {
get line() {
const line = this.props.line;
const formatQty = (line) => {
const quantity = line.get_quantity();
const unit = line.get_unit();
const decimals = this.env.pos.dp['Product Unit of Measure'];
const rounding = Math.max(unit.rounding, Math.pow(10, -decimals));
const roundedQuantity = round_pr(quantity, rounding);
return format.float(roundedQuantity, { digits: [69, decimals] });
};
return {
productName: line.get_full_product_name(),
totalPrice: line.get_price_with_tax(),
quantity: formatQty(line),
unit: line.get_unit().name,
unitPrice: line.get_unit_price(),
};
}
get productName() {
return this.line.productName;
}
get totalPrice() {
return this.env.pos.format_currency(this.line.totalPrice);
}
get quantity() {
return this.line.quantity;
}
get unitPrice() {
return this.line.unitPrice;
}
get unit() {
return this.line.unit;
}
get pricePerUnit() {
return ` ${this.unit} at ${this.unitPrice} / ${this.unit}`;
}
}
OrderlineDetails.template = 'OrderlineDetails';
Registries.Component.add(OrderlineDetails);
return OrderlineDetails;
});
|