I am trying to read the total amount of cash payments made in a POS session in Odoo 14 :
Could someone point me into the right direction: i have following code:
get totalCash() {
// Get order list
const orders = this.env.pos.get_order_list();
let totalCash = 0;
console.log("Order list: ", orders);
// Iterate over each order
for (const order of orders) {
console.log("Order: ", order);
// Iterate over each payment line of the order
for (const paymentLine of order.paymentlines.models) {
console.log("Payment line: ", paymentLine);
// Check if the payment method is cash
if (paymentLine.cashregister.journal.type === 'cash') {
console.log("Cash register type: ", paymentLine.cashregister.journal.type);
console.log("Amount before: ", totalCash);
totalCash += paymentLine.amount;
console.log("Amount after: ", totalCash);
}
}
}
return totalCash.toFixed(2);
}
in the console my output is following: Object { cid: "c49", attributes: {…}, _changing: false, _previousAttributes: {…}, changed: {}, _pending: false, locked: false, pos: {…}, selected_orderline: undefined, selected_paymentline: undefined, … }
So it seems i am finding the objects, but i am not using the right names for the payment lines. Anybody knows how to fix this?
Thanks a lot.