fix: Styling and test case fixes
This commit is contained in:
parent
adccb2c3a4
commit
a8cb00f31f
@ -13,7 +13,7 @@ frappe.ui.form.on('Accounting Dimension', {
|
|||||||
|
|
||||||
document_type: function(frm) {
|
document_type: function(frm) {
|
||||||
frm.set_value('label', frm.doc.document_type);
|
frm.set_value('label', frm.doc.document_type);
|
||||||
frm.set_value('fieldname', frappe.scrub(frm.doc.document_type))
|
frm.set_value('fieldname', frappe.scrub(frm.doc.document_type));
|
||||||
|
|
||||||
frappe.db.get_value('Accounting Dimension', {'document_type': frm.doc.document_type}, 'document_type', (r) => {
|
frappe.db.get_value('Accounting Dimension', {'document_type': frm.doc.document_type}, 'document_type', (r) => {
|
||||||
if (r.document_type) {
|
if (r.document_type) {
|
||||||
@ -29,7 +29,7 @@ frappe.ui.form.on('Accounting Dimension', {
|
|||||||
doc: frm.doc
|
doc: frm.doc
|
||||||
},
|
},
|
||||||
callback: function() {
|
callback: function() {
|
||||||
frappe.msgprint(_("{0} dimension disabled", [frm.doc.label]));
|
frappe.msgprint(__("{0} dimension disabled", [frm.doc.label]));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -71,22 +71,10 @@ def make_dimension_in_accounting_doctypes(doc):
|
|||||||
"property_type": "Text",
|
"property_type": "Text",
|
||||||
"value": "\nCost Center\nProject\n" + doc.document_type
|
"value": "\nCost Center\nProject\n" + doc.document_type
|
||||||
}).insert(ignore_permissions=True)
|
}).insert(ignore_permissions=True)
|
||||||
frappe.clear_cache(doctype=doctype)
|
|
||||||
else:
|
else:
|
||||||
if frappe.db.has_column(doctype, doc.fieldname) and (doc.mandatory_for_pl or doc.mandatory_for_bs):
|
create_custom_field(doctype, df)
|
||||||
frappe.get_doc({
|
|
||||||
"doctype": "Property Setter",
|
|
||||||
"doctype_or_field": "DocField",
|
|
||||||
"doc_type": doctype,
|
|
||||||
"field_name": doc.fieldname,
|
|
||||||
"property": "hidden",
|
|
||||||
"property_type": "Check",
|
|
||||||
"value": 0
|
|
||||||
}).insert(ignore_permissions=True)
|
|
||||||
else:
|
|
||||||
create_custom_field(doctype, df)
|
|
||||||
|
|
||||||
frappe.clear_cache(doctype=doctype)
|
frappe.clear_cache(doctype=doctype)
|
||||||
|
|
||||||
def delete_accounting_dimension(doc):
|
def delete_accounting_dimension(doc):
|
||||||
doclist = get_doclist()
|
doclist = get_doclist()
|
||||||
@ -94,13 +82,13 @@ def delete_accounting_dimension(doc):
|
|||||||
frappe.db.sql("""
|
frappe.db.sql("""
|
||||||
DELETE FROM `tabCustom Field`
|
DELETE FROM `tabCustom Field`
|
||||||
WHERE fieldname = %s
|
WHERE fieldname = %s
|
||||||
AND dt IN (%s)""" %
|
AND dt IN (%s)""" % #nosec
|
||||||
('%s', ', '.join(['%s']* len(doclist))), tuple([doc.fieldname] + doclist))
|
('%s', ', '.join(['%s']* len(doclist))), tuple([doc.fieldname] + doclist))
|
||||||
|
|
||||||
frappe.db.sql("""
|
frappe.db.sql("""
|
||||||
DELETE FROM `tabProperty Setter`
|
DELETE FROM `tabProperty Setter`
|
||||||
WHERE field_name = %s
|
WHERE field_name = %s
|
||||||
AND doc_type IN (%s)""" %
|
AND doc_type IN (%s)""" % #nosec
|
||||||
('%s', ', '.join(['%s']* len(doclist))), tuple([doc.fieldname] + doclist))
|
('%s', ', '.join(['%s']* len(doclist))), tuple([doc.fieldname] + doclist))
|
||||||
|
|
||||||
budget_against_property = frappe.get_doc("Property Setter", "Budget-budget_against-options")
|
budget_against_property = frappe.get_doc("Property Setter", "Budget-budget_against-options")
|
||||||
|
@ -7,6 +7,7 @@ import frappe
|
|||||||
import unittest
|
import unittest
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||||
|
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import delete_accounting_dimension
|
||||||
|
|
||||||
class TestAccountingDimension(unittest.TestCase):
|
class TestAccountingDimension(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -17,18 +18,27 @@ class TestAccountingDimension(unittest.TestCase):
|
|||||||
"doctype": "Accounting Dimension",
|
"doctype": "Accounting Dimension",
|
||||||
"document_type": "Department",
|
"document_type": "Department",
|
||||||
}).insert()
|
}).insert()
|
||||||
|
else:
|
||||||
|
dimension1 = frappe.get_doc("Accounting Dimension", "Department")
|
||||||
|
dimension1.disabled = 0
|
||||||
|
dimension1.save()
|
||||||
|
|
||||||
|
if not frappe.db.exists("Accounting Dimension", {"document_type": "Location"}):
|
||||||
dimension1 = frappe.get_doc({
|
dimension1 = frappe.get_doc({
|
||||||
"doctype": "Accounting Dimension",
|
"doctype": "Accounting Dimension",
|
||||||
"document_type": "Location",
|
"document_type": "Location",
|
||||||
"mandatory_for_pl": 1
|
"mandatory_for_pl": 1
|
||||||
}).insert()
|
}).insert()
|
||||||
|
else:
|
||||||
def tearDown(self):
|
dimension1 = frappe.get_doc("Accounting Dimension", "Location")
|
||||||
delete_dimension()
|
dimension1.disabled = 0
|
||||||
|
dimension1.mandatory_for_pl = 1
|
||||||
|
dimension1.save()
|
||||||
|
|
||||||
def test_dimension_against_sales_invoice(self):
|
def test_dimension_against_sales_invoice(self):
|
||||||
si = create_sales_invoice(do_not_save=1)
|
si = create_sales_invoice(do_not_save=1)
|
||||||
|
|
||||||
|
si.location = "Block 1"
|
||||||
si.append("items", {
|
si.append("items", {
|
||||||
"item_code": "_Test Item",
|
"item_code": "_Test Item",
|
||||||
"warehouse": "_Test Warehouse - _TC",
|
"warehouse": "_Test Warehouse - _TC",
|
||||||
@ -37,7 +47,8 @@ class TestAccountingDimension(unittest.TestCase):
|
|||||||
"income_account": "Sales - _TC",
|
"income_account": "Sales - _TC",
|
||||||
"expense_account": "Cost of Goods Sold - _TC",
|
"expense_account": "Cost of Goods Sold - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"department": "_Test Department - _TC"
|
"department": "_Test Department - _TC",
|
||||||
|
"location": "Block 1"
|
||||||
})
|
})
|
||||||
|
|
||||||
si.save()
|
si.save()
|
||||||
@ -52,6 +63,9 @@ class TestAccountingDimension(unittest.TestCase):
|
|||||||
je.accounts[0].update({"department": "_Test Department - _TC"})
|
je.accounts[0].update({"department": "_Test Department - _TC"})
|
||||||
je.accounts[1].update({"department": "_Test Department - _TC"})
|
je.accounts[1].update({"department": "_Test Department - _TC"})
|
||||||
|
|
||||||
|
je.accounts[0].update({"location": "Block 1"})
|
||||||
|
je.accounts[1].update({"location": "Block 1"})
|
||||||
|
|
||||||
je.save()
|
je.save()
|
||||||
je.submit()
|
je.submit()
|
||||||
|
|
||||||
@ -74,10 +88,20 @@ class TestAccountingDimension(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
si.save()
|
si.save()
|
||||||
self.assertRaises(frappe.ValidationError, si.submit())
|
self.assertRaises(frappe.ValidationError, si.submit)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
disable_dimension()
|
||||||
|
|
||||||
|
|
||||||
def delete_dimension():
|
def disable_dimension():
|
||||||
dimension1 = frappe.delete_doc("Accounting Diemnsion", "Department")
|
dimension1 = frappe.get_doc("Accounting Dimension", "Department")
|
||||||
dimension2 = frappe.delete_doc("Accounting Diemnsion", "Location")
|
dimension1.disabled = 1
|
||||||
|
dimension1.save()
|
||||||
|
|
||||||
|
dimension2 = frappe.get_doc("Accounting Dimension", "Location")
|
||||||
|
dimension2.mandatory_for_pl = 0
|
||||||
|
dimension2.disabled = 1
|
||||||
|
dimension2.save()
|
||||||
|
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"credit": flt(item.landed_cost_voucher_amount),
|
"credit": flt(item.landed_cost_voucher_amount),
|
||||||
"project": item.project
|
"project": item.project
|
||||||
}), item=item)
|
}, item=item))
|
||||||
|
|
||||||
# sub-contracting warehouse
|
# sub-contracting warehouse
|
||||||
if flt(item.rm_supp_cost):
|
if flt(item.rm_supp_cost):
|
||||||
|
@ -96,7 +96,7 @@ def get_cost_centers(filters):
|
|||||||
return frappe.db.sql_list("""select name from `tab{tab}` where company=%s
|
return frappe.db.sql_list("""select name from `tab{tab}` where company=%s
|
||||||
{cond}""".format(tab=filters.get("budget_against"), cond=cond), filters.get("company"))
|
{cond}""".format(tab=filters.get("budget_against"), cond=cond), filters.get("company"))
|
||||||
else:
|
else:
|
||||||
return frappe.db.sql_list("""select name from `tab{tab}`""".format(tab=filters.get("budget_against")))
|
return frappe.db.sql_list("""select name from `tab{tab}`""".format(tab=filters.get("budget_against"))) #nosec
|
||||||
|
|
||||||
#Get cost center & target details
|
#Get cost center & target details
|
||||||
def get_cost_center_target_details(filters):
|
def get_cost_center_target_details(filters):
|
||||||
|
@ -365,7 +365,7 @@ def set_gl_entries_by_account(
|
|||||||
where company=%(company)s
|
where company=%(company)s
|
||||||
{additional_conditions}
|
{additional_conditions}
|
||||||
and posting_date <= %(to_date)s
|
and posting_date <= %(to_date)s
|
||||||
order by account, posting_date""".format(additional_conditions=additional_conditions), gl_filters, as_dict=True)
|
order by account, posting_date""".format(additional_conditions=additional_conditions), gl_filters, as_dict=True) #nosec
|
||||||
|
|
||||||
if filters and filters.get('presentation_currency'):
|
if filters and filters.get('presentation_currency'):
|
||||||
convert_to_presentation_currency(gl_entries, get_currency(filters))
|
convert_to_presentation_currency(gl_entries, get_currency(filters))
|
||||||
|
@ -150,7 +150,7 @@ function get_filters(){
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
let dimension_filters = erpnext.get_dimension_filters()
|
let dimension_filters = erpnext.get_dimension_filters();
|
||||||
|
|
||||||
dimension_filters.then((dimensions) => {
|
dimension_filters.then((dimensions) => {
|
||||||
dimensions.forEach((dimension) => {
|
dimensions.forEach((dimension) => {
|
||||||
|
@ -5,9 +5,9 @@ let doclist = ["GL Entry", "Sales Invoice", "Purchase Invoice", "Payment Entry",
|
|||||||
"Purchase Order Item", "Journal Entry Account", "Material Request Item", "Delivery Note Item", "Purchase Receipt Item",
|
"Purchase Order Item", "Journal Entry Account", "Material Request Item", "Delivery Note Item", "Purchase Receipt Item",
|
||||||
"Stock Entry Detail", "Payment Entry Deduction", "Sales Taxes and Charges", "Purchase Taxes and Charges", "Shipping Rule",
|
"Stock Entry Detail", "Payment Entry Deduction", "Sales Taxes and Charges", "Purchase Taxes and Charges", "Shipping Rule",
|
||||||
"Landed Cost Item", "Asset Value Adjustment", "Loyalty Program", "Fee Schedule", "Fee Structure", "Stock Reconciliation",
|
"Landed Cost Item", "Asset Value Adjustment", "Loyalty Program", "Fee Schedule", "Fee Structure", "Stock Reconciliation",
|
||||||
"Travel Request", "Fees", "POS Profile"]
|
"Travel Request", "Fees", "POS Profile"];
|
||||||
|
|
||||||
let dimension_filters = erpnext.get_dimension_filters()
|
let dimension_filters = erpnext.get_dimension_filters();
|
||||||
|
|
||||||
doclist.forEach((doctype) => {
|
doclist.forEach((doctype) => {
|
||||||
frappe.ui.form.on(doctype, {
|
frappe.ui.form.on(doctype, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user