[journal voucher] [added opening entry] [cleanups]
This commit is contained in:
parent
03e9a4ea11
commit
8706ca9445
@ -82,7 +82,7 @@ cur_frm.cscript.account_type = function(doc, cdt, cdn) {
|
|||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
||||||
cur_frm.add_custom_button('Chart of Accounts',
|
cur_frm.add_custom_button('Chart of Accounts',
|
||||||
function() { wn.set_route("Accounts Browser", "Account"); }, 'icon-list')
|
function() { wn.set_route("Accounts Browser", "Account"); }, 'icon-sitemap')
|
||||||
|
|
||||||
if (cstr(doc.group_or_ledger) == 'Group') {
|
if (cstr(doc.group_or_ledger) == 'Group') {
|
||||||
cur_frm.add_custom_button('Convert to Ledger',
|
cur_frm.add_custom_button('Convert to Ledger',
|
||||||
|
@ -28,6 +28,9 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger')
|
cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger')
|
||||||
cur_frm.set_intro(intro_txt);
|
cur_frm.set_intro(intro_txt);
|
||||||
|
|
||||||
|
cur_frm.add_custom_button('Chart of Cost Centers',
|
||||||
|
function() { wn.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap')
|
||||||
}
|
}
|
||||||
|
|
||||||
//Account filtering for cost center
|
//Account filtering for cost center
|
||||||
|
@ -140,9 +140,20 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
|||||||
cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher");
|
cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher");
|
||||||
cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher");
|
cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher");
|
||||||
|
|
||||||
if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)
|
if(wn.model.get("Journal Voucher Detail", {"parent":doc.name}).length!===0 // too late
|
||||||
&& doc.company
|
|| !doc.company) // too early
|
||||||
&& wn.model.get("Journal Voucher Detail", {"parent":doc.name}).length==0) {
|
return;
|
||||||
|
|
||||||
|
var update_jv_details = function(doc, r) {
|
||||||
|
$.each(r.message, function(i, d) {
|
||||||
|
var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries");
|
||||||
|
jvdetail.account = d.account;
|
||||||
|
jvdetail.balance = d.balance;
|
||||||
|
});
|
||||||
|
refresh_field("entries");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)) {
|
||||||
wn.call({
|
wn.call({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
method: "accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",
|
method: "accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",
|
||||||
@ -152,14 +163,26 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
|||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries");
|
update_jv_details(doc, r);
|
||||||
jvdetail.account = r.message.account;
|
|
||||||
// this is a data field????
|
|
||||||
jvdetail.balance = format_currency(r.message.balance);
|
|
||||||
refresh_field("entries");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else if(doc.voucher_type=="Opening Entry") {
|
||||||
|
wn.call({
|
||||||
|
type:"GET",
|
||||||
|
method: "accounts.doctype.journal_voucher.journal_voucher.get_opening_accounts",
|
||||||
|
args: {
|
||||||
|
"company": doc.company
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
wn.model.clear_table("Journal Voucher Detail", "Journal Voucher",
|
||||||
|
doc.name, "entries");
|
||||||
|
if(r.message) {
|
||||||
|
update_jv_details(doc, r);
|
||||||
|
}
|
||||||
|
cur_frm.set_value("is_opening", "Yes")
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,10 +352,19 @@ def get_default_bank_cash_account(company, voucher_type):
|
|||||||
account = webnotes.conn.get_value("Company", company,
|
account = webnotes.conn.get_value("Company", company,
|
||||||
voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account")
|
voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account")
|
||||||
if account:
|
if account:
|
||||||
return {
|
return [{
|
||||||
"account": account,
|
"account": account,
|
||||||
"balance": get_balance_on(account)
|
"balance": get_balance_on(account)
|
||||||
}
|
}]
|
||||||
|
|
||||||
|
@webnotes.whitelist()
|
||||||
|
def get_opening_accounts(company):
|
||||||
|
"""get all balance sheet accounts for opening entry"""
|
||||||
|
from accounts.utils import get_balance_on
|
||||||
|
accounts = webnotes.conn.sql_list("""select name from tabAccount
|
||||||
|
where group_or_ledger='Ledger' and is_pl_account='No' and company=%s""", company)
|
||||||
|
|
||||||
|
return [{"account": a, "balance": get_balance_on(a)} for a in accounts]
|
||||||
|
|
||||||
def get_against_purchase_invoice(doctype, txt, searchfield, start, page_len, filters):
|
def get_against_purchase_invoice(doctype, txt, searchfield, start, page_len, filters):
|
||||||
return webnotes.conn.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date
|
return webnotes.conn.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-03-25 10:53:52",
|
"creation": "2013-03-25 10:53:52",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-06-11 16:04:20",
|
"modified": "2013-06-28 14:27:11",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -68,7 +68,7 @@
|
|||||||
"label": "Voucher Type",
|
"label": "Voucher Type",
|
||||||
"oldfieldname": "voucher_type",
|
"oldfieldname": "voucher_type",
|
||||||
"oldfieldtype": "Select",
|
"oldfieldtype": "Select",
|
||||||
"options": "\nJournal Entry\nBank Voucher\nCash Voucher\nCredit Card Voucher\nDebit Note\nCredit Note\nContra Voucher\nExcise Voucher\nWrite Off Voucher",
|
"options": "\nJournal Entry\nBank Voucher\nCash Voucher\nCredit Card Voucher\nDebit Note\nCredit Note\nContra Voucher\nExcise Voucher\nWrite Off Voucher\nOpening Entry",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
|
@ -9,11 +9,11 @@ wn.pages['voucher-import-tool'].onload = function(wrapper) {
|
|||||||
<p class="help">Import multiple accounting entries via CSV (spreadsheet) file:</p>\
|
<p class="help">Import multiple accounting entries via CSV (spreadsheet) file:</p>\
|
||||||
<h3>1. Download Template</h3><br>\
|
<h3>1. Download Template</h3><br>\
|
||||||
<div style="padding-left: 30px;">\
|
<div style="padding-left: 30px;">\
|
||||||
<button class="btn btn-download-two-accounts">Download</button>\
|
<button class="btn btn-default btn-download-two-accounts">Download</button>\
|
||||||
<p class="help">Import multiple vouchers with one debit and one credit entry</p>\
|
<p class="help">Import multiple vouchers with one debit and one credit entry</p>\
|
||||||
</div>\
|
</div>\
|
||||||
<div style="padding-left: 30px;">\
|
<div style="padding-left: 30px;">\
|
||||||
<button class="btn btn-download-multiple-accounts">Download</button>\
|
<button class="btn btn-default btn-download-multiple-accounts">Download</button>\
|
||||||
<p class="help">Import multiple vouchers with multiple accounts</p>\
|
<p class="help">Import multiple vouchers with multiple accounts</p>\
|
||||||
</div>\
|
</div>\
|
||||||
<hr>\
|
<hr>\
|
||||||
|
@ -61,14 +61,21 @@ class DocType:
|
|||||||
WHERE name=%(name)s AND docstatus<2""", args)
|
WHERE name=%(name)s AND docstatus<2""", args)
|
||||||
|
|
||||||
def create_fiscal_year_and_company(self, args):
|
def create_fiscal_year_and_company(self, args):
|
||||||
curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start'))
|
curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start'), True)
|
||||||
# Fiscal Year
|
|
||||||
webnotes.bean([{
|
webnotes.bean([{
|
||||||
"doctype":"Fiscal Year",
|
"doctype":"Fiscal Year",
|
||||||
'year': curr_fiscal_year,
|
'year': curr_fiscal_year,
|
||||||
'year_start_date': fy_start_date,
|
'year_start_date': fy_start_date,
|
||||||
}]).insert()
|
}]).insert()
|
||||||
|
|
||||||
|
curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start'))
|
||||||
|
webnotes.bean([{
|
||||||
|
"doctype":"Fiscal Year",
|
||||||
|
'year': curr_fiscal_year,
|
||||||
|
'year_start_date': fy_start_date,
|
||||||
|
}]).insert()
|
||||||
|
|
||||||
|
|
||||||
# Company
|
# Company
|
||||||
webnotes.bean([{
|
webnotes.bean([{
|
||||||
"doctype":"Company",
|
"doctype":"Company",
|
||||||
@ -198,13 +205,15 @@ class DocType:
|
|||||||
|
|
||||||
# Get Fiscal year Details
|
# Get Fiscal year Details
|
||||||
# ------------------------
|
# ------------------------
|
||||||
def get_fy_details(self, fy_start):
|
def get_fy_details(self, fy_start, last_year=False):
|
||||||
st = {'1st Jan':'01-01','1st Apr':'04-01','1st Jul':'07-01', '1st Oct': '10-01'}
|
st = {'1st Jan':'01-01','1st Apr':'04-01','1st Jul':'07-01', '1st Oct': '10-01'}
|
||||||
curr_year = getdate(nowdate()).year
|
curr_year = getdate(nowdate()).year
|
||||||
|
if last_year:
|
||||||
|
curr_year = curr_year - 1
|
||||||
if cint(getdate(nowdate()).month) < cint((st[fy_start].split('-'))[0]):
|
if cint(getdate(nowdate()).month) < cint((st[fy_start].split('-'))[0]):
|
||||||
curr_year = getdate(nowdate()).year - 1
|
curr_year = getdate(nowdate()).year - 1
|
||||||
stdt = cstr(curr_year)+'-'+cstr(st[fy_start])
|
stdt = cstr(curr_year)+'-'+cstr(st[fy_start])
|
||||||
#eddt = sql("select DATE_FORMAT(DATE_SUB(DATE_ADD('%s', INTERVAL 1 YEAR), INTERVAL 1 DAY),'%%d-%%m-%%Y')" % (stdt.split('-')[2]+ '-' + stdt.split('-')[1] + '-' + stdt.split('-')[0]))
|
|
||||||
if(fy_start == '1st Jan'):
|
if(fy_start == '1st Jan'):
|
||||||
fy = cstr(getdate(nowdate()).year)
|
fy = cstr(getdate(nowdate()).year)
|
||||||
abbr = cstr(fy)[-2:]
|
abbr = cstr(fy)[-2:]
|
||||||
|
@ -121,8 +121,6 @@ class DocType(DocListController):
|
|||||||
self.doc.posting_time = '00:00'
|
self.doc.posting_time = '00:00'
|
||||||
|
|
||||||
def on_doctype_update(self):
|
def on_doctype_update(self):
|
||||||
webnotes.msgprint(webnotes.conn.sql("""show index from `tabStock Ledger Entry`
|
|
||||||
where Key_name="posting_sort_index" """))
|
|
||||||
if not webnotes.conn.sql("""show index from `tabStock Ledger Entry`
|
if not webnotes.conn.sql("""show index from `tabStock Ledger Entry`
|
||||||
where Key_name="posting_sort_index" """):
|
where Key_name="posting_sort_index" """):
|
||||||
webnotes.conn.commit()
|
webnotes.conn.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user