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 (backport #37466) (#37703)

fix(defaults): apply discount and provisonal defaults from item group and brand if available (#37466)

(cherry picked from commit 1612d7b)

Co-authored-by: David Arnold <[email protected]>
  • Loading branch information
mergify[bot] and blaggacao authored Oct 26, 2023
1 parent 556095d commit a0893dd
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 @@ -364,8 +364,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 @@ -719,12 +723,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 a0893dd

Please sign in to comment.