Merge branch 'develop' into PACKING-SLIP-FOR-DN-PACKED-ITEMS
This commit is contained in:
commit
b4362e5517
@ -125,12 +125,14 @@ def get_revenue(data, period_list, include_in_gross=1):
|
|||||||
|
|
||||||
data_to_be_removed = True
|
data_to_be_removed = True
|
||||||
while data_to_be_removed:
|
while data_to_be_removed:
|
||||||
revenue, data_to_be_removed = remove_parent_with_no_child(revenue, period_list)
|
revenue, data_to_be_removed = remove_parent_with_no_child(revenue)
|
||||||
revenue = adjust_account(revenue, period_list)
|
|
||||||
|
adjust_account_totals(revenue, period_list)
|
||||||
|
|
||||||
return copy.deepcopy(revenue)
|
return copy.deepcopy(revenue)
|
||||||
|
|
||||||
|
|
||||||
def remove_parent_with_no_child(data, period_list):
|
def remove_parent_with_no_child(data):
|
||||||
data_to_be_removed = False
|
data_to_be_removed = False
|
||||||
for parent in data:
|
for parent in data:
|
||||||
if "is_group" in parent and parent.get("is_group") == 1:
|
if "is_group" in parent and parent.get("is_group") == 1:
|
||||||
@ -147,16 +149,19 @@ def remove_parent_with_no_child(data, period_list):
|
|||||||
return data, data_to_be_removed
|
return data, data_to_be_removed
|
||||||
|
|
||||||
|
|
||||||
def adjust_account(data, period_list, consolidated=False):
|
def adjust_account_totals(data, period_list):
|
||||||
leaf_nodes = [item for item in data if item["is_group"] == 0]
|
|
||||||
totals = {}
|
totals = {}
|
||||||
for node in leaf_nodes:
|
for d in reversed(data):
|
||||||
set_total(node, node["total"], data, totals)
|
if d.get("is_group"):
|
||||||
for d in data:
|
|
||||||
for period in period_list:
|
for period in period_list:
|
||||||
key = period if consolidated else period.key
|
# reset totals for group accounts as totals set by get_data doesn't consider include_in_gross check
|
||||||
|
d[period.key] = sum(
|
||||||
|
item[period.key] for item in data if item.get("parent_account") == d.get("account")
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
set_total(d, d["total"], data, totals)
|
||||||
|
|
||||||
d["total"] = totals[d["account"]]
|
d["total"] = totals[d["account"]]
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
def set_total(node, value, complete_list, totals):
|
def set_total(node, value, complete_list, totals):
|
||||||
@ -191,6 +196,9 @@ def get_profit(
|
|||||||
|
|
||||||
if profit_loss[key]:
|
if profit_loss[key]:
|
||||||
has_value = True
|
has_value = True
|
||||||
|
if not profit_loss.get("total"):
|
||||||
|
profit_loss["total"] = 0
|
||||||
|
profit_loss["total"] += profit_loss[key]
|
||||||
|
|
||||||
if has_value:
|
if has_value:
|
||||||
return profit_loss
|
return profit_loss
|
||||||
@ -229,6 +237,9 @@ def get_net_profit(
|
|||||||
|
|
||||||
if profit_loss[key]:
|
if profit_loss[key]:
|
||||||
has_value = True
|
has_value = True
|
||||||
|
if not profit_loss.get("total"):
|
||||||
|
profit_loss["total"] = 0
|
||||||
|
profit_loss["total"] += profit_loss[key]
|
||||||
|
|
||||||
if has_value:
|
if has_value:
|
||||||
return profit_loss
|
return profit_loss
|
||||||
|
Loading…
x
Reference in New Issue
Block a user