fix: Hanlde rounding loss for internal transfer
(cherry picked from commit 6e47fd54a0)
This commit is contained in:
@@ -139,13 +139,15 @@ class StockController(AccountsController):
|
|||||||
warehouse_with_no_account = []
|
warehouse_with_no_account = []
|
||||||
precision = self.get_debit_field_precision()
|
precision = self.get_debit_field_precision()
|
||||||
for item_row in voucher_details:
|
for item_row in voucher_details:
|
||||||
|
|
||||||
sle_list = sle_map.get(item_row.name)
|
sle_list = sle_map.get(item_row.name)
|
||||||
|
sle_rounding_diff = 0.0
|
||||||
if sle_list:
|
if sle_list:
|
||||||
for sle in sle_list:
|
for sle in sle_list:
|
||||||
if warehouse_account.get(sle.warehouse):
|
if warehouse_account.get(sle.warehouse):
|
||||||
# from warehouse account
|
# from warehouse account
|
||||||
|
|
||||||
|
sle_rounding_diff += flt(sle.stock_value_difference, precision)
|
||||||
|
|
||||||
self.check_expense_account(item_row)
|
self.check_expense_account(item_row)
|
||||||
|
|
||||||
# expense account/ target_warehouse / source_warehouse
|
# expense account/ target_warehouse / source_warehouse
|
||||||
@@ -188,6 +190,42 @@ class StockController(AccountsController):
|
|||||||
elif sle.warehouse not in warehouse_with_no_account:
|
elif sle.warehouse not in warehouse_with_no_account:
|
||||||
warehouse_with_no_account.append(sle.warehouse)
|
warehouse_with_no_account.append(sle.warehouse)
|
||||||
|
|
||||||
|
if sle_rounding_diff > 0:
|
||||||
|
expense_account = item_row.get("expense_account")
|
||||||
|
target_warehouse_account = warehouse_account[item_row.get("target_warehouse")]["account"]
|
||||||
|
source_warehouse_account = warehouse_account[item_row.get("warehouse")]["account"]
|
||||||
|
|
||||||
|
gl_list.append(
|
||||||
|
self.get_gl_dict(
|
||||||
|
{
|
||||||
|
"account": target_warehouse_account or expense_account,
|
||||||
|
"against": expense_account,
|
||||||
|
"cost_center": item_row.cost_center,
|
||||||
|
"project": item_row.project or self.get("project"),
|
||||||
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
|
"debit": sle_rounding_diff,
|
||||||
|
"is_opening": item_row.get("is_opening") or self.get("is_opening") or "No",
|
||||||
|
},
|
||||||
|
warehouse_account[sle.warehouse]["account_currency"],
|
||||||
|
item=item_row,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
gl_list.append(
|
||||||
|
self.get_gl_dict(
|
||||||
|
{
|
||||||
|
"account": source_warehouse_account or expense_account,
|
||||||
|
"against": target_warehouse_account,
|
||||||
|
"cost_center": item_row.cost_center,
|
||||||
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
|
"debit": -1 * sle_rounding_diff,
|
||||||
|
"project": item_row.get("project") or self.get("project"),
|
||||||
|
"is_opening": item_row.get("is_opening") or self.get("is_opening") or "No",
|
||||||
|
},
|
||||||
|
item=item_row,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if warehouse_with_no_account:
|
if warehouse_with_no_account:
|
||||||
for wh in warehouse_with_no_account:
|
for wh in warehouse_with_no_account:
|
||||||
if frappe.db.get_value("Warehouse", wh, "company"):
|
if frappe.db.get_value("Warehouse", wh, "company"):
|
||||||
|
|||||||
Reference in New Issue
Block a user