Skip to content

Commit

Permalink
fix(defaults): apply discount and provisonal defaults from item group…
Browse files Browse the repository at this point in the history
… and brand if available (#37466)
  • Loading branch information
blaggacao authored Oct 26, 2023
1 parent 6817821 commit 1612d7b
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions erpnext/stock/get_item_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,12 @@ def get_basic_details(args, item, overwrite_warehouse=True):
),
"expense_account": expense_account
or get_default_expense_account(args, item_defaults, item_group_defaults, brand_defaults),
"discount_account": get_default_discount_account(args, item_defaults),
"provisional_expense_account": get_provisional_account(args, item_defaults),
"discount_account": get_default_discount_account(
args, item_defaults, item_group_defaults, brand_defaults
),
"provisional_expense_account": get_provisional_account(
args, item_defaults, item_group_defaults, brand_defaults
),
"cost_center": get_default_cost_center(
args, item_defaults, item_group_defaults, brand_defaults
),
Expand Down Expand Up @@ -686,12 +690,22 @@ def get_default_expense_account(args, item, item_group, brand):
)


def get_provisional_account(args, item):
return item.get("default_provisional_account") or args.default_provisional_account
def get_provisional_account(args, item, item_group, brand):
return (
item.get("default_provisional_account")
or item_group.get("default_provisional_account")
or brand.get("default_provisional_account")
or args.default_provisional_account
)


def get_default_discount_account(args, item):
return item.get("default_discount_account") or args.discount_account
def get_default_discount_account(args, item, item_group, brand):
return (
item.get("default_discount_account")
or item_group.get("default_discount_account")
or brand.get("default_discount_account")
or args.discount_account
)


def get_default_deferred_account(args, item, fieldname=None):
Expand Down

0 comments on commit 1612d7b

Please sign in to comment.