fix: remove multiple accounts from against in capitalization

This commit is contained in:
Gursheen Anand 2023-09-25 20:10:01 +05:30
parent 6e1565c32c
commit f705bf2efe

View File

@ -390,6 +390,7 @@ class AssetCapitalization(StockController):
self.get_gl_dict( self.get_gl_dict(
{ {
"account": account, "account": account,
"against_type": "Account",
"against": target_account, "against": target_account,
"cost_center": item_row.cost_center, "cost_center": item_row.cost_center,
"project": item_row.get("project") or self.get("project"), "project": item_row.get("project") or self.get("project"),
@ -431,6 +432,7 @@ class AssetCapitalization(StockController):
self.set_consumed_asset_status(asset) self.set_consumed_asset_status(asset)
for gle in fixed_asset_gl_entries: for gle in fixed_asset_gl_entries:
gle["against_type"] = "Account"
gle["against"] = target_account gle["against"] = target_account
gl_entries.append(self.get_gl_dict(gle, item=item)) gl_entries.append(self.get_gl_dict(gle, item=item))
target_against.add(gle["account"]) target_against.add(gle["account"])
@ -447,6 +449,7 @@ class AssetCapitalization(StockController):
self.get_gl_dict( self.get_gl_dict(
{ {
"account": item_row.expense_account, "account": item_row.expense_account,
"against_type": "Account",
"against": target_account, "against": target_account,
"cost_center": item_row.cost_center, "cost_center": item_row.cost_center,
"project": item_row.get("project") or self.get("project"), "project": item_row.get("project") or self.get("project"),
@ -458,15 +461,17 @@ class AssetCapitalization(StockController):
) )
def get_gl_entries_for_target_item(self, gl_entries, target_against, precision): def get_gl_entries_for_target_item(self, gl_entries, target_against, precision):
for target_account in target_against:
if self.target_is_fixed_asset: if self.target_is_fixed_asset:
# Capitalization # Capitalization
gl_entries.append( gl_entries.append(
self.get_gl_dict( self.get_gl_dict(
{ {
"account": self.target_fixed_asset_account, "account": self.target_fixed_asset_account,
"against": ", ".join(target_against), "against_type": "Account",
"against": target_account,
"remarks": self.get("remarks") or _("Accounting Entry for Asset"), "remarks": self.get("remarks") or _("Accounting Entry for Asset"),
"debit": flt(self.total_value, precision), "debit": flt(self.total_value, precision) / len(target_against),
"cost_center": self.get("cost_center"), "cost_center": self.get("cost_center"),
}, },
item=self, item=self,
@ -483,11 +488,12 @@ class AssetCapitalization(StockController):
self.get_gl_dict( self.get_gl_dict(
{ {
"account": account, "account": account,
"against": ", ".join(target_against), "against_type": "Account",
"against": target_account,
"cost_center": self.cost_center, "cost_center": self.cost_center,
"project": self.get("project"), "project": self.get("project"),
"remarks": self.get("remarks") or "Accounting Entry for Stock", "remarks": self.get("remarks") or "Accounting Entry for Stock",
"debit": stock_value_difference, "debit": stock_value_difference / len(target_against),
}, },
self.warehouse_account[sle.warehouse]["account_currency"], self.warehouse_account[sle.warehouse]["account_currency"],
item=self, item=self,