Merge pull request #3358 from nabinhait/develop
General ledger, _idx and FY in Material request
This commit is contained in:
commit
2fd33a2f03
@ -2,7 +2,7 @@
|
|||||||
{%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %}
|
{%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %}
|
||||||
</div>
|
</div>
|
||||||
<h2 class="text-center">{%= __("Statement of Account") %}</h2>
|
<h2 class="text-center">{%= __("Statement of Account") %}</h2>
|
||||||
<h4 class="text-center">{%= filters.account && (filters.account + ", ") || "" %} {%= filters.company %}</h4>
|
<h4 class="text-center">{%= (filters.party || filters.account) && ((filters.party || filters.account) + ", ") || "" %} {%= filters.company %}</h4>
|
||||||
<h5 class="text-center">
|
<h5 class="text-center">
|
||||||
{%= dateutil.str_to_user(filters.from_date) %}
|
{%= dateutil.str_to_user(filters.from_date) %}
|
||||||
{%= __("to") %}
|
{%= __("to") %}
|
||||||
@ -26,15 +26,20 @@
|
|||||||
<td>{%= dateutil.str_to_user(data[i][__("Posting Date")]) %}</td>
|
<td>{%= dateutil.str_to_user(data[i][__("Posting Date")]) %}</td>
|
||||||
<td>{%= data[i][__("Voucher Type")] %}
|
<td>{%= data[i][__("Voucher Type")] %}
|
||||||
<br>{%= data[i][__("Voucher No")] %}</td>
|
<br>{%= data[i][__("Voucher No")] %}</td>
|
||||||
<td>{%= data[i][__("Account")] %}
|
<td>
|
||||||
<br>{%= __("Against") %}: {%= data[i][__("Against Account")] %}
|
{% if(!(filters.party || filters.account)) { %}
|
||||||
|
{%= data[i][__("Party")] || data[i][__("Account")] %}
|
||||||
|
<br>
|
||||||
|
{% } %}
|
||||||
|
|
||||||
|
{{ __("Against") }}: {%= data[i][__("Against Account")] %}
|
||||||
<br>{%= __("Remarks") %}: {%= data[i][__("Remarks")] %}</td>
|
<br>{%= __("Remarks") %}: {%= data[i][__("Remarks")] %}</td>
|
||||||
<td style="text-align: right">{%= format_currency(data[i][__("Debit")]) %}</td>
|
<td style="text-align: right">{%= format_currency(data[i][__("Debit")]) %}</td>
|
||||||
<td style="text-align: right">{%= format_currency(data[i][__("Credit")]) %}</td>
|
<td style="text-align: right">{%= format_currency(data[i][__("Credit")]) %}</td>
|
||||||
{% } else { %}
|
{% } else { %}
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><b>{%= data[i][__("Account")] || " " %}</b></td>
|
<td><b>{%= frappe.format(data[i][__("Account")], {fieldtype: "Link"}) || " " %}</b></td>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
{%= data[i][__("Account")] && format_currency(data[i][__("Debit")]) %}</td>
|
{%= data[i][__("Account")] && format_currency(data[i][__("Debit")]) %}</td>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
|
@ -9,7 +9,7 @@ from frappe import _
|
|||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
account_details = {}
|
account_details = {}
|
||||||
for acc in frappe.db.sql("""select name, is_group from tabAccount""", as_dict=1):
|
for acc in frappe.db.sql("""select name, is_group from tabAccount""", as_dict=1):
|
||||||
account_details.setdefault(acc.name, acc)
|
account_details.setdefault(acc.name, acc)
|
||||||
|
|
||||||
validate_filters(filters, account_details)
|
validate_filters(filters, account_details)
|
||||||
validate_party(filters)
|
validate_party(filters)
|
||||||
@ -82,8 +82,6 @@ def get_conditions(filters):
|
|||||||
lft, rgt = frappe.db.get_value("Account", filters["account"], ["lft", "rgt"])
|
lft, rgt = frappe.db.get_value("Account", filters["account"], ["lft", "rgt"])
|
||||||
conditions.append("""account in (select name from tabAccount
|
conditions.append("""account in (select name from tabAccount
|
||||||
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
|
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
|
||||||
else:
|
|
||||||
conditions.append("posting_date between %(from_date)s and %(to_date)s")
|
|
||||||
|
|
||||||
if filters.get("voucher_no"):
|
if filters.get("voucher_no"):
|
||||||
conditions.append("voucher_no=%(voucher_no)s")
|
conditions.append("voucher_no=%(voucher_no)s")
|
||||||
@ -107,7 +105,7 @@ def get_data_with_opening_closing(filters, account_details, gl_entries):
|
|||||||
opening, total_debit, total_credit, gle_map = get_accountwise_gle(filters, gl_entries, gle_map)
|
opening, total_debit, total_credit, gle_map = get_accountwise_gle(filters, gl_entries, gle_map)
|
||||||
|
|
||||||
# Opening for filtered account
|
# Opening for filtered account
|
||||||
if filters.get("account"):
|
if filters.get("account") or filters.get("party"):
|
||||||
data += [get_balance_row(_("Opening"), opening), {}]
|
data += [get_balance_row(_("Opening"), opening), {}]
|
||||||
|
|
||||||
for acc, acc_dict in gle_map.items():
|
for acc, acc_dict in gle_map.items():
|
||||||
@ -130,7 +128,7 @@ def get_data_with_opening_closing(filters, account_details, gl_entries):
|
|||||||
data.append({"account": "'" + _("Totals") + "'", "debit": total_debit, "credit": total_credit})
|
data.append({"account": "'" + _("Totals") + "'", "debit": total_debit, "credit": total_credit})
|
||||||
|
|
||||||
# Closing for filtered account
|
# Closing for filtered account
|
||||||
if filters.get("account"):
|
if filters.get("account") or filters.get("party"):
|
||||||
data.append(get_balance_row(_("Closing (Opening + Totals)"),
|
data.append(get_balance_row(_("Closing (Opening + Totals)"),
|
||||||
(opening + total_debit - total_credit)))
|
(opening + total_debit - total_credit)))
|
||||||
|
|
||||||
@ -153,9 +151,10 @@ def get_accountwise_gle(filters, gl_entries, gle_map):
|
|||||||
|
|
||||||
for gle in gl_entries:
|
for gle in gl_entries:
|
||||||
amount = flt(gle.debit, 3) - flt(gle.credit, 3)
|
amount = flt(gle.debit, 3) - flt(gle.credit, 3)
|
||||||
if filters.get("account") and gle.posting_date < getdate(filters.from_date):
|
if gle.posting_date < getdate(filters.from_date):
|
||||||
gle_map[gle.account].opening += amount
|
gle_map[gle.account].opening += amount
|
||||||
opening += amount
|
if filters.get("account") or filters.get("party"):
|
||||||
|
opening += amount
|
||||||
elif gle.posting_date <= getdate(filters.to_date):
|
elif gle.posting_date <= getdate(filters.to_date):
|
||||||
gle_map[gle.account].entries.append(gle)
|
gle_map[gle.account].entries.append(gle)
|
||||||
gle_map[gle.account].total_debit += flt(gle.debit, 3)
|
gle_map[gle.account].total_debit += flt(gle.debit, 3)
|
||||||
|
@ -359,10 +359,7 @@ class ProductionPlanningTool(Document):
|
|||||||
|
|
||||||
def insert_purchase_request(self):
|
def insert_purchase_request(self):
|
||||||
items_to_be_requested = self.get_requested_items()
|
items_to_be_requested = self.get_requested_items()
|
||||||
|
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
|
||||||
fiscal_year = get_fiscal_year(nowdate())[0]
|
|
||||||
|
|
||||||
purchase_request_list = []
|
purchase_request_list = []
|
||||||
if items_to_be_requested:
|
if items_to_be_requested:
|
||||||
for item in items_to_be_requested:
|
for item in items_to_be_requested:
|
||||||
@ -372,7 +369,6 @@ class ProductionPlanningTool(Document):
|
|||||||
"transaction_date": nowdate(),
|
"transaction_date": nowdate(),
|
||||||
"status": "Draft",
|
"status": "Draft",
|
||||||
"company": self.company,
|
"company": self.company,
|
||||||
"fiscal_year": fiscal_year,
|
|
||||||
"requested_by": frappe.session.user,
|
"requested_by": frappe.session.user,
|
||||||
"material_request_type": "Purchase"
|
"material_request_type": "Purchase"
|
||||||
})
|
})
|
||||||
|
@ -16,6 +16,9 @@ def execute():
|
|||||||
|
|
||||||
for name, script in frappe.db.sql("select name, {0} as script from `tab{1}` where ({2}) {3}".format(script_field, dt, cond1, cond2)):
|
for name, script in frappe.db.sql("select name, {0} as script from `tab{1}` where ({2}) {3}".format(script_field, dt, cond1, cond2)):
|
||||||
update_script(dt, name, script_field, script, renamed_fields)
|
update_script(dt, name, script_field, script, renamed_fields)
|
||||||
|
|
||||||
|
# update fieldnames in property setter for idx
|
||||||
|
update_idx_property(renamed_fields)
|
||||||
|
|
||||||
def get_all_renamed_fields():
|
def get_all_renamed_fields():
|
||||||
from erpnext.patches.v5_0.rename_table_fieldnames import rename_map
|
from erpnext.patches.v5_0.rename_table_fieldnames import rename_map
|
||||||
@ -63,3 +66,20 @@ def update_script(dt, name, script_field, script, renamed_fields):
|
|||||||
script = re.sub(r"\bentries\b", "items", script)
|
script = re.sub(r"\bentries\b", "items", script)
|
||||||
|
|
||||||
frappe.db.set_value(dt, name, script_field, script)
|
frappe.db.set_value(dt, name, script_field, script)
|
||||||
|
|
||||||
|
def update_idx_property(renamed_fields):
|
||||||
|
for ps, ordered_fields, dt in frappe.db.sql("select name, value, doc_type from `tabProperty Setter` where property = '_idx'"):
|
||||||
|
for from_field, to_field in renamed_fields:
|
||||||
|
if from_field in ordered_fields:
|
||||||
|
ordered_fields[ordered_fields.index(from_field)] = to_field
|
||||||
|
|
||||||
|
# remove invalid fields
|
||||||
|
valid_fields = [f.fieldname for f in frappe.get_meta(dt).fields]
|
||||||
|
for fld in ordered_fields:
|
||||||
|
if fld not in valid_fields:
|
||||||
|
ordered_fields.pop(fld)
|
||||||
|
|
||||||
|
frappe.db.set_value("Property Setter", ps, "value", ordered_fields)
|
||||||
|
|
||||||
|
|
||||||
|
frappe.db.sql("delete from `tabProperty Setter` where `property` = 'idx'")
|
@ -4,4 +4,5 @@ def execute():
|
|||||||
frappe.reload_doctype("System Settings")
|
frappe.reload_doctype("System Settings")
|
||||||
ss = frappe.get_doc("System Settings", "System Settings")
|
ss = frappe.get_doc("System Settings", "System Settings")
|
||||||
ss.email_footer_address = frappe.db.get_default("company")
|
ss.email_footer_address = frappe.db.get_default("company")
|
||||||
|
ss.flags.ignore_mandatory = True
|
||||||
ss.save()
|
ss.save()
|
||||||
|
@ -14,19 +14,21 @@ $.extend(erpnext, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get_fiscal_year: function(company, date, fn) {
|
get_fiscal_year: function(company, date, fn) {
|
||||||
frappe.call({
|
if(frappe.meta.get_docfield(cur_frm.doctype, "fiscal_year")) {
|
||||||
type:"GET",
|
frappe.call({
|
||||||
method: "erpnext.accounts.utils.get_fiscal_year",
|
type:"GET",
|
||||||
args: {
|
method: "erpnext.accounts.utils.get_fiscal_year",
|
||||||
"company": company,
|
args: {
|
||||||
"date": date,
|
"company": company,
|
||||||
"verbose": 0
|
"date": date,
|
||||||
},
|
"verbose": 0
|
||||||
callback: function(r) {
|
},
|
||||||
if (r.message) cur_frm.set_value("fiscal_year", r.message[0]);
|
callback: function(r) {
|
||||||
if (fn) fn();
|
if (r.message) cur_frm.set_value("fiscal_year", r.message[0]);
|
||||||
}
|
if (fn) fn();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggle_naming_series: function() {
|
toggle_naming_series: function() {
|
||||||
|
@ -131,21 +131,6 @@
|
|||||||
"search_index": 1,
|
"search_index": 1,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "fiscal_year",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Fiscal Year",
|
|
||||||
"oldfieldname": "fiscal_year",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "Fiscal Year",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
|
||||||
"print_width": "150px",
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1,
|
|
||||||
"width": "150px"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "column_break2",
|
"fieldname": "column_break2",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
@ -236,7 +221,7 @@
|
|||||||
"icon": "icon-ticket",
|
"icon": "icon-ticket",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2015-02-20 05:07:33.215371",
|
"modified": "2015-05-27 15:36:06.818491",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Material Request",
|
"name": "Material Request",
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import flt, cstr, nowdate, add_days, cint
|
from frappe.utils import flt, cstr, nowdate, add_days, cint
|
||||||
from erpnext.accounts.utils import get_fiscal_year, FiscalYearError
|
|
||||||
|
|
||||||
def reorder_item():
|
def reorder_item():
|
||||||
""" Reorder item if stock reaches reorder level"""
|
""" Reorder item if stock reaches reorder level"""
|
||||||
@ -83,7 +82,6 @@ def get_item_warehouse_projected_qty():
|
|||||||
def create_material_request(material_requests):
|
def create_material_request(material_requests):
|
||||||
""" Create indent on reaching reorder level """
|
""" Create indent on reaching reorder level """
|
||||||
mr_list = []
|
mr_list = []
|
||||||
defaults = frappe.defaults.get_defaults()
|
|
||||||
exceptions_list = []
|
exceptions_list = []
|
||||||
|
|
||||||
def _log_exception():
|
def _log_exception():
|
||||||
@ -93,14 +91,6 @@ def create_material_request(material_requests):
|
|||||||
else:
|
else:
|
||||||
exceptions_list.append(frappe.get_traceback())
|
exceptions_list.append(frappe.get_traceback())
|
||||||
|
|
||||||
try:
|
|
||||||
current_fiscal_year = get_fiscal_year(nowdate())[0] or defaults.fiscal_year
|
|
||||||
|
|
||||||
except FiscalYearError:
|
|
||||||
_log_exception()
|
|
||||||
notify_errors(exceptions_list)
|
|
||||||
return
|
|
||||||
|
|
||||||
for request_type in material_requests:
|
for request_type in material_requests:
|
||||||
for company in material_requests[request_type]:
|
for company in material_requests[request_type]:
|
||||||
try:
|
try:
|
||||||
@ -111,7 +101,6 @@ def create_material_request(material_requests):
|
|||||||
mr = frappe.new_doc("Material Request")
|
mr = frappe.new_doc("Material Request")
|
||||||
mr.update({
|
mr.update({
|
||||||
"company": company,
|
"company": company,
|
||||||
"fiscal_year": current_fiscal_year,
|
|
||||||
"transaction_date": nowdate(),
|
"transaction_date": nowdate(),
|
||||||
"material_request_type": request_type
|
"material_request_type": request_type
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user