This commit is contained in:
parent
81ba0b29da
commit
0d8d30e1cc
@ -3,12 +3,8 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import flt, fmt_money, cstr, cint
|
from frappe.utils import flt, fmt_money, cstr, cint
|
||||||
from frappe import msgprint, throw, _
|
from frappe import msgprint, throw, _
|
||||||
|
|
||||||
get_value = frappe.db.get_value
|
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class Account(Document):
|
class Account(Document):
|
||||||
@ -19,10 +15,7 @@ class Account(Document):
|
|||||||
frappe.db.get_value("Company", self.company, "abbr")
|
frappe.db.get_value("Company", self.company, "abbr")
|
||||||
|
|
||||||
def get_address(self):
|
def get_address(self):
|
||||||
return {
|
return {'address': frappe.db.get_value(self.master_type, self.master_name, "address")}
|
||||||
'address': frappe.db.get_value(self.master_type,
|
|
||||||
self.master_name, "address")
|
|
||||||
}
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_master_name()
|
self.validate_master_name()
|
||||||
@ -33,23 +26,18 @@ class Account(Document):
|
|||||||
self.validate_warehouse_account()
|
self.validate_warehouse_account()
|
||||||
self.validate_frozen_accounts_modifier()
|
self.validate_frozen_accounts_modifier()
|
||||||
|
|
||||||
if not self.parent_account:
|
|
||||||
self.parent_account = ''
|
|
||||||
|
|
||||||
def validate_master_name(self):
|
def validate_master_name(self):
|
||||||
"""Remind to add master name"""
|
|
||||||
if self.master_type in ('Customer', 'Supplier') or self.account_type == "Warehouse":
|
if self.master_type in ('Customer', 'Supplier') or self.account_type == "Warehouse":
|
||||||
if not self.master_name:
|
if not self.master_name:
|
||||||
msgprint(_("Please enter Master Name once the account is created."))
|
msgprint(_("Please enter Master Name once the account is created."))
|
||||||
elif not frappe.db.exists(self.master_type or self.account_type,
|
elif not frappe.db.exists(self.master_type or self.account_type, self.master_name):
|
||||||
self.master_name):
|
|
||||||
throw(_("Invalid Master Name"))
|
throw(_("Invalid Master Name"))
|
||||||
|
|
||||||
def validate_parent(self):
|
def validate_parent(self):
|
||||||
"""Fetch Parent Details and validation for account not to be created under ledger"""
|
"""Fetch Parent Details and validation for account not to be created under ledger"""
|
||||||
if self.parent_account:
|
if self.parent_account:
|
||||||
par = frappe.db.sql("""select name, group_or_ledger, report_type
|
par = frappe.db.get_value("Account", self.parent_account,
|
||||||
from tabAccount where name =%s""", self.parent_account, as_dict=1)
|
["name", "group_or_ledger", "report_type"], as_dict=1)
|
||||||
if not par:
|
if not par:
|
||||||
throw(_("Parent account does not exists"))
|
throw(_("Parent account does not exists"))
|
||||||
elif par[0]["name"] == self.name:
|
elif par[0]["name"] == self.name:
|
||||||
@ -63,14 +51,13 @@ class Account(Document):
|
|||||||
def validate_duplicate_account(self):
|
def validate_duplicate_account(self):
|
||||||
if self.get('__islocal') or not self.name:
|
if self.get('__islocal') or not self.name:
|
||||||
company_abbr = frappe.db.get_value("Company", self.company, "abbr")
|
company_abbr = frappe.db.get_value("Company", self.company, "abbr")
|
||||||
if frappe.db.sql("""select name from tabAccount where name=%s""",
|
if frappe.db.exists("Account", (self.account_name + " - " + company_abbr)):
|
||||||
(self.account_name + " - " + company_abbr)):
|
throw("{name}: {acc_name} {exist}, {rename}".format(**{
|
||||||
throw("{name}: {acc_name} {exist}, {rename}".format(**{
|
"name": _("Account Name"),
|
||||||
"name": _("Account Name"),
|
"acc_name": self.account_name,
|
||||||
"acc_name": self.account_name,
|
"exist": _("already exists"),
|
||||||
"exist": _("already exists"),
|
"rename": _("please rename")
|
||||||
"rename": _("please rename")
|
}))
|
||||||
}))
|
|
||||||
|
|
||||||
def validate_root_details(self):
|
def validate_root_details(self):
|
||||||
#does not exists parent
|
#does not exists parent
|
||||||
|
@ -35,12 +35,12 @@ def _make_test_records(verbose):
|
|||||||
]
|
]
|
||||||
|
|
||||||
for company, abbr in [["_Test Company", "_TC"], ["_Test Company 1", "_TC1"]]:
|
for company, abbr in [["_Test Company", "_TC"], ["_Test Company 1", "_TC1"]]:
|
||||||
test_objects = make_test_objects("Account", [[{
|
test_objects = make_test_objects("Account", [{
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
"account_name": account_name,
|
"account_name": account_name,
|
||||||
"parent_account": parent_account + " - " + abbr,
|
"parent_account": parent_account + " - " + abbr,
|
||||||
"company": company,
|
"company": company,
|
||||||
"group_or_ledger": group_or_ledger
|
"group_or_ledger": group_or_ledger
|
||||||
}] for account_name, parent_account, group_or_ledger in accounts])
|
} for account_name, parent_account, group_or_ledger in accounts])
|
||||||
|
|
||||||
return test_objects
|
return test_objects
|
@ -7,18 +7,16 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class AccountsSettings(Document):
|
class AccountsSettings(Document):
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
frappe.db.set_default("auto_accounting_for_stock", self.auto_accounting_for_stock)
|
frappe.db.set_default("auto_accounting_for_stock", self.auto_accounting_for_stock)
|
||||||
|
|
||||||
if cint(self.auto_accounting_for_stock):
|
if cint(self.auto_accounting_for_stock):
|
||||||
# set default perpetual account in company
|
# set default perpetual account in company
|
||||||
for company in frappe.db.sql("select name from tabCompany"):
|
for company in frappe.db.sql("select name from tabCompany"):
|
||||||
frappe.bean("Company", company[0]).save()
|
frappe.get_doc("Company", company[0]).save()
|
||||||
|
|
||||||
# Create account head for warehouses
|
# Create account head for warehouses
|
||||||
warehouse_list = frappe.db.sql("select name, company from tabWarehouse", as_dict=1)
|
warehouse_list = frappe.db.sql("select name, company from tabWarehouse", as_dict=1)
|
||||||
|
@ -3,20 +3,25 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.utils import cstr, flt, getdate, nowdate
|
||||||
from frappe.utils import cstr, flt, getdate, now, nowdate
|
from frappe import msgprint, _
|
||||||
from frappe import msgprint
|
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class BankReconciliation(Document):
|
class BankReconciliation(Document):
|
||||||
|
|
||||||
def get_details(self):
|
def get_details(self):
|
||||||
if not (self.bank_account and self.from_date and self.to_date):
|
if not (self.bank_account and self.from_date and self.to_date):
|
||||||
msgprint("Bank Account, From Date and To Date are Mandatory")
|
msgprint("Bank Account, From Date and To Date are Mandatory")
|
||||||
return
|
return
|
||||||
|
|
||||||
dl = frappe.db.sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.bank_account, self.from_date, self.to_date))
|
dl = frappe.db.sql("""select t1.name, t1.cheque_no, t1.cheque_date, t2.debit,
|
||||||
|
t2.credit, t1.posting_date, t2.against_account
|
||||||
|
from
|
||||||
|
`tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
|
||||||
|
where
|
||||||
|
t2.parent = t1.name and t2.account = %s
|
||||||
|
and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '')
|
||||||
|
and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1""",
|
||||||
|
(self.bank_account, self.from_date, self.to_date))
|
||||||
|
|
||||||
self.set('entries', [])
|
self.set('entries', [])
|
||||||
self.total_amount = 0.0
|
self.total_amount = 0.0
|
||||||
@ -37,15 +42,14 @@ class BankReconciliation(Document):
|
|||||||
for d in self.get('entries'):
|
for d in self.get('entries'):
|
||||||
if d.clearance_date:
|
if d.clearance_date:
|
||||||
if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date):
|
if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date):
|
||||||
msgprint("Clearance Date can not be before Cheque Date (Row #%s)" %
|
frappe.throw("Clearance Date can not be before Cheque Date (Row #%s)" % d.idx)
|
||||||
d.idx, raise_exception=1)
|
|
||||||
|
|
||||||
frappe.db.sql("""update `tabJournal Voucher`
|
frappe.db.set_value("Journal Voucher", d.voucher_id, "clearance_date", d.clearance_date)
|
||||||
set clearance_date = %s, modified = %s where name=%s""",
|
frappe.db.sql("""update `tabJournal Voucher` set clearance_date = %s, modified = %s
|
||||||
(d.clearance_date, nowdate(), d.voucher_id))
|
where name=%s""", (d.clearance_date, nowdate(), d.voucher_id))
|
||||||
vouchers.append(d.voucher_id)
|
vouchers.append(d.voucher_id)
|
||||||
|
|
||||||
if vouchers:
|
if vouchers:
|
||||||
msgprint("Clearance Date updated in %s" % ", ".join(vouchers))
|
msgprint("Clearance Date updated in %s" % ", ".join(vouchers))
|
||||||
else:
|
else:
|
||||||
msgprint("Clearance Date not mentioned")
|
msgprint(_("Clearance Date not mentioned"))
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class BankReconciliationDetail(Document):
|
class BankReconciliationDetail(Document):
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class BudgetDetail(Document):
|
class BudgetDetail(Document):
|
||||||
|
@ -3,11 +3,8 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
from frappe.model.bean import getlist
|
from frappe import _
|
||||||
from frappe import msgprint, _
|
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class BudgetDistribution(Document):
|
class BudgetDistribution(Document):
|
||||||
@ -17,13 +14,12 @@ class BudgetDistribution(Document):
|
|||||||
idx =1
|
idx =1
|
||||||
for m in month_list:
|
for m in month_list:
|
||||||
mnth = self.append('budget_distribution_details')
|
mnth = self.append('budget_distribution_details')
|
||||||
mnth.month = m or ''
|
mnth.month = m
|
||||||
mnth.idx = idx
|
mnth.idx = idx
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
total = sum([flt(d.percentage_allocation, 2) for d in self.doclist.get(
|
total = sum([flt(d.percentage_allocation) for d in self.get("budget_distribution_details")])
|
||||||
{"parentfield": "budget_distribution_details"})])
|
|
||||||
|
|
||||||
if total != 100.0:
|
if total != 100.0:
|
||||||
msgprint(_("Percentage Allocation should be equal to ") + "100%", raise_exception=1)
|
frappe.throw(_("Percentage Allocation should be equal to ") + "100%")
|
@ -2,69 +2,48 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
[{
|
{
|
||||||
"doctype": "Budget Distribution",
|
"doctype": "Budget Distribution",
|
||||||
"distribution_id": "_Test Distribution",
|
"distribution_id": "_Test Distribution",
|
||||||
"fiscal_year": "_Test Fiscal Year 2013",
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
}, {
|
"budget_distribution_details": [
|
||||||
"doctype": "Budget Distribution Detail",
|
{
|
||||||
"parentfield": "budget_distribution_details",
|
"month": "January",
|
||||||
"month": "January",
|
"percentage_allocation": "8"
|
||||||
"percentage_allocation": "8"
|
}, {
|
||||||
}, {
|
"month": "February",
|
||||||
"doctype": "Budget Distribution Detail",
|
"percentage_allocation": "8"
|
||||||
"parentfield": "budget_distribution_details",
|
}, {
|
||||||
"month": "February",
|
"month": "March",
|
||||||
"percentage_allocation": "8"
|
"percentage_allocation": "8"
|
||||||
}, {
|
}, {
|
||||||
"doctype": "Budget Distribution Detail",
|
"month": "April",
|
||||||
"parentfield": "budget_distribution_details",
|
"percentage_allocation": "8"
|
||||||
"month": "March",
|
}, {
|
||||||
"percentage_allocation": "8"
|
"month": "May",
|
||||||
}, {
|
"percentage_allocation": "8"
|
||||||
"doctype": "Budget Distribution Detail",
|
}, {
|
||||||
"parentfield": "budget_distribution_details",
|
"month": "June",
|
||||||
"month": "April",
|
"percentage_allocation": "8"
|
||||||
"percentage_allocation": "8"
|
}, {
|
||||||
}, {
|
"month": "July",
|
||||||
"doctype": "Budget Distribution Detail",
|
"percentage_allocation": "8"
|
||||||
"parentfield": "budget_distribution_details",
|
}, {
|
||||||
"month": "May",
|
"month": "August",
|
||||||
"percentage_allocation": "8"
|
"percentage_allocation": "8"
|
||||||
}, {
|
}, {
|
||||||
"doctype": "Budget Distribution Detail",
|
"month": "September",
|
||||||
"parentfield": "budget_distribution_details",
|
"percentage_allocation": "8"
|
||||||
"month": "June",
|
}, {
|
||||||
"percentage_allocation": "8"
|
"month": "October",
|
||||||
}, {
|
"percentage_allocation": "8"
|
||||||
"doctype": "Budget Distribution Detail",
|
}, {
|
||||||
"parentfield": "budget_distribution_details",
|
"month": "November",
|
||||||
"month": "July",
|
"percentage_allocation": "10"
|
||||||
"percentage_allocation": "8"
|
}, {
|
||||||
}, {
|
"month": "December",
|
||||||
"doctype": "Budget Distribution Detail",
|
"percentage_allocation": "10"
|
||||||
"parentfield": "budget_distribution_details",
|
}
|
||||||
"month": "August",
|
]
|
||||||
"percentage_allocation": "8"
|
}
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "September",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "October",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "November",
|
|
||||||
"percentage_allocation": "10"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "December",
|
|
||||||
"percentage_allocation": "10"
|
|
||||||
}]
|
|
||||||
]
|
]
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class BudgetDistributionDetail(Document):
|
class BudgetDistributionDetail(Document):
|
||||||
|
@ -3,14 +3,11 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import flt, getdate
|
from frappe.utils import flt
|
||||||
from frappe.model.bean import getlist
|
from frappe import _
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class CForm(Document):
|
class CForm(Document):
|
||||||
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
"""Validate invoice that c-form is applicable
|
"""Validate invoice that c-form is applicable
|
||||||
and no other c-form is received for that"""
|
and no other c-form is received for that"""
|
||||||
@ -21,18 +18,17 @@ class CForm(Document):
|
|||||||
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
|
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
|
||||||
|
|
||||||
if not inv:
|
if not inv:
|
||||||
frappe.msgprint("""Invoice: %s is not exists in the system or
|
frappe.throw("""Invoice: %s is not exists in the system or
|
||||||
is not submitted, please check.""" % d.invoice_no, raise_exception=1)
|
is not submitted, please check.""" % d.invoice_no)
|
||||||
|
|
||||||
elif inv[0][0] != 'Yes':
|
elif inv[0][0] != 'Yes':
|
||||||
frappe.msgprint("C-form is not applicable for Invoice: %s" %
|
frappe.throw("C-form is not applicable for Invoice: %s" % d.invoice_no)
|
||||||
d.invoice_no, raise_exception=1)
|
|
||||||
|
|
||||||
elif inv[0][1] and inv[0][1] != self.name:
|
elif inv[0][1] and inv[0][1] != self.name:
|
||||||
frappe.msgprint("""Invoice %s is tagged in another C-form: %s.
|
frappe.throw("""Invoice %s is tagged in another C-form: %s.
|
||||||
If you want to change C-form no for this invoice,
|
If you want to change C-form no for this invoice,
|
||||||
please remove invoice no from the previous c-form and then try again""" %
|
please remove invoice no from the previous c-form and then try again""" %
|
||||||
(d.invoice_no, inv[0][1]), raise_exception=1)
|
(d.invoice_no, inv[0][1]))
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
""" Update C-Form No on invoices"""
|
""" Update C-Form No on invoices"""
|
||||||
@ -43,22 +39,19 @@ class CForm(Document):
|
|||||||
|
|
||||||
def before_cancel(self):
|
def before_cancel(self):
|
||||||
# remove cform reference
|
# remove cform reference
|
||||||
frappe.db.sql("""update `tabSales Invoice` set c_form_no=null
|
frappe.db.sql("""update `tabSales Invoice` set c_form_no=null where c_form_no=%s""", self.name)
|
||||||
where c_form_no=%s""", self.name)
|
|
||||||
|
|
||||||
def set_cform_in_sales_invoices(self):
|
def set_cform_in_sales_invoices(self):
|
||||||
inv = [d.invoice_no for d in self.get('invoice_details')]
|
inv = [d.invoice_no for d in self.get('invoice_details')]
|
||||||
if inv:
|
if inv:
|
||||||
frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s
|
frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s where name in (%s)""" %
|
||||||
where name in (%s)""" % ('%s', '%s', ', '.join(['%s'] * len(inv))),
|
('%s', '%s', ', '.join(['%s'] * len(inv))), tuple([self.name, self.modified] + inv))
|
||||||
tuple([self.name, self.modified] + inv))
|
|
||||||
|
|
||||||
frappe.db.sql("""update `tabSales Invoice` set c_form_no = null, modified = %s
|
frappe.db.sql("""update `tabSales Invoice` set c_form_no = null, modified = %s
|
||||||
where name not in (%s) and ifnull(c_form_no, '') = %s""" %
|
where name not in (%s) and ifnull(c_form_no, '') = %s""" %
|
||||||
('%s', ', '.join(['%s']*len(inv)), '%s'),
|
('%s', ', '.join(['%s']*len(inv)), '%s'), tuple([self.modified] + inv + [self.name]))
|
||||||
tuple([self.modified] + inv + [self.name]))
|
|
||||||
else:
|
else:
|
||||||
frappe.msgprint("Please enter atleast 1 invoice in the table", raise_exception=1)
|
frappe.throw(_("Please enter atleast 1 invoice in the table"))
|
||||||
|
|
||||||
def set_total_invoiced_amount(self):
|
def set_total_invoiced_amount(self):
|
||||||
total = sum([flt(d.grand_total) for d in self.get('invoice_details')])
|
total = sum([flt(d.grand_total) for d in self.get('invoice_details')])
|
||||||
@ -67,13 +60,13 @@ class CForm(Document):
|
|||||||
def get_invoice_details(self, invoice_no):
|
def get_invoice_details(self, invoice_no):
|
||||||
""" Pull details from invoices for referrence """
|
""" Pull details from invoices for referrence """
|
||||||
|
|
||||||
inv = frappe.db.sql("""select posting_date, territory, net_total, grand_total
|
inv = frappe.db.get_value("Sales Invoice", invoice_no,
|
||||||
from `tabSales Invoice` where name = %s""", invoice_no)
|
["posting_date", "territory", "net_total", "grand_total"], as_dict=True)
|
||||||
return {
|
return {
|
||||||
'invoice_date' : inv and getdate(inv[0][0]).strftime('%Y-%m-%d') or '',
|
'invoice_date' : inv.posting_date,
|
||||||
'territory' : inv and inv[0][1] or '',
|
'territory' : inv.territory,
|
||||||
'net_total' : inv and flt(inv[0][2]) or '',
|
'net_total' : inv.net_total,
|
||||||
'grand_total' : inv and flt(inv[0][3]) or ''
|
'grand_total' : inv.grand_total
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_invoice_nos(doctype, txt, searchfield, start, page_len, filters):
|
def get_invoice_nos(doctype, txt, searchfield, start, page_len, filters):
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class CFormInvoiceDetail(Document):
|
class CFormInvoiceDetail(Document):
|
||||||
|
@ -5,21 +5,17 @@ from __future__ import unicode_literals
|
|||||||
import frappe, os, json
|
import frappe, os, json
|
||||||
from frappe.utils import cstr
|
from frappe.utils import cstr
|
||||||
from unidecode import unidecode
|
from unidecode import unidecode
|
||||||
|
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class ChartOfAccounts(Document):
|
class ChartOfAccounts(Document):
|
||||||
self.no_report_type = False
|
no_report_type = False
|
||||||
|
|
||||||
def create_accounts(self, company):
|
def create_accounts(self, company):
|
||||||
chart = {}
|
chart = {}
|
||||||
with open(os.path.join(os.path.dirname(__file__), "charts",
|
with open(os.path.join(os.path.dirname(__file__), "charts", self.source_file), "r") as f:
|
||||||
self.source_file), "r") as f:
|
|
||||||
chart = json.loads(f.read())
|
chart = json.loads(f.read())
|
||||||
|
|
||||||
from erpnext.accounts.doctype.chart_of_accounts.charts.account_properties \
|
from erpnext.accounts.doctype.chart_of_accounts.charts.account_properties import account_properties
|
||||||
import account_properties
|
|
||||||
|
|
||||||
if chart:
|
if chart:
|
||||||
accounts = []
|
accounts = []
|
||||||
@ -33,10 +29,9 @@ class ChartOfAccounts(Document):
|
|||||||
count = accounts.count(account_name_in_db)
|
count = accounts.count(account_name_in_db)
|
||||||
account_name = account_name + " " + cstr(count)
|
account_name = account_name + " " + cstr(count)
|
||||||
|
|
||||||
child.update(account_properties.get(chart.get("name"), {})\
|
child.update(account_properties.get(chart.get("name"), {}).get(account_name, {}))
|
||||||
.get(account_name, {}))
|
|
||||||
|
|
||||||
account = frappe.bean({
|
account = frappe.new_doc({
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
"account_name": account_name,
|
"account_name": account_name,
|
||||||
"company": company,
|
"company": company,
|
||||||
@ -63,5 +58,5 @@ class ChartOfAccounts(Document):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_charts_for_country(country):
|
def get_charts_for_country(country):
|
||||||
return frappe.db.sql_list("select chart_name from `tabChart of Accounts` where country=%s",
|
return frappe.db.sql_list("""select chart_name from `tabChart of Accounts`
|
||||||
country)
|
where country=%s""", country)
|
@ -13,7 +13,7 @@ def import_charts():
|
|||||||
chart = json.loads(f.read())
|
chart = json.loads(f.read())
|
||||||
country = frappe.db.get_value("Country", {"code": fname.split("_", 1)[0]})
|
country = frappe.db.get_value("Country", {"code": fname.split("_", 1)[0]})
|
||||||
if country:
|
if country:
|
||||||
bean = frappe.bean({
|
bean = frappe.new_doc({
|
||||||
"doctype":"Chart of Accounts",
|
"doctype":"Chart of Accounts",
|
||||||
"chart_name": chart.get("name"),
|
"chart_name": chart.get("name"),
|
||||||
"source_file": fname,
|
"source_file": fname,
|
||||||
|
@ -3,19 +3,17 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
from frappe.utils.nestedset import DocTypeNestedSet
|
from frappe.utils.nestedset import DocTypeNestedSet
|
||||||
|
|
||||||
class CostCenter(DocTypeNestedSet):
|
class CostCenter(DocTypeNestedSet):
|
||||||
|
nsm_parent_field = 'parent_cost_center'
|
||||||
self.nsm_parent_field = 'parent_cost_center'
|
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
company_abbr = frappe.db.sql("select abbr from tabCompany where name=%s",
|
self.name = self.cost_center_name.strip() + ' - ' + \
|
||||||
self.company)[0][0]
|
frappe.get_value("Company", self.company, "abbr")
|
||||||
self.name = self.cost_center_name.strip() + ' - ' + company_abbr
|
|
||||||
|
|
||||||
def validate_mandatory(self):
|
def validate_mandatory(self):
|
||||||
if not self.group_or_ledger:
|
if not self.group_or_ledger:
|
||||||
@ -78,7 +76,7 @@ class CostCenter(DocTypeNestedSet):
|
|||||||
new_cost_center = get_name_with_abbr(newdn, self.company)
|
new_cost_center = get_name_with_abbr(newdn, self.company)
|
||||||
|
|
||||||
# Validate properties before merging
|
# Validate properties before merging
|
||||||
super(DocType, self).before_rename(olddn, new_cost_center, merge, "group_or_ledger")
|
super(CostCenter, self).before_rename(olddn, new_cost_center, merge, "group_or_ledger")
|
||||||
|
|
||||||
return new_cost_center
|
return new_cost_center
|
||||||
|
|
||||||
@ -87,5 +85,5 @@ class CostCenter(DocTypeNestedSet):
|
|||||||
frappe.db.set_value("Cost Center", newdn, "cost_center_name",
|
frappe.db.set_value("Cost Center", newdn, "cost_center_name",
|
||||||
" - ".join(newdn.split(" - ")[:-1]))
|
" - ".join(newdn.split(" - ")[:-1]))
|
||||||
else:
|
else:
|
||||||
super(DocType, self).after_rename(olddn, newdn, merge)
|
super(CostCenter, self).after_rename(olddn, newdn, merge)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cint, cstr, flt, formatdate
|
from frappe.utils import cint, cstr, flt, formatdate
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
|
@ -10,7 +10,7 @@ from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate,
|
|||||||
|
|
||||||
from frappe.utils import comma_and
|
from frappe.utils import comma_and
|
||||||
from frappe.model.naming import make_autoname
|
from frappe.model.naming import make_autoname
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import _, msgprint
|
from frappe import _, msgprint
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cstr, flt
|
from frappe.utils import cstr, flt
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import msgprint
|
from frappe import msgprint
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cstr, flt, getdate
|
from frappe.utils import cstr, flt, getdate
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint
|
from frappe import msgprint
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
@ -6,7 +6,7 @@ import frappe
|
|||||||
|
|
||||||
from frappe.utils import add_days, cint, cstr, flt, getdate, nowdate, _round
|
from frappe.utils import add_days, cint, cstr, flt, getdate, nowdate, _round
|
||||||
from frappe.model.naming import make_autoname
|
from frappe.model.naming import make_autoname
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cint, cstr, flt, now, nowdate
|
from frappe.utils import cint, cstr, flt, now, nowdate
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cstr, flt, cint, nowdate, add_days
|
from frappe.utils import cstr, flt, cint, nowdate, add_days
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cstr, getdate
|
from frappe.utils import cstr, getdate
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint
|
from frappe import msgprint
|
||||||
from erpnext.stock.utils import get_valid_serial_nos
|
from erpnext.stock.utils import get_valid_serial_nos
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cstr, cint
|
from frappe.utils import cstr, cint
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cstr
|
from frappe.utils import cstr
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import _, msgprint
|
from frappe import _, msgprint
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import frappe
|
|||||||
import frappe.utils
|
import frappe.utils
|
||||||
|
|
||||||
from frappe.utils import cstr, flt, getdate
|
from frappe.utils import cstr, flt, getdate
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import msgprint
|
from frappe import msgprint
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cstr, flt, has_common, make_esc
|
from frappe.utils import cstr, flt, has_common, make_esc
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import session, msgprint
|
from frappe import session, msgprint
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
from frappe.utils.nestedset import DocTypeNestedSet
|
from frappe.utils.nestedset import DocTypeNestedSet
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
|
|
||||||
from frappe.utils.nestedset import DocTypeNestedSet
|
from frappe.utils.nestedset import DocTypeNestedSet
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cstr, flt, cint
|
from frappe.utils import cstr, flt, cint
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cstr, flt, getdate, now_datetime, formatdate
|
from frappe.utils import cstr, flt, getdate, now_datetime, formatdate
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
from frappe.model.controller import DocListController
|
from frappe.model.controller import DocListController
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cstr, flt
|
from frappe.utils import cstr, flt
|
||||||
from frappe.model.bean import getlist
|
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cstr, flt, cint
|
from frappe.utils import cstr, flt, cint
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
|
@ -6,7 +6,7 @@ import frappe
|
|||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
|
|
||||||
from frappe.utils import cstr, cint, flt, comma_or, nowdate
|
from frappe.utils import cstr, cint, flt, comma_or, nowdate
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from erpnext.stock.utils import get_incoming_rate
|
from erpnext.stock.utils import get_incoming_rate
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import add_days, cstr, flt, nowdate, cint, now
|
from frappe.utils import add_days, cstr, flt, nowdate, cint, now
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import session, msgprint
|
from frappe import session, msgprint
|
||||||
from erpnext.stock.utils import get_valid_serial_nos
|
from erpnext.stock.utils import get_valid_serial_nos
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import add_days, cstr, getdate, cint
|
from frappe.utils import add_days, cstr, getdate, cint
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import throw, _
|
from frappe import throw, _
|
||||||
from erpnext.utilities.transaction_base import TransactionBase, delete_events
|
from erpnext.utilities.transaction_base import TransactionBase, delete_events
|
||||||
from erpnext.stock.utils import get_valid_serial_nos
|
from erpnext.stock.utils import get_valid_serial_nos
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cstr
|
from frappe.utils import cstr
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint
|
from frappe import msgprint
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import frappe, json
|
|||||||
from frappe.utils import nowdate, cstr
|
from frappe.utils import nowdate, cstr
|
||||||
from frappe.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from frappe import msgprint, throw, _
|
from frappe import msgprint, throw, _
|
||||||
from frappe.model.bean import getlist
|
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user