feat: GL entries

This commit is contained in:
Mihir Kandoi
2025-05-27 15:01:46 +05:30
parent 0f53cc1922
commit 44bec1f981

View File

@@ -562,6 +562,18 @@ class SubcontractingReceipt(SubcontractingController):
def make_item_gl_entries(self, gl_entries, warehouse_account=None): def make_item_gl_entries(self, gl_entries, warehouse_account=None):
warehouse_with_no_account = [] warehouse_with_no_account = []
supplied_items_details = frappe._dict()
for item in self.supplied_items:
supplied_items_details.setdefault(item.reference_name, []).append(
frappe._dict(
{
"amount": item.amount,
"expense_account": item.expense_account,
"cost_center": item.cost_center,
}
)
)
for item in self.items: for item in self.items:
if flt(item.rate) and flt(item.qty): if flt(item.rate) and flt(item.qty):
if warehouse_account.get(item.warehouse): if warehouse_account.get(item.warehouse):
@@ -611,15 +623,16 @@ class SubcontractingReceipt(SubcontractingController):
) )
if flt(item.rm_supp_cost) and supplier_warehouse_account: if flt(item.rm_supp_cost) and supplier_warehouse_account:
for rm_item in supplied_items_details.get(item.name):
# Supplier Warehouse Account (Credit) # Supplier Warehouse Account (Credit)
self.add_gl_entry( self.add_gl_entry(
gl_entries=gl_entries, gl_entries=gl_entries,
account=supplier_warehouse_account, account=supplier_warehouse_account,
cost_center=item.cost_center, cost_center=rm_item.cost_center,
debit=0.0, debit=0.0,
credit=flt(item.rm_supp_cost), credit=flt(rm_item.amount),
remarks=remarks, remarks=remarks,
against_account=item.expense_account, against_account=rm_item.expense_account,
account_currency=get_account_currency(supplier_warehouse_account), account_currency=get_account_currency(supplier_warehouse_account),
project=item.project, project=item.project,
item=item, item=item,
@@ -627,9 +640,9 @@ class SubcontractingReceipt(SubcontractingController):
# Expense Account (Debit) # Expense Account (Debit)
self.add_gl_entry( self.add_gl_entry(
gl_entries=gl_entries, gl_entries=gl_entries,
account=item.expense_account, account=rm_item.expense_account,
cost_center=item.cost_center, cost_center=rm_item.cost_center,
debit=flt(item.rm_supp_cost), debit=flt(rm_item.amount),
credit=0.0, credit=0.0,
remarks=remarks, remarks=remarks,
against_account=supplier_warehouse_account, against_account=supplier_warehouse_account,