[fix] Price list not loaded from pos profile, auto set outstanding amount in the mode of payment

This commit is contained in:
Rohit Waghchaure 2017-11-18 16:58:58 +05:30
parent a5b53e9480
commit 77940493a8
3 changed files with 46 additions and 20 deletions

View File

@ -24,11 +24,11 @@ frappe.ui.form.on("POS Profile", "onload", function(frm) {
frappe.ui.form.on('POS Profile', {
setup: function(frm) {
frm.set_query("online_print_format", function() {
frm.set_query("print_format_for_online", function() {
return {
filters: [
['Print Format', 'doc_type', '=', 'Sales Invoice'],
['Print Format', 'print_format_type', '!=', 'Js'],
['Print Format', 'print_format_type', '=', 'Server'],
]
};
});

View File

@ -247,7 +247,7 @@ class SalesInvoice(SellingController):
super(SalesInvoice, self).set_missing_values(for_validate)
if pos:
return {"print_format": pos.get("print_format") }
return {"print_format": pos.get("print_format_for_online") }
def update_time_sheet(self, sales_invoice):
for d in self.timesheets:

View File

@ -53,8 +53,6 @@ erpnext.pos.PointOfSale = class PointOfSale {
() => this.setup_pos_profile(),
() => this.make_new_invoice(),
() => {
frappe.timeout(1);
this.make_items();
this.bind_events();
frappe.dom.unfreeze();
},
@ -323,16 +321,20 @@ erpnext.pos.PointOfSale = class PointOfSale {
make_new_invoice() {
return frappe.run_serially([
() => this.make_sales_invoice_frm(),
() => {
this.make_sales_invoice_frm()
.then(() => this.set_pos_profile_data())
.then(() => {
if (this.cart) {
this.cart.frm = this.frm;
this.cart.reset();
} else {
this.make_items();
this.make_cart();
}
this.toggle_editing(true);
}
})
},
]);
}
@ -359,12 +361,29 @@ erpnext.pos.PointOfSale = class PointOfSale {
if(!frm.doc.company) {
frm.set_value('company', pos_profile.company);
}
frm.set_value('is_pos', 1);
frm.meta.default_print_format = 'POS Invoice';
frm.doc.is_pos = 1;
return frm;
}
}
set_pos_profile_data() {
return new Promise(resolve => {
return this.frm.call({
doc: this.frm.doc,
method: "set_missing_values",
}).then((r) => {
if(!r.exc) {
this.frm.script_manager.trigger("update_stock");
frappe.model.set_default_values(this.frm.doc);
this.frm.cscript.calculate_taxes_and_totals();
this.frm.meta.default_print_format = r.message.print_format || 'POS Invoice';
}
resolve();
})
})
}
prepare_menu() {
var me = this;
this.page.clear_menu();
@ -392,9 +411,6 @@ erpnext.pos.PointOfSale = class PointOfSale {
if(this.frm.doc.docstatus !== 1) return;
this.page.set_secondary_action(__("Print"), () => {
if (this.pos_profile && this.pos_profile.print_format_for_online) {
this.frm.meta.default_print_format = this.pos_profile.print_format_for_online;
}
this.frm.print_preview.printit(true);
});
@ -1264,6 +1280,16 @@ class Payment {
$(this.dialog.body).find('.input-with-feedback').focusin(function() {
me.numpad.reset_value();
me.fieldname = $(this).prop('dataset').fieldname;
if (me.frm.doc.outstanding_amount > 0 &&
!in_list(['write_off_amount', 'change_amount'], me.fieldname)) {
me.frm.doc.payments.forEach((data) => {
if (data.mode_of_payment == me.fieldname && !data.amount) {
me.dialog.set_value(me.fieldname,
me.frm.doc.outstanding_amount / me.frm.doc.conversion_rate);
return;
}
})
}
});
}