[POS] Fixed issue of paid amount, write off account

This commit is contained in:
Rohit Waghchaure 2016-08-19 15:11:36 +05:30
parent e4fb7b1b2f
commit 713e2b7b62
3 changed files with 25 additions and 15 deletions

View File

@ -381,8 +381,10 @@ class SalesInvoice(SellingController):
if d.delivery_note: if d.delivery_note:
msgprint(_("Stock cannot be updated against Delivery Note {0}").format(d.delivery_note), raise_exception=1) msgprint(_("Stock cannot be updated against Delivery Note {0}").format(d.delivery_note), raise_exception=1)
def validate_write_off_account(self): def validate_write_off_account(self):
if flt(self.write_off_amount) and not self.write_off_account:
self.write_off_account = frappe.db.get_value('Company', self.company, 'write_off_account')
if flt(self.write_off_amount) and not self.write_off_account: if flt(self.write_off_amount) and not self.write_off_account:
msgprint(_("Please enter Write Off Account"), raise_exception=1) msgprint(_("Please enter Write Off Account"), raise_exception=1)

View File

@ -509,7 +509,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.remove_zero_qty_item(); this.remove_zero_qty_item();
} }
this.refresh(); this.update_paid_amount_status(false)
}, },
remove_zero_qty_item: function(){ remove_zero_qty_item: function(){
@ -591,7 +591,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
if (!caught) if (!caught)
this.add_new_item_to_grid(); this.add_new_item_to_grid();
this.refresh(); this.update_paid_amount_status(false)
}, },
add_new_item_to_grid: function() { add_new_item_to_grid: function() {
@ -616,6 +616,14 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
? this.item_serial_no[this.child.item_code][0] : ''); ? this.item_serial_no[this.child.item_code][0] : '');
}, },
update_paid_amount_status: function(update_paid_amount){
if(this.name){
update_paid_amount = update_paid_amount ? false : true;
}
this.refresh(update_paid_amount);
},
refresh: function(update_paid_amount) { refresh: function(update_paid_amount) {
var me = this; var me = this;
this.refresh_fields(update_paid_amount); this.refresh_fields(update_paid_amount);
@ -623,6 +631,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.update_rate(); this.update_rate();
this.set_primary_action(); this.set_primary_action();
}, },
refresh_fields: function(update_paid_amount) { refresh_fields: function(update_paid_amount) {
this.apply_pricing_rule(); this.apply_pricing_rule();
this.discount_amount_applied = false; this.discount_amount_applied = false;
@ -698,7 +707,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
if (this.frm.doc.docstatus==0) { if (this.frm.doc.docstatus==0) {
this.page.set_primary_action(__("Pay"), function() { this.page.set_primary_action(__("Pay"), function() {
me.validate() me.validate();
me.update_paid_amount_status(true);
me.create_invoice(); me.create_invoice();
me.make_payment(); me.make_payment();
}, "octicon octicon-credit-card"); }, "octicon octicon-credit-card");

View File

@ -177,19 +177,17 @@ erpnext.payments = erpnext.stock.StockController.extend({
write_off_amount: function(write_off_amount) { write_off_amount: function(write_off_amount) {
var me = this; var me = this;
if(this.frm.doc.paid_amount > 0){ this.frm.doc.write_off_amount = flt(write_off_amount, precision("write_off_amount"));
this.frm.doc.write_off_amount = write_off_amount;
this.frm.doc.base_write_off_amount = flt(this.frm.doc.write_off_amount * this.frm.doc.conversion_rate, this.frm.doc.base_write_off_amount = flt(this.frm.doc.write_off_amount * this.frm.doc.conversion_rate,
precision("base_write_off_amount")); precision("base_write_off_amount"));
this.calculate_outstanding_amount(false) this.calculate_outstanding_amount(false)
this.show_amounts() this.show_amounts()
}
}, },
change_amount: function(change_amount) { change_amount: function(change_amount) {
var me = this; var me = this;
this.frm.doc.change_amount = change_amount; this.frm.doc.change_amount = flt(change_amount, precision("change_amount"));
this.calculate_write_off_amount() this.calculate_write_off_amount()
this.show_amounts() this.show_amounts()
}, },
@ -197,7 +195,7 @@ erpnext.payments = erpnext.stock.StockController.extend({
update_paid_amount: function() { update_paid_amount: function() {
var me = this; var me = this;
if(in_list(['change_amount', 'write_off_amount'], this.idx)){ if(in_list(['change_amount', 'write_off_amount'], this.idx)){
value = flt(me.selected_mode.val(), 2) value = me.selected_mode.val();
if(me.idx == 'change_amount'){ if(me.idx == 'change_amount'){
me.change_amount(value) me.change_amount(value)
} else{ } else{
@ -226,9 +224,9 @@ erpnext.payments = erpnext.stock.StockController.extend({
show_amounts: function(){ show_amounts: function(){
var me = this; var me = this;
$(this.$body).find(".write_off_amount").val(format_number(this.frm.doc.write_off_amount, 2)); $(this.$body).find(".write_off_amount").val(flt(this.frm.doc.write_off_amount, precision("write_off_amount")));
$(this.$body).find('.paid_amount').text(format_currency(this.frm.doc.paid_amount, this.frm.doc.currency)); $(this.$body).find('.paid_amount').text(format_currency(this.frm.doc.paid_amount, this.frm.doc.currency));
$(this.$body).find('.change_amount').val(format_number(this.frm.doc.change_amount, 2)) $(this.$body).find('.change_amount').val(flt(this.frm.doc.change_amount, precision("change_amount")))
$(this.$body).find('.outstanding_amount').text(format_currency(this.frm.doc.outstanding_amount, this.frm.doc.currency)) $(this.$body).find('.outstanding_amount').text(format_currency(this.frm.doc.outstanding_amount, this.frm.doc.currency))
this.update_invoice(); this.update_invoice();
} }