fix: Opening accounting entry for stock entry
This commit is contained in:
parent
7327f8a901
commit
8770ea2631
@ -80,7 +80,7 @@ class StockController(AccountsController):
|
|||||||
"cost_center": item_row.cost_center,
|
"cost_center": item_row.cost_center,
|
||||||
"remarks": self.get("remarks") or "Accounting Entry for Stock",
|
"remarks": self.get("remarks") or "Accounting Entry for Stock",
|
||||||
"debit": flt(sle.stock_value_difference, 2),
|
"debit": flt(sle.stock_value_difference, 2),
|
||||||
"is_opening": item_row.get("is_opening"),
|
"is_opening": item_row.get("is_opening") or self.get("is_opening") or "No",
|
||||||
}, warehouse_account[sle.warehouse]["account_currency"]))
|
}, warehouse_account[sle.warehouse]["account_currency"]))
|
||||||
|
|
||||||
# to target warehouse / expense account
|
# to target warehouse / expense account
|
||||||
@ -91,7 +91,7 @@ class StockController(AccountsController):
|
|||||||
"remarks": self.get("remarks") or "Accounting Entry for Stock",
|
"remarks": self.get("remarks") or "Accounting Entry for Stock",
|
||||||
"credit": flt(sle.stock_value_difference, 2),
|
"credit": flt(sle.stock_value_difference, 2),
|
||||||
"project": item_row.get("project") or self.get("project"),
|
"project": item_row.get("project") or self.get("project"),
|
||||||
"is_opening": item_row.get("is_opening")
|
"is_opening": item_row.get("is_opening") or self.get("is_opening") or "No"
|
||||||
}))
|
}))
|
||||||
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)
|
||||||
|
|||||||
@ -1963,6 +1963,40 @@
|
|||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
|
"fieldname": "is_opening",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Is Opening",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "No\nYes",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_in_quick_entry": 0,
|
"allow_in_quick_entry": 0,
|
||||||
@ -2246,7 +2280,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2019-03-26 12:24:46.439626",
|
"modified": "2019-05-23 12:24:46.439626",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Entry",
|
"name": "Stock Entry",
|
||||||
@ -2339,4 +2373,4 @@
|
|||||||
"track_changes": 1,
|
"track_changes": 1,
|
||||||
"track_seen": 0,
|
"track_seen": 0,
|
||||||
"track_views": 0
|
"track_views": 0
|
||||||
}
|
}
|
||||||
@ -17,6 +17,7 @@ from erpnext.manufacturing.doctype.bom.bom import validate_bom_no, add_additiona
|
|||||||
from erpnext.stock.utils import get_bin
|
from erpnext.stock.utils import get_bin
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from erpnext.stock.doctype.serial_no.serial_no import update_serial_nos_after_submit, get_serial_nos
|
from erpnext.stock.doctype.serial_no.serial_no import update_serial_nos_after_submit, get_serial_nos
|
||||||
|
from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation import OpeningEntryAccountError
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ class StockEntry(StockController):
|
|||||||
self.validate_batch()
|
self.validate_batch()
|
||||||
self.validate_inspection()
|
self.validate_inspection()
|
||||||
self.validate_fg_completed_qty()
|
self.validate_fg_completed_qty()
|
||||||
|
self.validate_difference_account()
|
||||||
self.set_job_card_data()
|
self.set_job_card_data()
|
||||||
self.set_purpose_for_stock_entry()
|
self.set_purpose_for_stock_entry()
|
||||||
|
|
||||||
@ -226,7 +228,19 @@ class StockEntry(StockController):
|
|||||||
production_item = frappe.get_value('Work Order', self.work_order, 'production_item')
|
production_item = frappe.get_value('Work Order', self.work_order, 'production_item')
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
if item.item_code == production_item and item.qty != self.fg_completed_qty:
|
if item.item_code == production_item and item.qty != self.fg_completed_qty:
|
||||||
frappe.throw(_("Finished product quantity <b>{0}</b> and For Quantity <b>{1}</b> cannot be different").format(item.qty, self.fg_completed_qty))
|
frappe.throw(_("Finished product quantity <b>{0}</b> and For Quantity <b>{1}</b> cannot be different")
|
||||||
|
.format(item.qty, self.fg_completed_qty))
|
||||||
|
|
||||||
|
def validate_difference_account(self):
|
||||||
|
if not cint(erpnext.is_perpetual_inventory_enabled(self.company)):
|
||||||
|
return
|
||||||
|
|
||||||
|
for d in self.get("items"):
|
||||||
|
if not d.expense_account:
|
||||||
|
frappe.throw(_("Please enter Difference Account"))
|
||||||
|
elif self.is_opening == "Yes" or not frappe.db.sql("""select name from `tabStock Ledger Entry` limit 1"""):
|
||||||
|
if frappe.db.get_value("Account", d.expense_account, "report_type") == "Profit and Loss":
|
||||||
|
frappe.throw(_("Difference Account must be a Asset/Liability type account, since this Stock Entry is an Opening Entry"), OpeningEntryAccountError)
|
||||||
|
|
||||||
def validate_warehouse(self):
|
def validate_warehouse(self):
|
||||||
"""perform various (sometimes conditional) validations on warehouse"""
|
"""perform various (sometimes conditional) validations on warehouse"""
|
||||||
|
|||||||
@ -238,8 +238,8 @@ class StockReconciliation(StockController):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if not self.expense_account:
|
if not self.expense_account:
|
||||||
msgprint(_("Please enter Expense Account"), raise_exception=1)
|
frappe.throw(_("Please enter Expense Account"))
|
||||||
elif not frappe.db.sql("""select name from `tabStock Ledger Entry` limit 1"""):
|
elif self.reconciliation_purpose == "Opening Stock" or not frappe.db.sql("""select name from `tabStock Ledger Entry` limit 1"""):
|
||||||
if frappe.db.get_value("Account", self.expense_account, "report_type") == "Profit and Loss":
|
if frappe.db.get_value("Account", self.expense_account, "report_type") == "Profit and Loss":
|
||||||
frappe.throw(_("Difference Account must be a Asset/Liability type account, since this Stock Reconciliation is an Opening Entry"), OpeningEntryAccountError)
|
frappe.throw(_("Difference Account must be a Asset/Liability type account, since this Stock Reconciliation is an Opening Entry"), OpeningEntryAccountError)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user