Merge branch 'version-11-hotfix' into v11-work-order-bugs
This commit is contained in:
@@ -5,7 +5,7 @@ import frappe
|
|||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
__version__ = '11.1.61'
|
__version__ = '11.1.62'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ def get_pos_data():
|
|||||||
items_list = get_items_list(pos_profile, doc.company)
|
items_list = get_items_list(pos_profile, doc.company)
|
||||||
customers = get_customers_list(pos_profile)
|
customers = get_customers_list(pos_profile)
|
||||||
|
|
||||||
|
doc.plc_conversion_rate = update_plc_conversion_rate(doc, pos_profile)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'doc': doc,
|
'doc': doc,
|
||||||
'default_customer': pos_profile.get('customer'),
|
'default_customer': pos_profile.get('customer'),
|
||||||
@@ -53,7 +55,7 @@ def get_pos_data():
|
|||||||
'batch_no_data': get_batch_no_data(),
|
'batch_no_data': get_batch_no_data(),
|
||||||
'barcode_data': get_barcode_data(items_list),
|
'barcode_data': get_barcode_data(items_list),
|
||||||
'tax_data': get_item_tax_data(),
|
'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(),
|
'customer_wise_price_list': get_customer_wise_price_list(),
|
||||||
'bin_data': get_bin_data(pos_profile),
|
'bin_data': get_bin_data(pos_profile),
|
||||||
'pricing_rules': get_pricing_rule_data(doc),
|
'pricing_rules': get_pricing_rule_data(doc),
|
||||||
@@ -62,6 +64,15 @@ def get_pos_data():
|
|||||||
'meta': get_meta()
|
'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():
|
def get_meta():
|
||||||
doctype_meta = {
|
doctype_meta = {
|
||||||
@@ -317,14 +328,14 @@ def get_item_tax_data():
|
|||||||
return itemwise_tax
|
return itemwise_tax
|
||||||
|
|
||||||
|
|
||||||
def get_price_list_data(selling_price_list):
|
def get_price_list_data(selling_price_list, conversion_rate):
|
||||||
itemwise_price_list = {}
|
itemwise_price_list = {}
|
||||||
price_lists = frappe.db.sql("""Select ifnull(price_list_rate, 0) as price_list_rate,
|
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""",
|
item_code from `tabItem Price` ip where price_list = %(price_list)s""",
|
||||||
{'price_list': selling_price_list}, as_dict=1)
|
{'price_list': selling_price_list}, as_dict=1)
|
||||||
|
|
||||||
for item in price_lists:
|
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
|
return itemwise_price_list
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ class SalesInvoice(SellingController):
|
|||||||
for payment in self.payments:
|
for payment in self.payments:
|
||||||
total_amount_in_payments += payment.amount
|
total_amount_in_payments += payment.amount
|
||||||
invoice_total = self.rounded_total or self.grand_total
|
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)))
|
frappe.throw(_("Total payments amount can't be greater than {}".format(-invoice_total)))
|
||||||
|
|
||||||
def validate_pos_paid_amount(self):
|
def validate_pos_paid_amount(self):
|
||||||
|
|||||||
@@ -1625,7 +1625,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
w.print();
|
w.print();
|
||||||
w.close();
|
w.close();
|
||||||
}, 1000)
|
}, 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
submit_invoice: function () {
|
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-bill').css('pointer-events', pointer_events);
|
||||||
$(this.wrapper).find('.pos-items-section').css('pointer-events', pointer_events);
|
$(this.wrapper).find('.pos-items-section').css('pointer-events', pointer_events);
|
||||||
this.set_primary_action();
|
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 () {
|
create_invoice: function () {
|
||||||
@@ -1699,13 +1705,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
if (this.frm.doc.offline_pos_name
|
if (this.frm.doc.offline_pos_name
|
||||||
&& in_list(existing_pos_list, this.frm.doc.offline_pos_name)) {
|
&& in_list(existing_pos_list, this.frm.doc.offline_pos_name)) {
|
||||||
this.update_invoice()
|
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) {
|
} else if(!this.frm.doc.offline_pos_name) {
|
||||||
this.frm.doc.offline_pos_name = frappe.datetime.now_datetime();
|
this.frm.doc.offline_pos_name = frappe.datetime.now_datetime();
|
||||||
this.frm.doc.posting_date = frappe.datetime.get_today();
|
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];
|
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();
|
this.refresh();
|
||||||
frappe.throw(__(repl("Error: Serial no is mandatory for item %(item)s", {
|
frappe.throw(__(repl("Error: Serial no is mandatory for item %(item)s", {
|
||||||
'item': this.items[0].item_code
|
'item': this.items[0].item_code
|
||||||
|
|||||||
@@ -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):
|
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:
|
if not start_date and not last_completion_date:
|
||||||
start_date = frappe.utils.now()
|
start_date = frappe.utils.now()
|
||||||
|
if last_completion_date and ((start_date and last_completion_date > start_date) or not start_date):
|
||||||
if last_completion_date and (last_completion_date > start_date or not start_date):
|
|
||||||
start_date = last_completion_date
|
start_date = last_completion_date
|
||||||
if periodicity == 'Daily':
|
if periodicity == 'Daily':
|
||||||
next_due_date = add_days(start_date, 1)
|
next_due_date = add_days(start_date, 1)
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ def _order(*args, **kwargs):
|
|||||||
|
|
||||||
item_woo_com_id = item.get("product_id")
|
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
|
#Edit
|
||||||
link_item(item,1)
|
link_item(item,1)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
{%- macro format_float(value, precision=2) -%}
|
{%- 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 -%}
|
{%- endmacro -%}
|
||||||
|
|
||||||
{%- macro render_address(address) %}
|
{%- macro render_address(address) %}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class NamingSeries(Document):
|
|||||||
|
|
||||||
def insert_series(self, series):
|
def insert_series(self, series):
|
||||||
"""insert series if missing"""
|
"""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))
|
frappe.db.sql("insert into tabSeries (name, current) values (%s, 0)", (series))
|
||||||
|
|
||||||
def update_series_start(self):
|
def update_series_start(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user