Merge pull request #7336 from rohitwaghchaure/pos_enhancement_and_issues

[Enhancement] POS features
This commit is contained in:
Nabin Hait
2017-01-04 15:15:32 +05:30
committed by GitHub
7 changed files with 146 additions and 83 deletions

View File

@@ -78,6 +78,8 @@ class Company(Document):
if not frappe.local.flags.ignore_chart_of_accounts:
self.set_default_accounts()
if self.default_cash_account:
self.mode_of_payment()
if self.default_currency:
frappe.db.set_value("Currency", self.default_currency, "enabled", 1)
@@ -162,6 +164,16 @@ class Company(Document):
if account:
self.db_set(fieldname, account)
def mode_of_payment(self):
cash = frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name')
if cash and not frappe.db.get_value('Mode of Payment Account', {'company': self.name}):
mode_of_payment = frappe.get_doc('Mode of Payment', cash)
mode_of_payment.append('accounts', {
'company': self.name,
'default_account': self.default_cash_account
})
mode_of_payment.save(ignore_permissions=True)
def create_default_cost_center(self):
cc_list = [
{

View File

@@ -40,9 +40,10 @@ class TestCompany(unittest.TestCase):
acc = frappe.get_doc("Account", account)
for prop, val in acc_property.items():
self.assertEqual(acc.get(prop), val)
self.delete_mode_of_payment("COA from Existing Company")
frappe.delete_doc("Company", "COA from Existing Company")
def test_coa_based_on_country_template(self):
countries = ["India", "Brazil", "United Arab Emirates", "Canada", "Germany", "France",
"Guatemala", "Indonesia", "Mexico", "Nicaragua", "Netherlands", "Singapore"]
@@ -78,4 +79,9 @@ class TestCompany(unittest.TestCase):
self.assertTrue(frappe.get_all("Account", filters))
finally:
frappe.delete_doc("Company", template)
self.delete_mode_of_payment(template)
frappe.delete_doc("Company", template)
def delete_mode_of_payment(self, company):
frappe.db.sql(""" delete from `tabMode of Payment Account`
where company =%s """, (company))