Since we have Service Order process I need to generate accounting entries for specific accounts in Delivery Note could someone help me with this case
here is my existing code I have test through msgprint the gl_entries it does have value but it doesn’t create document in GL Entry
import frappe
from erpnext.stock.doctype.delivery_note.delivery_note import DeliveryNote
from erpnext.accounts.general_ledger import (
make_gl_entries,
make_reverse_gl_entries,
process_gl_map,
)
class CustomDeliveryNote(DeliveryNote):
def validate(self):
pass
def on_submit(self):
self.make_gl_entries()
def before_save(self):
self.make_gl_entries()
def create_gl_entries(self, gl_entries):
"""
Creates GL Entries of COS and CWIP
"""
if self.custom_is_service_order:
wo_name = self.items[0].against_sales_order
se_detail_filters = {
"custom_sales_order": wo_name,
"docstatus": 1
}
se_detail = frappe.get_all("Stock Entry Detail", filters=se_detail_filters, fields=["*"])
amount = [ item.amount for item in se_detail ]
# COS Default Company Account
debit_account = frappe.get_value("Company", self.company, "default_expense_account")
# Capital Work in Progress
credit_account = self.items[0].expense_account
gl_entries.append(
self.get_gl_dict({
"account": debit_account,
"posting_date": self.posting_date,
"against": credit_account,
"debit": amount,
"debit_in_account_currency": amount,
"voucher_no": self.name,
"voucher_type": self.doctype,
"project": self.items[0].project,
"cost_center": self.items[0].cost_center,
"remarks": "TEST"
},
"PHP",
item=self,
)
)
# Create Credit Capital Work in Progress GL Entry
gl_entries.append(
self.get_gl_dict({
"account": credit_account,
"posting_date": self.posting_date,
"against": debit_account,
"credit": amount,
"credit_in_account_currency": amount,
"voucher_no": self.name,
"voucher_type": self.doctype,
"project": self.project,
"cost_center": self.items[0].cost_center,
"remarks": "TEST"
},
"PHP",
item=self,
)
)
def make_gl_entries(self, gl_entries=None, from_repost=False, via_landed_cost_voucher=False):
gl_entries = []
# Create Debit GL Entry
self.create_gl_entries(gl_entries)
process_gl_map(gl_entries)
make_gl_entries(gl_entries)