diff --git a/erpnext/__init__.py b/erpnext/__init__.py index b69bb4ebdc8..1dfe47dd711 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '11.1.61' +__version__ = '11.1.62' def get_default_company(user=None): '''Get default company for user''' diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index dd168e32d52..9c176abb582 100755 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -41,6 +41,8 @@ def get_pos_data(): items_list = get_items_list(pos_profile, doc.company) customers = get_customers_list(pos_profile) + doc.plc_conversion_rate = update_plc_conversion_rate(doc, pos_profile) + return { 'doc': doc, 'default_customer': pos_profile.get('customer'), @@ -53,7 +55,7 @@ def get_pos_data(): 'batch_no_data': get_batch_no_data(), 'barcode_data': get_barcode_data(items_list), 'tax_data': get_item_tax_data(), - 'price_list_data': get_price_list_data(doc.selling_price_list), + 'price_list_data': get_price_list_data(doc.selling_price_list, doc.plc_conversion_rate), 'customer_wise_price_list': get_customer_wise_price_list(), 'bin_data': get_bin_data(pos_profile), 'pricing_rules': get_pricing_rule_data(doc), @@ -62,6 +64,15 @@ def get_pos_data(): 'meta': get_meta() } +def update_plc_conversion_rate(doc, pos_profile): + conversion_rate = 1.0 + + price_list_currency = frappe.get_cached_value("Price List", doc.selling_price_list, "currency") + if pos_profile.get("currency") != price_list_currency: + conversion_rate = get_exchange_rate(price_list_currency, + pos_profile.get("currency"), nowdate(), args="for_selling") or 1.0 + + return conversion_rate def get_meta(): doctype_meta = { @@ -317,14 +328,14 @@ def get_item_tax_data(): return itemwise_tax -def get_price_list_data(selling_price_list): +def get_price_list_data(selling_price_list, conversion_rate): itemwise_price_list = {} price_lists = frappe.db.sql("""Select ifnull(price_list_rate, 0) as price_list_rate, item_code from `tabItem Price` ip where price_list = %(price_list)s""", {'price_list': selling_price_list}, as_dict=1) for item in price_lists: - itemwise_price_list[item.item_code] = item.price_list_rate + itemwise_price_list[item.item_code] = item.price_list_rate * conversion_rate return itemwise_price_list diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 5cf76728e62..a56411ad1fc 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -207,7 +207,7 @@ class SalesInvoice(SellingController): for payment in self.payments: total_amount_in_payments += payment.amount invoice_total = self.rounded_total or self.grand_total - if total_amount_in_payments < invoice_total: + if flt(total_amount_in_payments, self.precision("grand_total")) < invoice_total: frappe.throw(_("Total payments amount can't be greater than {}".format(-invoice_total))) def validate_pos_paid_amount(self): diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index ef18cdd91cd..428e68ae1b2 100755 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -1625,7 +1625,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ setTimeout(function () { w.print(); w.close(); - }, 1000) + }, 1000); }, submit_invoice: function () { @@ -1682,6 +1682,12 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ $(this.wrapper).find('.pos-bill').css('pointer-events', pointer_events); $(this.wrapper).find('.pos-items-section').css('pointer-events', pointer_events); this.set_primary_action(); + + $(this.wrapper).find('#pos-item-disc').prop('disabled', + this.pos_profile_data.allow_user_to_edit_discount ? false : true); + + $(this.wrapper).find('#pos-item-price').prop('disabled', + this.pos_profile_data.allow_user_to_edit_rate ? false : true); }, create_invoice: function () { @@ -1699,13 +1705,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ if (this.frm.doc.offline_pos_name && in_list(existing_pos_list, this.frm.doc.offline_pos_name)) { this.update_invoice() - //to retrieve and set the default payment - invoice_data[this.frm.doc.offline_pos_name] = this.frm.doc; - invoice_data[this.frm.doc.offline_pos_name].payments[0].amount = this.frm.doc.net_total - invoice_data[this.frm.doc.offline_pos_name].payments[0].base_amount = this.frm.doc.net_total - - this.frm.doc.paid_amount = this.frm.doc.net_total - this.frm.doc.outstanding_amount = 0 } else if(!this.frm.doc.offline_pos_name) { this.frm.doc.offline_pos_name = frappe.datetime.now_datetime(); this.frm.doc.posting_date = frappe.datetime.get_today(); @@ -1907,7 +1906,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ serial_no = me.item_serial_no[key][0]; } - if (this.items[0].has_serial_no && serial_no == "") { + if (this.items && this.items[0].has_serial_no && serial_no == "") { this.refresh(); frappe.throw(__(repl("Error: Serial no is mandatory for item %(item)s", { 'item': this.items[0].item_code diff --git a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py index 7551eae229e..224f8136f49 100644 --- a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py +++ b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py @@ -56,8 +56,7 @@ def assign_tasks(asset_maintenance_name, assign_to_member, maintenance_task, nex def calculate_next_due_date(periodicity, start_date = None, end_date = None, last_completion_date = None, next_due_date = None): if not start_date and not last_completion_date: start_date = frappe.utils.now() - - if last_completion_date and (last_completion_date > start_date or not start_date): + if last_completion_date and ((start_date and last_completion_date > start_date) or not start_date): start_date = last_completion_date if periodicity == 'Daily': next_due_date = add_days(start_date, 1) @@ -115,4 +114,4 @@ def get_maintenance_log(asset_name): select maintenance_status, count(asset_name) as count, asset_name from `tabAsset Maintenance Log` where asset_name=%s group by maintenance_status""", - (asset_name), as_dict=1) \ No newline at end of file + (asset_name), as_dict=1) diff --git a/erpnext/erpnext_integrations/connectors/woocommerce_connection.py b/erpnext/erpnext_integrations/connectors/woocommerce_connection.py index 0b6ea8cc7ca..adc2391f290 100644 --- a/erpnext/erpnext_integrations/connectors/woocommerce_connection.py +++ b/erpnext/erpnext_integrations/connectors/woocommerce_connection.py @@ -62,7 +62,8 @@ def _order(*args, **kwargs): item_woo_com_id = item.get("product_id") - if frappe.get_value("Item",{"woocommerce_id": item_woo_com_id}): + if frappe.get_value("Item",{"woocommerce_id": item_woo_com_id}) or\ + frappe.get_value("Item",{"item_name": item.get('name')}): #Edit link_item(item,1) else: diff --git a/erpnext/regional/italy/e-invoice.xml b/erpnext/regional/italy/e-invoice.xml index 9978dc0da2e..0a5bb296a5f 100644 --- a/erpnext/regional/italy/e-invoice.xml +++ b/erpnext/regional/italy/e-invoice.xml @@ -1,5 +1,11 @@ {%- macro format_float(value, precision=2) -%} -{{ value|round(frappe.utils.cint(precision)) }} +{%- if frappe.utils.cint(precision) == 3 %} +{{ "%.3f" % value|abs }} +{%- elif frappe.utils.cint(precision) == 4 -%} +{{ "%.4f" % value|abs }} +{%- else -%} +{{ "%.2f" % value|abs }} +{%- endif %} {%- endmacro -%} {%- macro render_address(address) %} diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py index ffcfa2edb37..05e1abd8a4c 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.py +++ b/erpnext/setup/doctype/naming_series/naming_series.py @@ -151,7 +151,7 @@ class NamingSeries(Document): def insert_series(self, series): """insert series if missing""" - if not frappe.db.get_value('Series', series, 'name', order_by="name"): + if frappe.db.get_value('Series', series, 'name', order_by="name") == None: frappe.db.sql("insert into tabSeries (name, current) values (%s, 0)", (series)) def update_series_start(self):