Merge pull request #4069 from anandpdoshi/round-status-updater-percentages

Round status update percentages to 2 decimals
This commit is contained in:
Anand Doshi 2015-09-28 19:40:01 +05:30
commit 6534ad082d
4 changed files with 18 additions and 2 deletions

View File

@ -207,10 +207,10 @@ class StatusUpdater(Document):
# update percent complete in the parent table # update percent complete in the parent table
if args.get('target_parent_field'): if args.get('target_parent_field'):
frappe.db.sql("""update `tab%(target_parent_dt)s` frappe.db.sql("""update `tab%(target_parent_dt)s`
set %(target_parent_field)s = (select sum(if(%(target_ref_field)s > set %(target_parent_field)s = round((select sum(if(%(target_ref_field)s >
ifnull(%(target_field)s, 0), %(target_field)s, ifnull(%(target_field)s, 0), %(target_field)s,
%(target_ref_field)s))/sum(%(target_ref_field)s)*100 %(target_ref_field)s))/sum(%(target_ref_field)s)*100
from `tab%(target_dt)s` where parent="%(name)s") %(set_modified)s from `tab%(target_dt)s` where parent="%(name)s"), 2) %(set_modified)s
where name='%(name)s'""" % args) where name='%(name)s'""" % args)
# update field # update field

View File

@ -211,3 +211,4 @@ erpnext.patches.v6_2.remove_newsletter_duplicates
erpnext.patches.v6_2.fix_missing_default_taxes_and_lead erpnext.patches.v6_2.fix_missing_default_taxes_and_lead
erpnext.patches.v5_8.tax_rule erpnext.patches.v5_8.tax_rule
erpnext.patches.v6_3.convert_applicable_territory erpnext.patches.v6_3.convert_applicable_territory
erpnext.patches.v6_4.round_status_updater_percentages

View File

@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@ -0,0 +1,14 @@
from __future__ import unicode_literals
import frappe
def execute():
for doctype, fieldname in (
("Sales Order", "per_billed"),
("Sales Order", "per_delivered"),
("Delivery Note", "per_installed"),
("Purchase Order", "per_billed"),
("Purchase Order", "per_received"),
("Material Request", "per_ordered"),
):
frappe.db.sql("""update `tab{doctype}` set `{fieldname}`=round(`{fieldname}`, 2)""".format(
doctype=doctype, fieldname=fieldname))