Merge branch 'hotfix'
This commit is contained in:
commit
1ef72c0b66
@ -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__ = '10.1.49'
|
__version__ = '10.1.50'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
|||||||
@ -15,42 +15,20 @@ def execute():
|
|||||||
buying_doctypes = ["Purchase Order Item", "Purchase Invoice Item", "Purchase Receipt Item", "Supplier Quotation Item"]
|
buying_doctypes = ["Purchase Order Item", "Purchase Invoice Item", "Purchase Receipt Item", "Supplier Quotation Item"]
|
||||||
|
|
||||||
for doctype in selling_doctypes:
|
for doctype in selling_doctypes:
|
||||||
values = frappe.db.sql('''
|
|
||||||
SELECT
|
|
||||||
discount_percentage, rate_with_margin, price_list_rate, name
|
|
||||||
FROM
|
|
||||||
`tab%s`
|
|
||||||
WHERE
|
|
||||||
ifnull(discount_percentage, 0) > 0
|
|
||||||
''' % (doctype), as_dict=True)
|
|
||||||
calculate_discount(doctype, values)
|
|
||||||
|
|
||||||
for doctype in buying_doctypes:
|
|
||||||
values = frappe.db.sql('''
|
|
||||||
SELECT
|
|
||||||
discount_percentage, price_list_rate, name
|
|
||||||
FROM
|
|
||||||
`tab%s`
|
|
||||||
WHERE
|
|
||||||
discount_percentage > 0
|
|
||||||
''' % (doctype), as_dict=True)
|
|
||||||
calculate_discount(doctype, values)
|
|
||||||
|
|
||||||
def calculate_discount(doctype, values):
|
|
||||||
rate = None
|
|
||||||
if not values: return
|
|
||||||
for d in values:
|
|
||||||
if d.rate_with_margin and d.rate_with_margin > 0:
|
|
||||||
rate = d.rate_with_margin
|
|
||||||
else:
|
|
||||||
rate = d.price_list_rate
|
|
||||||
|
|
||||||
discount_value = rate * d.get('discount_percentage') / 100
|
|
||||||
frappe.db.sql('''
|
frappe.db.sql('''
|
||||||
UPDATE
|
UPDATE
|
||||||
`tab%s`
|
`tab%s`
|
||||||
SET
|
SET
|
||||||
discount_amount = %s
|
discount_amount = if(rate_with_margin > 0, rate_with_margin, price_list_rate) * discount_percentage / 100
|
||||||
WHERE
|
WHERE
|
||||||
name = '%s'
|
discount_percentage > 0
|
||||||
''' % (doctype, discount_value, d.get('name')))
|
''' % (doctype))
|
||||||
|
for doctype in buying_doctypes:
|
||||||
|
frappe.db.sql('''
|
||||||
|
UPDATE
|
||||||
|
`tab%s`
|
||||||
|
SET
|
||||||
|
discount_amount = price_list_rate * discount_percentage / 100
|
||||||
|
WHERE
|
||||||
|
discount_percentage > 0
|
||||||
|
''' % (doctype))
|
||||||
@ -33,7 +33,7 @@ def execute(filters=None):
|
|||||||
|
|
||||||
row = [cd.item_code, cd.item_name, cd.description, cd.stock_uom, \
|
row = [cd.item_code, cd.item_name, cd.description, cd.stock_uom, \
|
||||||
consumed_qty, consumed_amount, delivered_qty, delivered_amount, \
|
consumed_qty, consumed_amount, delivered_qty, delivered_amount, \
|
||||||
total_qty, total_amount, list(set(suppliers))]
|
total_qty, total_amount, ','.join(list(set(suppliers)))]
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user