async _load_invoice_to_cart(offline_pos_name) {
        if (this.frm.doc.items.length > 0) {
          await new Promise((resolve, reject) => {
            frappe.confirm(
              'Your current cart contains some items. ' +
                'Do you really want to clear them and load the saved invoice?',
              resolve,
              reject
            );
          });
        }

        const invoice = await db.draft_invoices.get(offline_pos_name);
        frappe.model.add_to_locals(invoice);
        ['items', 'payments', 'taxes'].forEach((field) =>
          invoice[field].forEach(frappe.model.add_to_locals)
        );
        this.frm.refresh(invoice.name);

        this.customer_field.value = this.frm.doc.customer;
        this.customer_field.refresh();

        this.available_loyalty_points.value = this.frm.doc.loyalty_points;
        this.available_loyalty_points.refresh();

        this.$cart_items.empty();
        this.$cart_items.append(
          this.frm.doc.items.map(this.get_item_html.bind(this))
        );

        this.update_discount_fields();
        this.update_grand_total();
        this.update_taxes_and_totals();
        this.update_qty_total();
      }
// actually a POSCart method. should be called from POS with cart context
actually a POSCart method. should be called from POS with cart context
actually a POSCart method . should be called from POS with cart context
async _load_invoice_to_cart(offline_pos_name) {
        if (this.frm.doc.items.length > 0) {
          await new Promise((resolve, reject) => {
            frappe.confirm(
              'Your current cart contains some items. ' +
                'Do you really want to clear them and load the saved invoice?',
              resolve,
              reject
            );
          });
        }
        const invoice = await db.draft_invoices.get(offline_pos_name);
        frappe.model.add_to_locals(invoice);
        ['items', 'payments', 'taxes'].forEach((field) =>
          invoice[field].forEach(frappe.model.add_to_locals)
        );
        this.frm.refresh(invoice.name);
        this.customer_field.value = this.frm.doc.customer;
        this.customer_field.refresh();
        this.available_loyalty_points.value = this.frm.doc.loyalty_points;
        this.available_loyalty_points.refresh();
        this.$cart_items.empty();
        this.$cart_items.append(
          this.frm.doc.items.map(this.get_item_html.bind(this))
        );
        this.update_discount_fields();
        this.update_grand_total();
        this.update_taxes_and_totals();
        this.update_qty_total();
      }
async _load_invoice_to_cart ( offline_pos_name ) { if ( this . frm . doc . items . length > 0 ) { await new Promise ( ( resolve , reject ) => { frappe . confirm ( 'Your current cart contains some items. ' + 'Do you really want to clear them and load the saved invoice?' , resolve , reject ) ; } ) ; } const invoice = await db . draft_invoices . get ( offline_pos_name ) ; frappe . model . add_to_locals ( invoice ) ; [ 'items' , 'payments' , 'taxes' ] . forEach ( ( field ) => invoice [ field ] . forEach ( frappe . model . add_to_locals ) ) ; this . frm . refresh ( invoice . name ) ; this . customer_field . value = this . frm . doc . customer ; this . customer_field . refresh ( ) ; this . available_loyalty_points . value = this . frm . doc . loyalty_points ; this . available_loyalty_points . refresh ( ) ; this . $cart_items . empty ( ) ; this . $cart_items . append ( this . frm . doc . items . map ( this . get_item_html . bind ( this ) ) ) ; this . update_discount_fields ( ) ; this . update_grand_total ( ) ; this . update_taxes_and_totals ( ) ; this . update_qty_total ( ) ; }
actually a POSCart method.
actually a POSCart method .