fix: GL entry fixes and validation for intercompany account
This commit is contained in:
@@ -375,12 +375,17 @@ class PurchaseInvoice(BuyingController):
|
||||
def set_inter_company_account(self):
|
||||
"""
|
||||
Set intercompany account for inter warehouse transactions
|
||||
This account will be used in case billing company and internal supplier's
|
||||
This account will be used in case billing company and internal customer's
|
||||
representation company is same
|
||||
"""
|
||||
|
||||
if self.is_internal_transfer() and not self.inter_company_account:
|
||||
self.inter_company_account = frappe.get_cached_value('Company', self.company, 'default_inter_company_account')
|
||||
inter_company_account = frappe.get_cached_value('Company', self.company, 'default_inter_company_account')
|
||||
|
||||
if not inter_company_account:
|
||||
msg = _("Please select inter-company account or add default inter-company account for company {0}").format(
|
||||
frappe.bold(self.company))
|
||||
frappe.throw(msg)
|
||||
|
||||
def is_internal_transfer(self):
|
||||
"""
|
||||
@@ -474,7 +479,6 @@ class PurchaseInvoice(BuyingController):
|
||||
self.make_payment_gl_entries(gl_entries)
|
||||
self.make_write_off_gl_entry(gl_entries)
|
||||
self.make_gle_for_rounding_adjustment(gl_entries)
|
||||
|
||||
return gl_entries
|
||||
|
||||
def check_asset_cwip_enabled(self):
|
||||
@@ -514,7 +518,6 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
def make_item_gl_entries(self, gl_entries):
|
||||
# item gl entries
|
||||
if not self.is_internal_transfer():
|
||||
stock_items = self.get_stock_items()
|
||||
if self.update_stock and self.auto_accounting_for_stock:
|
||||
warehouse_account = get_warehouse_account_map(self.company)
|
||||
@@ -543,7 +546,6 @@ class PurchaseInvoice(BuyingController):
|
||||
item, voucher_wise_stock_value, account_currency)
|
||||
|
||||
if item.from_warehouse:
|
||||
|
||||
gl_entries.append(self.get_gl_dict({
|
||||
"account": warehouse_account[item.warehouse]['account'],
|
||||
"against": warehouse_account[item.from_warehouse]["account"],
|
||||
@@ -563,6 +565,8 @@ class PurchaseInvoice(BuyingController):
|
||||
"debit": -1 * flt(item.base_net_amount, item.precision("base_net_amount")),
|
||||
}, warehouse_account[item.from_warehouse]["account_currency"], item=item))
|
||||
|
||||
# Do not book expense for transfer within same company transfer
|
||||
if not self.is_internal_transfer():
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": item.expense_account,
|
||||
|
||||
@@ -579,7 +579,12 @@ class SalesInvoice(SellingController):
|
||||
"""
|
||||
|
||||
if self.is_internal_transfer() and not self.inter_company_account:
|
||||
self.inter_company_account = frappe.get_cached_value('Company', self.company, 'default_inter_company_account')
|
||||
inter_company_account = frappe.get_cached_value('Company', self.company, 'default_inter_company_account')
|
||||
|
||||
if not inter_company_account:
|
||||
msg = _("Please select inter-company account or add default inter-company account for company {0}").format(
|
||||
frappe.bold(self.company))
|
||||
frappe.throw(msg)
|
||||
|
||||
def is_internal_transfer(self):
|
||||
"""
|
||||
@@ -845,7 +850,6 @@ class SalesInvoice(SellingController):
|
||||
|
||||
def make_item_gl_entries(self, gl_entries):
|
||||
# income account gl entries
|
||||
if not self.is_internal_transfer():
|
||||
for item in self.get("items"):
|
||||
if flt(item.base_net_amount, item.precision("base_net_amount")):
|
||||
if item.is_fixed_asset:
|
||||
@@ -866,6 +870,8 @@ class SalesInvoice(SellingController):
|
||||
asset.db_set("disposal_date", self.posting_date)
|
||||
asset.set_status("Sold" if self.docstatus==1 else None)
|
||||
else:
|
||||
# Do not book income for transfer within same company
|
||||
if not self.is_internal_transfer():
|
||||
income_account = (item.income_account
|
||||
if (not item.enable_deferred_revenue or self.is_return) else item.deferred_revenue_account)
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@ class StockController(AccountsController):
|
||||
}, warehouse_account[sle.warehouse]["account_currency"], item=item_row))
|
||||
|
||||
# expense account/ target_warehouse / source_warehouse
|
||||
if item_row.get('target_warehouse') or item_row.get('from_warehouse'):
|
||||
warehouse = item_row.get('target_warehouse') or item_row.get('from_warehouse')
|
||||
if item_row.get('target_warehouse'):
|
||||
warehouse = item_row.get('target_warehouse')
|
||||
expense_account = warehouse_account[warehouse]["account"]
|
||||
else:
|
||||
expense_account = item_row.expense_account
|
||||
|
||||
Reference in New Issue
Block a user