Compare commits

...

10 Commits

Author SHA1 Message Date
Saurabh
8bd9bf2be6 Merge branch 'v12-pre-release' into version-12 2020-08-27 10:04:32 +05:30
Saurabh
fc7121e38f bumped to version 12.11.2 2020-08-27 10:24:32 +05:50
rohitwaghchaure
03488f8285 Merge pull request #23177 from marination/pricing-rule-missing-fix-v12-pre-release
fix: Pricing Rule encoding missing line
2020-08-27 10:00:48 +05:30
marination
4e3bbb8e74 fix: get_applied_pricing_rule in taxes_and_totals 2020-08-26 20:09:11 +05:30
Saurabh
271f8b5cfd Merge branch 'v12-pre-release' into version-12 2020-08-25 20:01:54 +05:30
Saurabh
f26e66b2b5 bumped to version 12.11.1 2020-08-25 20:21:54 +05:50
Saurabh
020534046c Merge pull request #23162 from rohitwaghchaure/pricing-rule-not-working-js-side-v12-pre-release
fix: mixed condition pricing rule not working on js side
2020-08-25 20:01:02 +05:30
Rohit Waghchaure
0407a435d7 fix: mixed condition pricing rule not working on js side 2020-08-25 19:59:17 +05:30
Saurabh
8245640ca2 Merge pull request #23149 from rohitwaghchaure/pricing-rule-encoding-pre-release-v12
fix(hot): Pricing Rule encoding fixed
2020-08-25 17:24:56 +05:30
Rohit Waghchaure
29d24cddcf fix(hot): Pricing Rule encoding fixed 2020-08-25 17:22:20 +05:30
6 changed files with 24 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
__version__ = '12.11.0'
__version__ = '12.11.2'
def get_default_company(user=None):
'''Get default company for user'''

View File

@@ -241,7 +241,7 @@ def get_pricing_rule_for_item(args, price_list_rate=0, doc=None, for_validate=Fa
update_args_for_pricing_rule(args)
pricing_rules = (get_applied_pricing_rules(args)
pricing_rules = (get_applied_pricing_rules(args.get('pricing_rules'))
if for_validate and args.get("pricing_rules") else get_pricing_rules(args, doc))
if pricing_rules:
@@ -369,8 +369,10 @@ def set_discount_amount(rate, item_details):
item_details.rate = rate
def remove_pricing_rule_for_item(pricing_rules, item_details, item_code=None):
from erpnext.accounts.doctype.pricing_rule.utils import get_pricing_rule_items
for d in json.loads(pricing_rules):
from erpnext.accounts.doctype.pricing_rule.utils import (get_applied_pricing_rules,
get_pricing_rule_items)
for d in get_applied_pricing_rules(pricing_rules):
if not d or not frappe.db.exists("Pricing Rule", d): continue
pricing_rule = frappe.get_cached_doc('Pricing Rule', d)
@@ -393,7 +395,8 @@ def remove_pricing_rule_for_item(pricing_rules, item_details, item_code=None):
items = get_pricing_rule_items(pricing_rule)
item_details.apply_on = (frappe.scrub(pricing_rule.apply_rule_on_other)
if pricing_rule.apply_rule_on_other else frappe.scrub(pricing_rule.get('apply_on')))
item_details.applied_on_items = ','.join(items)
item_details.applied_on_items = json.dumps(items)
item_details.price_or_product_discount = pricing_rule.price_or_product_discount
item_details.pricing_rules = ''

View File

@@ -470,9 +470,14 @@ def apply_pricing_rule_on_transaction(doc):
apply_pricing_rule_for_free_items(doc, item_details.free_item_data)
doc.set_missing_values()
def get_applied_pricing_rules(item_row):
return (json.loads(item_row.get("pricing_rules"))
if item_row.get("pricing_rules") else [])
def get_applied_pricing_rules(pricing_rules):
if pricing_rules:
if pricing_rules.startswith('['):
return json.loads(pricing_rules)
else:
return pricing_rules.split(',')
return []
def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None):
free_item = pricing_rule.free_item

View File

@@ -325,7 +325,7 @@ class AccountsController(TransactionBase):
apply_pricing_rule_for_free_items(self, pricing_rule_args.get('free_item_data'))
elif pricing_rule_args.get("validate_applied_rule"):
for pricing_rule in get_applied_pricing_rules(item):
for pricing_rule in get_applied_pricing_rules(item.get('pricing_rules')):
pricing_rule_doc = frappe.get_cached_doc("Pricing Rule", pricing_rule)
for field in ['discount_percentage', 'discount_amount', 'rate']:
if item.get(field) < pricing_rule_doc.get(field):

View File

@@ -9,6 +9,7 @@ from frappe.utils import cint, flt, round_based_on_smallest_currency_fraction
from erpnext.controllers.accounts_controller import validate_conversion_rate, \
validate_taxes_and_charges, validate_inclusive_tax
from erpnext.stock.get_item_details import _get_item_tax_template
from erpnext.accounts.doctype.pricing_rule.utils import get_applied_pricing_rules
class calculate_taxes_and_totals(object):
def __init__(self, doc):
@@ -208,7 +209,7 @@ class calculate_taxes_and_totals(object):
elif tax.charge_type == "On Previous Row Total":
current_tax_fraction = (tax_rate / 100.0) * \
self.doc.get("taxes")[cint(tax.row_id) - 1].grand_total_fraction_for_current_item
elif tax.charge_type == "On Item Quantity":
inclusive_tax_amount_per_qty = flt(tax_rate)
@@ -603,7 +604,7 @@ class calculate_taxes_and_totals(object):
base_rate_with_margin = 0.0
if item.price_list_rate:
if item.pricing_rules and not self.doc.ignore_pricing_rule:
for d in json.loads(item.pricing_rules):
for d in get_applied_pricing_rules(item.pricing_rules):
pricing_rule = frappe.get_cached_doc('Pricing Rule', d)
if (pricing_rule.margin_type == 'Amount' and pricing_rule.currency == self.doc.currency)\

View File

@@ -1413,9 +1413,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
if (data && data.apply_rule_on_other_items) {
me.frm.doc.items.forEach(d => {
if (in_list(data.apply_rule_on_other_items, d[data.apply_rule_on])) {
if (in_list(JSON.parse(data.apply_rule_on_other_items), d[data.apply_rule_on])) {
for(var k in data) {
if (in_list(fields, k) && data[k] && (data.price_or_product_discount === 'price' || k === 'pricing_rules')) {
if (in_list(fields, k) && data[k] && (data.price_or_product_discount === 'Price' || k === 'pricing_rules')) {
frappe.model.set_value(d.doctype, d.name, k, data[k]);
}
}
@@ -1499,9 +1499,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
me.frm.doc.items = items;
refresh_field('items');
} else if(item.applied_on_items && item.apply_on) {
const applied_on_items = item.applied_on_items.split(',');
const applied_on_items = JSON.parse(item.applied_on_items);
me.frm.doc.items.forEach(row => {
if(applied_on_items.includes(row[item.apply_on])) {
if(in_list(applied_on_items, row[item.apply_on])) {
fields.forEach(f => {
row[f] = 0;
});