Merge branch 'version-12-hotfix' into fixed-incorrect-operation-time-calculation

This commit is contained in:
Marica
2020-10-12 14:54:44 +05:30
committed by GitHub
7 changed files with 37 additions and 12 deletions

View File

@@ -13,8 +13,7 @@ def get_data():
'Auto Repeat': 'reference_document', 'Auto Repeat': 'reference_document',
}, },
'internal_links': { 'internal_links': {
'Sales Order': ['items', 'sales_order'], 'Sales Order': ['items', 'sales_order']
'Delivery Note': ['items', 'delivery_note']
}, },
'transactions': [ 'transactions': [
{ {

View File

@@ -106,6 +106,7 @@ def get_tds_amount(suppliers, net_total, company, tax_details, fiscal_year_detai
from `tabGL Entry` from `tabGL Entry`
where company = %s and where company = %s and
party in %s and fiscal_year=%s and credit > 0 party in %s and fiscal_year=%s and credit > 0
and is_opening = 'No'
""", (company, tuple(suppliers), fiscal_year), as_dict=1) """, (company, tuple(suppliers), fiscal_year), as_dict=1)
vouchers = [d.voucher_no for d in entries] vouchers = [d.voucher_no for d in entries]
@@ -192,6 +193,7 @@ def get_advance_vouchers(suppliers, fiscal_year=None, company=None, from_date=No
select distinct voucher_no select distinct voucher_no
from `tabGL Entry` from `tabGL Entry`
where party in %s and %s and debit > 0 where party in %s and %s and debit > 0
and is_opening = 'No'
""", (tuple(suppliers), condition)) or [] """, (tuple(suppliers), condition)) or []
def get_debit_note_amount(suppliers, year_start_date, year_end_date, company=None): def get_debit_note_amount(suppliers, year_start_date, year_end_date, company=None):

View File

@@ -44,7 +44,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for(let j=0, k=data.length-1; j<k; j++) { %} {% for(let j=0, k=data.length; j<k; j++) { %}
{% {%
var row = data[j]; var row = data[j];
var row_class = data[j].parent_account ? "" : "financial-statements-important"; var row_class = data[j].parent_account ? "" : "financial-statements-important";

View File

@@ -1284,19 +1284,21 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil
validate_quantity(child_item, d) validate_quantity(child_item, d)
child_item.qty = flt(d.get("qty")) child_item.qty = flt(d.get("qty"))
precision = child_item.precision("rate") or 2 rate_precision = child_item.precision("rate") or 2
conv_fac_precision = child_item.precision("conversion_factor") or 2
qty_precision = child_item.precision("qty") or 2
if flt(child_item.billed_amt, precision) > flt(flt(d.get("rate")) * flt(d.get("qty")), precision): if flt(child_item.billed_amt, rate_precision) > flt(flt(d.get("rate"), rate_precision) * flt(d.get("qty"), qty_precision), rate_precision):
frappe.throw(_("Row #{0}: Cannot set Rate if amount is greater than billed amount for Item {1}.") frappe.throw(_("Row #{0}: Cannot set Rate if amount is greater than billed amount for Item {1}.")
.format(child_item.idx, child_item.item_code)) .format(child_item.idx, child_item.item_code))
else: else:
child_item.rate = flt(d.get("rate")) child_item.rate = flt(d.get("rate"), rate_precision)
if d.get("conversion_factor"): if d.get("conversion_factor"):
if child_item.stock_uom == child_item.uom: if child_item.stock_uom == child_item.uom:
child_item.conversion_factor = 1 child_item.conversion_factor = 1
else: else:
child_item.conversion_factor = flt(d.get('conversion_factor')) child_item.conversion_factor = flt(d.get('conversion_factor'), conv_fac_precision)
if d.get("delivery_date") and parent_doctype == 'Sales Order': if d.get("delivery_date") and parent_doctype == 'Sales Order':
child_item.delivery_date = d.get('delivery_date') child_item.delivery_date = d.get('delivery_date')

View File

@@ -452,6 +452,9 @@ erpnext.utils.update_child_items = function(opts) {
const frm = opts.frm; const frm = opts.frm;
const cannot_add_row = (typeof opts.cannot_add_row === 'undefined') ? true : opts.cannot_add_row; const cannot_add_row = (typeof opts.cannot_add_row === 'undefined') ? true : opts.cannot_add_row;
const child_docname = (typeof opts.cannot_add_row === 'undefined') ? "items" : opts.child_docname; const child_docname = (typeof opts.cannot_add_row === 'undefined') ? "items" : opts.child_docname;
const child_meta = frappe.get_meta(`${frm.doc.doctype} Item`);
const get_precision = (fieldname) => child_meta.fields.find(f => f.fieldname == fieldname).precision;
this.data = []; this.data = [];
const fields = [{ const fields = [{
fieldtype:'Data', fieldtype:'Data',
@@ -472,14 +475,16 @@ erpnext.utils.update_child_items = function(opts) {
default: 0, default: 0,
read_only: 0, read_only: 0,
in_list_view: 1, in_list_view: 1,
label: __('Qty') label: __('Qty'),
precision: get_precision("qty")
}, { }, {
fieldtype:'Currency', fieldtype:'Currency',
fieldname:"rate", fieldname:"rate",
default: 0, default: 0,
read_only: 0, read_only: 0,
in_list_view: 1, in_list_view: 1,
label: __('Rate') label: __('Rate'),
precision: get_precision("rate")
}]; }];
if (frm.doc.doctype == 'Sales Order' || frm.doc.doctype == 'Purchase Order' ) { if (frm.doc.doctype == 'Sales Order' || frm.doc.doctype == 'Purchase Order' ) {
@@ -494,7 +499,8 @@ erpnext.utils.update_child_items = function(opts) {
fieldtype: 'Float', fieldtype: 'Float',
fieldname: "conversion_factor", fieldname: "conversion_factor",
in_list_view: 1, in_list_view: 1,
label: __("Conversion Factor") label: __("Conversion Factor"),
precision: get_precision('conversion_factor')
}) })
} }

View File

@@ -129,7 +129,7 @@ class Customer(TransactionBase):
address = frappe.get_doc('Address', address_name.get('name')) address = frappe.get_doc('Address', address_name.get('name'))
if not address.has_link('Customer', self.name): if not address.has_link('Customer', self.name):
address.append('links', dict(link_doctype='Customer', link_name=self.name)) address.append('links', dict(link_doctype='Customer', link_name=self.name))
address.save() address.save(ignore_permissions=self.flags.ignore_permissions)
lead = frappe.db.get_value("Lead", self.lead_name, ["organization_lead", "lead_name", "email_id", "phone", "mobile_no", "gender", "salutation"], as_dict=True) lead = frappe.db.get_value("Lead", self.lead_name, ["organization_lead", "lead_name", "email_id", "phone", "mobile_no", "gender", "salutation"], as_dict=True)
@@ -147,7 +147,7 @@ class Customer(TransactionBase):
contact = frappe.get_doc('Contact', contact_name.get('name')) contact = frappe.get_doc('Contact', contact_name.get('name'))
if not contact.has_link('Customer', self.name): if not contact.has_link('Customer', self.name):
contact.append('links', dict(link_doctype='Customer', link_name=self.name)) contact.append('links', dict(link_doctype='Customer', link_name=self.name))
contact.save() contact.save(ignore_permissions=self.flags.ignore_permissions)
else: else:
lead.lead_name = lead.lead_name.lstrip().split(" ") lead.lead_name = lead.lead_name.lstrip().split(" ")

View File

@@ -403,6 +403,22 @@ class TestSalesOrder(unittest.TestCase):
trans_item = json.dumps([{'item_code' : '_Test Item', 'rate' : 200, 'qty' : 2, 'docname': so.items[0].name}]) trans_item = json.dumps([{'item_code' : '_Test Item', 'rate' : 200, 'qty' : 2, 'docname': so.items[0].name}])
self.assertRaises(frappe.ValidationError, update_child_qty_rate,'Sales Order', trans_item, so.name) self.assertRaises(frappe.ValidationError, update_child_qty_rate,'Sales Order', trans_item, so.name)
def test_update_child_with_precision(self):
from frappe.model.meta import get_field_precision
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
precision = get_field_precision(frappe.get_meta("Sales Order Item").get_field("rate"))
make_property_setter("Sales Order Item", "rate", "precision", 7, "Currency")
so = make_sales_order(item_code= "_Test Item", qty=4, rate=200.34664)
trans_item = json.dumps([{'item_code' : '_Test Item', 'rate' : 200.34669, 'qty' : 4, 'docname': so.items[0].name}])
update_child_qty_rate('Sales Order', trans_item, so.name)
so.reload()
self.assertEqual(so.items[0].rate, 200.34669)
make_property_setter("Sales Order Item", "rate", "precision", precision, "Currency")
def test_update_child_qty_rate_perm(self): def test_update_child_qty_rate_perm(self):
so = make_sales_order(item_code= "_Test Item", qty=4) so = make_sales_order(item_code= "_Test Item", qty=4)