Merge pull request #1672 from nabinhait/v4-hotfix
Account root type and email digest for income / expense
This commit is contained in:
commit
d2802cab6c
@ -49,6 +49,7 @@ cur_frm.cscript.master_type = function(doc, cdt, cdn) {
|
||||
}
|
||||
|
||||
cur_frm.add_fetch('parent_account', 'report_type', 'report_type');
|
||||
cur_frm.add_fetch('parent_account', 'root_type', 'root_type');
|
||||
|
||||
cur_frm.cscript.account_type = function(doc, cdt, cdn) {
|
||||
if(doc.group_or_ledger=='Ledger') {
|
||||
|
@ -82,13 +82,6 @@
|
||||
"permlevel": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "report_type",
|
||||
"fieldtype": "Select",
|
||||
"label": "Report Type",
|
||||
"options": "\nBalance Sheet\nProfit and Loss",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Setting Account Type helps in selecting this Account in transactions.",
|
||||
"fieldname": "account_type",
|
||||
@ -169,6 +162,22 @@
|
||||
"options": "\nDebit\nCredit",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "root_type",
|
||||
"fieldtype": "Select",
|
||||
"label": "Root Type",
|
||||
"options": "\nAsset\nLiability\nIncome\nExpense\nEquity",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "report_type",
|
||||
"fieldtype": "Select",
|
||||
"label": "Report Type",
|
||||
"options": "\nBalance Sheet\nProfit and Loss",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "lft",
|
||||
"fieldtype": "Int",
|
||||
@ -200,7 +209,7 @@
|
||||
"icon": "icon-money",
|
||||
"idx": 1,
|
||||
"in_create": 1,
|
||||
"modified": "2014-05-12 17:03:19.733139",
|
||||
"modified": "2014-05-21 11:42:47.255511",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Account",
|
||||
|
@ -42,7 +42,7 @@ class Account(Document):
|
||||
"""Fetch Parent Details and validation for account not to be created under ledger"""
|
||||
if self.parent_account:
|
||||
par = frappe.db.get_value("Account", self.parent_account,
|
||||
["name", "group_or_ledger", "report_type"], as_dict=1)
|
||||
["name", "group_or_ledger", "report_type", "root_type"], as_dict=1)
|
||||
if not par:
|
||||
throw(_("Parent account does not exist"))
|
||||
elif par["name"] == self.name:
|
||||
@ -52,6 +52,8 @@ class Account(Document):
|
||||
|
||||
if par["report_type"]:
|
||||
self.report_type = par["report_type"]
|
||||
if par["root_type"]:
|
||||
self.root_type = par["root_type"]
|
||||
|
||||
def validate_root_details(self):
|
||||
#does not exists parent
|
||||
@ -99,6 +101,9 @@ class Account(Document):
|
||||
if not self.report_type:
|
||||
throw(_("Report Type is mandatory"))
|
||||
|
||||
if not self.root_type:
|
||||
throw(_("Root Type is mandatory"))
|
||||
|
||||
def validate_warehouse_account(self):
|
||||
if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
|
||||
return
|
||||
@ -194,10 +199,10 @@ class Account(Document):
|
||||
throw(_("Account {0} does not exist").format(new))
|
||||
|
||||
val = list(frappe.db.get_value("Account", new_account,
|
||||
["group_or_ledger", "report_type", "company"]))
|
||||
["group_or_ledger", "root_type", "company"]))
|
||||
|
||||
if val != [self.group_or_ledger, self.report_type, self.company]:
|
||||
throw(_("""Merging is only possible if following properties are same in both records. Group or Ledger, Report Type, Company"""))
|
||||
if val != [self.group_or_ledger, self.root_type, self.company]:
|
||||
throw(_("""Merging is only possible if following properties are same in both records. Group or Ledger, Root Type, Company"""))
|
||||
|
||||
return new_account
|
||||
|
||||
|
@ -43,4 +43,4 @@ execute:frappe.delete_doc_if_exists("DocType", "Warehouse User")
|
||||
execute:frappe.db.sql("delete from `tabWebsite Item Group` where ifnull(item_group, '')=''")
|
||||
execute:frappe.delete_doc("Print Format", "SalesInvoice")
|
||||
execute:import frappe.defaults;frappe.defaults.clear_default("price_list_currency")
|
||||
|
||||
erpnext.patches.v4_0.update_account_root_type
|
||||
|
39
erpnext/patches/v4_0/update_account_root_type.py
Normal file
39
erpnext/patches/v4_0/update_account_root_type.py
Normal file
@ -0,0 +1,39 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("accounts", "doctype", "account")
|
||||
|
||||
account_table_columns = frappe.db.get_table_columns("Account")
|
||||
if "debit_or_credit" in account_table_columns and "is_pl_account" in account_table_columns:
|
||||
frappe.db.sql("""UPDATE tabAccount
|
||||
SET root_type = CASE
|
||||
WHEN (debit_or_credit='Debit' and is_pl_account = 'No') THEN 'Asset'
|
||||
WHEN (debit_or_credit='Credit' and is_pl_account = 'No') THEN 'Liability'
|
||||
WHEN (debit_or_credit='Debit' and is_pl_account = 'Yes') THEN 'Expense'
|
||||
WHEN (debit_or_credit='Credit' and is_pl_account = 'Yes') THEN 'Income'
|
||||
END
|
||||
WHERE ifnull(parent_account, '') = ''
|
||||
""")
|
||||
|
||||
else:
|
||||
frappe.db.sql("""UPDATE tabAccount
|
||||
SET root_type = CASE
|
||||
WHEN name like '%%asset%%' THEN 'Asset'
|
||||
WHEN name like '%%liabilities%%' THEN 'Liability'
|
||||
WHEN name like '%%expense%%' THEN 'Expense'
|
||||
WHEN name like '%%income%%' THEN 'Income'
|
||||
END
|
||||
WHERE ifnull(parent_account, '') = ''
|
||||
""")
|
||||
|
||||
for root in frappe.db.sql("""SELECT name, lft, rgt, root_type FROM `tabAccount`
|
||||
WHERE ifnull(parent_account, '')=''""", as_dict=True):
|
||||
if root.root_type:
|
||||
frappe.db.sql("""UPDATE tabAccount SET root_type=%s WHERE lft>%s and rgt<%s""",
|
||||
(root.root_type, root.lft, root.rgt))
|
||||
else:
|
||||
print b"Root type not found for {0}".format(root.name.encode("utf-8"))
|
@ -81,11 +81,12 @@ class Company(Document):
|
||||
chart = frappe.get_doc("Chart of Accounts", self.chart_of_accounts)
|
||||
chart.create_accounts(self.name)
|
||||
|
||||
def add_acc(self,lst):
|
||||
def add_acc(self, lst):
|
||||
account = frappe.get_doc({
|
||||
"doctype": "Account",
|
||||
"freeze_account": "No",
|
||||
"master_type": "",
|
||||
"company": self.name
|
||||
})
|
||||
|
||||
for d in self.fld_dict.keys():
|
||||
@ -182,77 +183,77 @@ class Company(Document):
|
||||
'group_or_ledger': 2,
|
||||
'account_type': 3,
|
||||
'report_type': 4,
|
||||
'company': 5,
|
||||
'tax_rate': 6
|
||||
'tax_rate': 5,
|
||||
'root_type': 6
|
||||
}
|
||||
|
||||
acc_list_common = [
|
||||
[_('Application of Funds (Assets)'),'','Group','','Balance Sheet',self.name,''],
|
||||
[_('Current Assets'),_('Application of Funds (Assets)'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Accounts Receivable'),_('Current Assets'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Bank Accounts'),_('Current Assets'),'Group','Bank','Balance Sheet',self.name,''],
|
||||
[_('Cash In Hand'),_('Current Assets'),'Group','Cash','Balance Sheet',self.name,''],
|
||||
[_('Cash'),_('Cash In Hand'),'Ledger','Cash','Balance Sheet',self.name,''],
|
||||
[_('Loans and Advances (Assets)'),_('Current Assets'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Securities and Deposits'),_('Current Assets'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Earnest Money'),_('Securities and Deposits'),'Ledger','','Balance Sheet',self.name,''],
|
||||
[_('Stock Assets'),_('Current Assets'),'Group','Stock','Balance Sheet',self.name,''],
|
||||
[_('Tax Assets'),_('Current Assets'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Fixed Assets'),_('Application of Funds (Assets)'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Capital Equipments'),_('Fixed Assets'),'Ledger','Fixed Asset','Balance Sheet',self.name,''],
|
||||
[_('Computers'),_('Fixed Assets'),'Ledger','Fixed Asset','Balance Sheet',self.name,''],
|
||||
[_('Furniture and Fixture'),_('Fixed Assets'),'Ledger','Fixed Asset','Balance Sheet',self.name,''],
|
||||
[_('Office Equipments'),_('Fixed Assets'),'Ledger','Fixed Asset','Balance Sheet',self.name,''],
|
||||
[_('Plant and Machinery'),_('Fixed Assets'),'Ledger','Fixed Asset','Balance Sheet',self.name,''],
|
||||
[_('Investments'),_('Application of Funds (Assets)'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Temporary Accounts (Assets)'),_('Application of Funds (Assets)'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Temporary Account (Assets)'),_('Temporary Accounts (Assets)'),'Ledger','','Balance Sheet',self.name,''],
|
||||
[_('Expenses'),'','Group','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Direct Expenses'),_('Expenses'),'Group','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Stock Expenses'),_('Direct Expenses'),'Group','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Cost of Goods Sold'),_('Stock Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Stock Adjustment'),_('Stock Expenses'),'Ledger','Stock Adjustment','Profit and Loss',self.name,''],
|
||||
[_('Expenses Included In Valuation'), _("Stock Expenses"), 'Ledger', 'Expenses Included In Valuation', 'Profit and Loss', self.name, ''],
|
||||
[_('Indirect Expenses'), _('Expenses'),'Group','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Marketing Expenses'), _('Indirect Expenses'),'Ledger','Chargeable','Profit and Loss',self.name,''],
|
||||
[_('Sales Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Administrative Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Charity and Donations'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Commission on Sales'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Travel Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Entertainment Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Depreciation'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Freight and Forwarding Charges'), _('Indirect Expenses'),'Ledger','Chargeable','Profit and Loss',self.name,''],
|
||||
[_('Legal Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Miscellaneous Expenses'), _('Indirect Expenses'),'Ledger','Chargeable','Profit and Loss',self.name,''],
|
||||
[_('Office Maintenance Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Office Rent'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Postal Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Print and Stationary'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Rounded Off'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Salary') ,_('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Telephone Expenses') ,_('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Utility Expenses') ,_('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss',self.name,''],
|
||||
[_('Income'),'','Group','','Profit and Loss',self.name,''],
|
||||
[_('Direct Income'),_('Income'),'Group','Income Account','Profit and Loss',self.name,''],
|
||||
[_('Sales'),_('Direct Income'),'Ledger','Income Account','Profit and Loss',self.name,''],
|
||||
[_('Service'),_('Direct Income'),'Ledger','Income Account','Profit and Loss',self.name,''],
|
||||
[_('Indirect Income'),_('Income'),'Group','Income Account','Profit and Loss',self.name,''],
|
||||
[_('Source of Funds (Liabilities)'),'','Group','','Balance Sheet',self.name,''],
|
||||
[_('Capital Account'),_('Source of Funds (Liabilities)'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Reserves and Surplus'),_('Capital Account'),'Ledger','','Balance Sheet',self.name,''],
|
||||
[_('Shareholders Funds'),_('Capital Account'),'Ledger','','Balance Sheet',self.name,''],
|
||||
[_('Current Liabilities'),_('Source of Funds (Liabilities)'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Accounts Payable'),_('Current Liabilities'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Stock Liabilities'),_('Current Liabilities'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Stock Received But Not Billed'), _('Stock Liabilities'), 'Ledger', 'Stock Received But Not Billed', 'Balance Sheet', self.name, ''],
|
||||
[_('Duties and Taxes'),_('Current Liabilities'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Loans (Liabilities)'),_('Current Liabilities'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Secured Loans'),_('Loans (Liabilities)'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Unsecured Loans'),_('Loans (Liabilities)'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Bank Overdraft Account'),_('Loans (Liabilities)'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Temporary Accounts (Liabilities)'),_('Source of Funds (Liabilities)'),'Group','','Balance Sheet',self.name,''],
|
||||
[_('Temporary Account (Liabilities)'),_('Temporary Accounts (Liabilities)'),'Ledger','','Balance Sheet',self.name,'']
|
||||
[_('Application of Funds (Assets)'),'','Group','','Balance Sheet','', 'Asset'],
|
||||
[_('Current Assets'),_('Application of Funds (Assets)'),'Group','','Balance Sheet','', 'Asset'],
|
||||
[_('Accounts Receivable'),_('Current Assets'),'Group','','Balance Sheet','', 'Asset'],
|
||||
[_('Bank Accounts'),_('Current Assets'),'Group','Bank','Balance Sheet','', 'Asset'],
|
||||
[_('Cash In Hand'),_('Current Assets'),'Group','Cash','Balance Sheet','', 'Asset'],
|
||||
[_('Cash'),_('Cash In Hand'),'Ledger','Cash','Balance Sheet','', 'Asset'],
|
||||
[_('Loans and Advances (Assets)'),_('Current Assets'),'Group','','Balance Sheet','', 'Asset'],
|
||||
[_('Securities and Deposits'),_('Current Assets'),'Group','','Balance Sheet','', 'Asset'],
|
||||
[_('Earnest Money'),_('Securities and Deposits'),'Ledger','','Balance Sheet','', 'Asset'],
|
||||
[_('Stock Assets'),_('Current Assets'),'Group','Stock','Balance Sheet','', 'Asset'],
|
||||
[_('Tax Assets'),_('Current Assets'),'Group','','Balance Sheet','', 'Asset'],
|
||||
[_('Fixed Assets'),_('Application of Funds (Assets)'),'Group','','Balance Sheet','', 'Asset'],
|
||||
[_('Capital Equipments'),_('Fixed Assets'),'Ledger','Fixed Asset','Balance Sheet','', 'Asset'],
|
||||
[_('Computers'),_('Fixed Assets'),'Ledger','Fixed Asset','Balance Sheet','', 'Asset'],
|
||||
[_('Furniture and Fixture'),_('Fixed Assets'),'Ledger','Fixed Asset','Balance Sheet','', 'Asset'],
|
||||
[_('Office Equipments'),_('Fixed Assets'),'Ledger','Fixed Asset','Balance Sheet','', 'Asset'],
|
||||
[_('Plant and Machinery'),_('Fixed Assets'),'Ledger','Fixed Asset','Balance Sheet','', 'Asset'],
|
||||
[_('Investments'),_('Application of Funds (Assets)'),'Group','','Balance Sheet','', 'Asset'],
|
||||
[_('Temporary Accounts (Assets)'),_('Application of Funds (Assets)'),'Group','','Balance Sheet','', 'Asset'],
|
||||
[_('Temporary Account (Assets)'),_('Temporary Accounts (Assets)'),'Ledger','','Balance Sheet','', 'Asset'],
|
||||
[_('Expenses'),'','Group','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Direct Expenses'),_('Expenses'),'Group','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Stock Expenses'),_('Direct Expenses'),'Group','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Cost of Goods Sold'),_('Stock Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Stock Adjustment'),_('Stock Expenses'),'Ledger','Stock Adjustment','Profit and Loss','', 'Expense'],
|
||||
[_('Expenses Included In Valuation'), _("Stock Expenses"), 'Ledger', 'Expenses Included In Valuation', 'Profit and Loss', '', 'Expense'],
|
||||
[_('Indirect Expenses'), _('Expenses'),'Group','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Marketing Expenses'), _('Indirect Expenses'),'Ledger','Chargeable','Profit and Loss','', 'Expense'],
|
||||
[_('Sales Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Administrative Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Charity and Donations'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Commission on Sales'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Travel Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Entertainment Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Depreciation'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Freight and Forwarding Charges'), _('Indirect Expenses'),'Ledger','Chargeable','Profit and Loss','', 'Expense'],
|
||||
[_('Legal Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Miscellaneous Expenses'), _('Indirect Expenses'),'Ledger','Chargeable','Profit and Loss','', 'Expense'],
|
||||
[_('Office Maintenance Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Office Rent'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Postal Expenses'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Print and Stationary'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Rounded Off'), _('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Salary') ,_('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Telephone Expenses') ,_('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Utility Expenses') ,_('Indirect Expenses'),'Ledger','Expense Account','Profit and Loss','', 'Expense'],
|
||||
[_('Income'),'','Group','','Profit and Loss','', 'Income'],
|
||||
[_('Direct Income'),_('Income'),'Group','Income Account','Profit and Loss','', 'Income'],
|
||||
[_('Sales'),_('Direct Income'),'Ledger','Income Account','Profit and Loss','', 'Income'],
|
||||
[_('Service'),_('Direct Income'),'Ledger','Income Account','Profit and Loss','', 'Income'],
|
||||
[_('Indirect Income'),_('Income'),'Group','Income Account','Profit and Loss','', 'Income'],
|
||||
[_('Source of Funds (Liabilities)'),'','Group','','Balance Sheet','', 'Income'],
|
||||
[_('Capital Account'),_('Source of Funds (Liabilities)'),'Group','','Balance Sheet','', 'Liability'],
|
||||
[_('Reserves and Surplus'),_('Capital Account'),'Ledger','','Balance Sheet','', 'Liability'],
|
||||
[_('Shareholders Funds'),_('Capital Account'),'Ledger','','Balance Sheet','', 'Liability'],
|
||||
[_('Current Liabilities'),_('Source of Funds (Liabilities)'),'Group','','Balance Sheet','', 'Liability'],
|
||||
[_('Accounts Payable'),_('Current Liabilities'),'Group','','Balance Sheet','', 'Liability'],
|
||||
[_('Stock Liabilities'),_('Current Liabilities'),'Group','','Balance Sheet','', 'Liability'],
|
||||
[_('Stock Received But Not Billed'), _('Stock Liabilities'), 'Ledger', 'Stock Received But Not Billed', 'Balance Sheet', '', 'Liability'],
|
||||
[_('Duties and Taxes'),_('Current Liabilities'),'Group','','Balance Sheet','', 'Liability'],
|
||||
[_('Loans (Liabilities)'),_('Current Liabilities'),'Group','','Balance Sheet','', 'Liability'],
|
||||
[_('Secured Loans'),_('Loans (Liabilities)'),'Group','','Balance Sheet','', 'Liability'],
|
||||
[_('Unsecured Loans'),_('Loans (Liabilities)'),'Group','','Balance Sheet','', 'Liability'],
|
||||
[_('Bank Overdraft Account'),_('Loans (Liabilities)'),'Group','','Balance Sheet','', 'Liability'],
|
||||
[_('Temporary Accounts (Liabilities)'),_('Source of Funds (Liabilities)'),'Group','','Balance Sheet','', 'Liability'],
|
||||
[_('Temporary Account (Liabilities)'),_('Temporary Accounts (Liabilities)'),'Ledger','','Balance Sheet','', 'Liability']
|
||||
]
|
||||
|
||||
# load common account heads
|
||||
|
@ -96,7 +96,7 @@
|
||||
{
|
||||
"fieldname": "income_year_to_date",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"hidden": 0,
|
||||
"label": "Income Year to Date",
|
||||
"permlevel": 0
|
||||
},
|
||||
@ -104,7 +104,7 @@
|
||||
"description": "Income booked for the digest period",
|
||||
"fieldname": "income",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"hidden": 0,
|
||||
"label": "Income Booked",
|
||||
"permlevel": 0
|
||||
},
|
||||
@ -112,24 +112,10 @@
|
||||
"description": "Expenses booked for the digest period",
|
||||
"fieldname": "expenses_booked",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"hidden": 0,
|
||||
"label": "Expenses Booked",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Payments received during the digest period",
|
||||
"fieldname": "collections",
|
||||
"fieldtype": "Check",
|
||||
"label": "Payments Received",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Payments made during the digest period",
|
||||
"fieldname": "payments",
|
||||
"fieldtype": "Check",
|
||||
"label": "Payments Made",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Receivable / Payable account will be identified based on the field Master Type",
|
||||
"fieldname": "column_break_16",
|
||||
@ -151,6 +137,20 @@
|
||||
"label": "Payables",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Payments received during the digest period",
|
||||
"fieldname": "collections",
|
||||
"fieldtype": "Check",
|
||||
"label": "Payments Received",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Payments made during the digest period",
|
||||
"fieldname": "payments",
|
||||
"fieldtype": "Check",
|
||||
"label": "Payments Made",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_20",
|
||||
"fieldtype": "Section Break",
|
||||
@ -328,7 +328,7 @@
|
||||
],
|
||||
"icon": "icon-envelope",
|
||||
"idx": 1,
|
||||
"modified": "2014-05-09 02:16:43.979204",
|
||||
"modified": "2014-05-20 14:02:36.762220",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Email Digest",
|
||||
|
@ -13,8 +13,7 @@ from frappe.utils.email_lib import sendmail
|
||||
from frappe.core.doctype.user.user import STANDARD_USERS
|
||||
|
||||
content_sequence = [
|
||||
# ["Income / Expenses", ["income_year_to_date", "bank_balance",
|
||||
# "income", "expenses_booked"]],
|
||||
["Income / Expenses", ["income_year_to_date", "income", "expenses_booked"]],
|
||||
["Receivables / Payables", ["collections", "payments",
|
||||
"invoiced_amount", "payables"]],
|
||||
["Bank Balance", ["bank_balance"]],
|
||||
@ -154,9 +153,9 @@ class EmailDigest(Document):
|
||||
|
||||
return msg
|
||||
|
||||
# def get_income_year_to_date(self):
|
||||
# return self.get_income(frappe.db.get_defaults("year_start_date"),
|
||||
# self.meta.get_label("income_year_to_date"))
|
||||
def get_income_year_to_date(self):
|
||||
return self.get_income(frappe.db.get_defaults("year_start_date"),
|
||||
self.meta.get_label("income_year_to_date"))
|
||||
|
||||
def get_bank_balance(self):
|
||||
# account is of type "Bank" or "Cash"
|
||||
@ -169,36 +168,34 @@ class EmailDigest(Document):
|
||||
accounts[gle["account"]][1] += gle["debit"] - gle["credit"]
|
||||
|
||||
# build html
|
||||
out = self.get_html("Bank/Cash Balance", "", "")
|
||||
out = self.get_html("Bank/Cash Balance as on " + formatdate(self.to_date), "", "")
|
||||
for ac in ackeys:
|
||||
if accounts[ac][1]:
|
||||
out += "\n" + self.get_html(accounts[ac][0], self.currency,
|
||||
fmt_money(accounts[ac][1]), style="margin-left: 17px")
|
||||
return sum((accounts[ac][1] for ac in ackeys)), out
|
||||
|
||||
# def get_income(self, from_date=None, label=None):
|
||||
# # account is PL Account and Credit type account
|
||||
# accounts = [a["name"] for a in self.get_accounts() if a["root_type"]=="Income"]
|
||||
#
|
||||
# income = 0
|
||||
# for gle in self.get_gl_entries(from_date or self.from_date, self.to_date):
|
||||
# if gle["account"] in accounts:
|
||||
# income += gle["credit"] - gle["debit"]
|
||||
#
|
||||
# return income, self.get_html(label or self.meta.get_label("income"), self.currency,
|
||||
# fmt_money(income))
|
||||
#
|
||||
# def get_expenses_booked(self):
|
||||
# # account is PL Account and Debit type account
|
||||
# accounts = [a["name"] for a in self.get_accounts() if a["root_type"]=="Expense"]
|
||||
#
|
||||
# expense = 0
|
||||
# for gle in self.get_gl_entries(self.from_date, self.to_date):
|
||||
# if gle["account"] in accounts:
|
||||
# expense += gle["debit"] - gle["credit"]
|
||||
#
|
||||
# return expense, self.get_html(self.meta.get_label("expenses_booked"), self.currency,
|
||||
# fmt_money(expense))
|
||||
def get_income(self, from_date=None, label=None):
|
||||
accounts = [a["name"] for a in self.get_accounts() if a["root_type"]=="Income"]
|
||||
|
||||
income = 0
|
||||
for gle in self.get_gl_entries(from_date or self.from_date, self.to_date):
|
||||
if gle["account"] in accounts:
|
||||
income += gle["credit"] - gle["debit"]
|
||||
|
||||
return income, self.get_html(label or self.meta.get_label("income"), self.currency,
|
||||
fmt_money(income))
|
||||
|
||||
def get_expenses_booked(self):
|
||||
accounts = [a["name"] for a in self.get_accounts() if a["root_type"]=="Expense"]
|
||||
|
||||
expense = 0
|
||||
for gle in self.get_gl_entries(self.from_date, self.to_date):
|
||||
if gle["account"] in accounts:
|
||||
expense += gle["debit"] - gle["credit"]
|
||||
|
||||
return expense, self.get_html(self.meta.get_label("expenses_booked"), self.currency,
|
||||
fmt_money(expense))
|
||||
|
||||
def get_collections(self):
|
||||
return self.get_party_total("Customer", "credit", self.meta.get_label("collections"))
|
||||
@ -390,7 +387,7 @@ class EmailDigest(Document):
|
||||
|
||||
def get_accounts(self):
|
||||
if not hasattr(self, "accounts"):
|
||||
self.accounts = frappe.db.sql("""select name, account_type, account_name, master_type
|
||||
self.accounts = frappe.db.sql("""select name, account_type, account_name, master_type, root_type
|
||||
from `tabAccount` where company=%s and docstatus < 2
|
||||
and group_or_ledger = "Ledger" order by lft""",
|
||||
(self.company,), as_dict=1)
|
||||
|
@ -192,7 +192,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
|
||||
{fieldname:'company_name', label: __('Company Name'), fieldtype:'Data', reqd:1,
|
||||
placeholder: __('e.g. "My Company LLC"')},
|
||||
{fieldname:'company_abbr', label: __('Company Abbreviation'), fieldtype:'Data',
|
||||
placeholder: __('e.g. "MC"'),reqd:1},
|
||||
description: __('Max 5 characters'), placeholder: __('e.g. "MC"'), reqd:1},
|
||||
{fieldname:'fy_start_date', label:__('Financial Year Start Date'), fieldtype:'Date',
|
||||
description: __('Your financial year begins on'), reqd:1},
|
||||
{fieldname:'fy_end_date', label:__('Financial Year End Date'), fieldtype:'Date',
|
||||
@ -205,9 +205,16 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
|
||||
slide.get_input("company_name").on("change", function() {
|
||||
var parts = slide.get_input("company_name").val().split(" ");
|
||||
var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join("");
|
||||
slide.get_input("company_abbr").val(abbr.toUpperCase());
|
||||
slide.get_input("company_abbr").val(abbr.slice(0, 5).toUpperCase());
|
||||
}).val(frappe.boot.sysdefaults.company_name || "").trigger("change");
|
||||
|
||||
slide.get_input("company_abbr").on("change", function() {
|
||||
if(slide.get_input("company_abbr").val().length > 5) {
|
||||
msgprint("Company Abbreviation cannot have more than 5 characters");
|
||||
slide.get_input("company_abbr").val("");
|
||||
}
|
||||
});
|
||||
|
||||
slide.get_input("fy_start_date").on("change", function() {
|
||||
var year_end_date =
|
||||
frappe.datetime.add_days(frappe.datetime.add_months(
|
||||
|
Loading…
Reference in New Issue
Block a user