From ea278b59719e0adefe068388fdae0dd7d59837a7 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 21 Jul 2016 23:28:04 +0530 Subject: [PATCH] [Fix]POS and timesheet issues --- erpnext/accounts/doctype/sales_invoice/pos.py | 18 ++++++------ erpnext/accounts/page/pos/pos.js | 29 ++++++++++++------- .../timesheet_detail/timesheet_detail.json | 4 +-- .../public/js/controllers/taxes_and_totals.js | 6 ++-- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index f986eeae23..605bf097f7 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -71,7 +71,7 @@ def get_root(table): def update_multi_mode_option(doc, pos_profile): from frappe.model import default_fields - if not pos_profile: + if not pos_profile or not pos_profile.get('payments'): for payment in get_mode_of_payment(doc): payments = doc.append('payments', {}) payments.mode_of_payment = payment.parent @@ -166,13 +166,14 @@ def make_invoice(doc_list): for docs in doc_list: for name, doc in docs.items(): - validate_customer(doc) - validate_item(doc) - si_doc = frappe.new_doc('Sales Invoice') - si_doc.offline_pos_name = name - si_doc.update(doc) - submit_invoice(si_doc, name) - name_list.append(name) + if not frappe.db.exists('Sales Invoice', {'offline_pos_name': name}): + validate_customer(doc) + validate_item(doc) + si_doc = frappe.new_doc('Sales Invoice') + si_doc.offline_pos_name = name + si_doc.update(doc) + submit_invoice(si_doc, name) + name_list.append(name) return name_list @@ -213,7 +214,6 @@ def submit_invoice(si_doc, name): save_invoice(e, si_doc, name) def save_invoice(e, si_doc, name): - if not frappe.db.exists('Sales Invoice', {'offline_pos_name': name, 'docstatus': 1}): si_doc.docstatus = 0 si_doc.name = '' si_doc.save(ignore_permissions=True) diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index 49cbdd0a68..cb57ff406f 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -104,9 +104,10 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.page.add_menu_item(__("Sync Master Data"), function(){ me.get_data_from_server(function(){ - me.load_data(); + me.load_data(false); me.make_customer(); me.make_item_list(); + me.set_missing_values(); }) }); @@ -151,7 +152,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ if(doc_data){ me.frm.doc = doc_data[0][me.name]; me.set_missing_values(); - me.refresh(); + me.refresh(false); me.disable_input_field(); me.list_dialog.hide(); } @@ -177,6 +178,10 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ if(this.frm.doc.payments.length == 0){ this.frm.doc.payments = doc.payments; } + + if(this.frm.doc.customer){ + this.party_field.$input.val(this.frm.doc.customer); + } }, get_invoice_doc: function(si_docs){ @@ -222,15 +227,18 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ var me = this; this.frm = {} this.name = ''; - this.load_data(); + this.load_data(true); this.setup(); }, - load_data: function(){ + load_data: function(load_doc){ this.items = window.items; this.customers = window.customers; this.pricing_rules = window.pricing_rules; - this.frm.doc = JSON.parse(localStorage.getItem('doc')); + + if(load_doc) { + this.frm.doc = JSON.parse(localStorage.getItem('doc')); + } $.each(window.meta, function(i, data){ frappe.meta.sync(data) @@ -302,7 +310,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ make_customer: function() { var me = this; - if(this.default_customer){ + if(this.default_customer && !this.frm.doc.customer){ this.party_field.$input.val(this.default_customer); this.frm.doc.customer = this.default_customer; } @@ -535,7 +543,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ customer_validate: function(){ var me = this; - if(!this.frm.doc.customer){ frappe.throw(__("Please select customer")) } @@ -598,21 +605,21 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ ? this.item_serial_no[this.child.item_code][0] : ''); }, - refresh: function() { + refresh: function(update_paid_amount) { var me = this; - this.refresh_fields(); + this.refresh_fields(update_paid_amount); this.update_qty(); this.update_rate(); this.set_primary_action(); }, - refresh_fields: function() { + refresh_fields: function(update_paid_amount) { this.apply_pricing_rule(); this.discount_amount_applied = false; this._calculate_taxes_and_totals(); this.calculate_discount_amount(); this.show_items_in_item_cart(); this.set_taxes(); - this.calculate_outstanding_amount(); + this.calculate_outstanding_amount(update_paid_amount); this.set_totals(); }, diff --git a/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json b/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json index ce8c56959e..9413629d7f 100644 --- a/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json +++ b/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json @@ -394,7 +394,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "depends_on": "project", + "depends_on": "", "fieldname": "task", "fieldtype": "Link", "hidden": 0, @@ -532,7 +532,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2016-07-18 13:57:29.873073", + "modified": "2016-07-21 09:59:01.622745", "modified_by": "Administrator", "module": "Projects", "name": "Timesheet Detail", diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 236eb82473..8405e3d3c9 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -75,7 +75,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, precision("conversion_rate")); var conversion_rate_label = frappe.meta.get_label(this.frm.doc.doctype, "conversion_rate", this.frm.doc.name); - var company_currency = this.get_company_currency(); + var company_currency = this.frm.doc.currency || this.get_company_currency(); if(!this.frm.doc.conversion_rate) { if(this.frm.doc.currency == company_currency) { @@ -427,7 +427,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ this.frm.doc.currency, precision("rounded_total")); } if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) { - var company_currency = this.get_company_currency(); + var company_currency = this.frm.doc.currency || this.get_company_currency(); this.frm.doc.base_rounded_total = round_based_on_smallest_currency_fraction(this.frm.doc.base_grand_total, @@ -587,7 +587,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ if(data.type == "Cash" && payment_status) { data.amount = total_amount_to_pay; payment_status = false; - }else{ + }else if(me.frm.doc.paid_amount){ data.amount = 0.0; } })