added voucher import tool
diff --git a/accounts/doctype/lease_agreement/__init__.py b/accounts/doctype/lease_agreement/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/accounts/doctype/lease_agreement/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/accounts/doctype/lease_agreement/lease_agreement.js b/accounts/doctype/lease_agreement/lease_agreement.js
deleted file mode 100644
index bf0495c..0000000
--- a/accounts/doctype/lease_agreement/lease_agreement.js
+++ /dev/null
@@ -1,94 +0,0 @@
-// ERPNext - web based ERP (http://erpnext.com)
-// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-$.extend(cur_frm.cscript, {
- Generate: function(doc, dt, dn) {
- if(doc.installment_amount==''){
- msgprint('Set Installment Amount before generating schedule');
- return;
- }
- if(doc.no_of_installments==''){
- msgprint('Set Number of Installments before generating schedule');
- return;
- }
- if(doc.start_date==''){
- msgprint('Set Start Date before generating schedule');
- return;
- }
- cur_frm.cscript.clear_installments(doc);
- tot=0;i=0;
- while(tot<flt(doc.invoice_amount)-flt(doc.down_payment)){
- d = LocalDB.add_child(doc, 'Lease Installment', 'installments');
- d.amount = flt(doc.installment_amount) < flt(doc.invoice_amount)-flt(doc.down_payment)-tot ? flt(doc.installment_amount) : flt(doc.invoice_amount)-flt(doc.down_payment)-tot
- d.due_date = dateutil.add_months(doc.start_date, i+1);
- tot += flt(doc.installment_amount)
- i++;
- }
- cur_frm.refresh();
- },
- refresh: function(doc) {
- cur_frm.cscript.hide_show_buttons(doc);
- },
- hide_show_buttons: function(doc) {
- if(doc.docstatus==0) {
- hide_field('installment_reciept'); show_field('generate');
- } else if (doc.docstatus==1) {
- show_field('installment_reciept');hide_field('generate');
- }
- },
- clear_installments: function(doc) {
- $.each(getchildren('Lease Installment', doc.name, 'installments', 'Lease Agreement'),
- function(i, d) {
- LocalDB.delete_doc('Lease Installment', d.name);
- }
- )
- },
- no_of_installments: function(doc)
- {
- if(flt(doc.no_of_installments)!=0) {
- doc.installment_amount = (flt(doc.invoice_amount)- flt(doc.down_payment))/flt(doc.no_of_installments);
- refresh_field('installment_amount');
- }
- },
- 'Installment Reciept': function(doc, dt, dn) {
- var d = new wn.widgets.Dialog({
- width: 500,
- title: 'Add a new payment installment',
- fields: [
- {fieldtype:'Data', label:'Cheque Number', fieldname:'cheque_number', reqd:1},
- {fieldtype:'Date', label:'Cheque Date', fieldname:'cheque_date', reqd:1},
- {fieldtype:'Link', label:'Bank Account', fieldname:'bank_account', reqd:1, options:'Account'},
- {fieldtype:'Button', label:'Update',fieldname:'update'}
- ]
- })
- d.show();
- d.fields_dict.update.input.onclick = function() {
- var data = d.get_values();
-
- if(data) {
- $c_obj(make_doclist(dt,dn),'lease_installment_post',data,function(){cur_frm.refresh(); d.hide();});
- }
- }
- }
-})
-
-
-cur_frm.add_fetch('invoice','grand_total','invoice_amount');
-
-cur_frm.fields_dict.invoice.get_query=function(doc){
-
- return "SELECT tv.name FROM `tabSales Invoice` tv WHERE debit_to='"+doc.account+"' and tv.%(key)s like '%s' ORDER BY tv.name LIMIT 50"
-}
diff --git a/accounts/doctype/lease_agreement/lease_agreement.py b/accounts/doctype/lease_agreement/lease_agreement.py
deleted file mode 100644
index f5f444c..0000000
--- a/accounts/doctype/lease_agreement/lease_agreement.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-from webnotes.model.doc import make_autoname, Document, addchild
-from webnotes import msgprint
-from webnotes.utils import get_defaults
-import json
-from accounts.utils import post_jv
-sql = webnotes.conn.sql
-
-class DocType:
- def __init__(self, doc, doclist):
- self.doc, self.doclist = doc, doclist
-
- def autoname(self):
- """
- Create Lease Id using naming_series pattern
- """
- self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
-
- def lease_installment_post(self, args):
- """
- Posts the Installment receipt into Journal Voucher
- """
- next_inst = sql("select amount,name from `tabLease Installment` where parent=%s and ifnull(cheque_number,'')='' order by due_date limit 1",self.doc.name)
-
- data = json.loads(args)
- data['voucher_type']='Lease Receipt'
- data['naming_series']='JV'
- data['amount']=next_inst[0][0]
- data['debit_account']=data.get('bank_account')
- data['credit_account']=self.doc.account
- data['fiscal_year']=get_defaults()['fiscal_year']
- data['company']=get_defaults()['company']
- jv_name=post_jv(data)
-
- sql("update `tabLease Installment` set cheque_number=%s, cheque_date=%s, jv_number=%s where name=%s",(data.get('cheque_number'),data.get('cheque_date'),jv_name,next_inst[0][1]))
-
- self.doclist = [Document(d.doctype, d.name) for d in self.doclist]
diff --git a/accounts/doctype/lease_agreement/lease_agreement.txt b/accounts/doctype/lease_agreement/lease_agreement.txt
deleted file mode 100644
index c4f3e12..0000000
--- a/accounts/doctype/lease_agreement/lease_agreement.txt
+++ /dev/null
@@ -1,276 +0,0 @@
-# DocType, Lease Agreement
-[
-
- # These values are common in all dictionaries
- {
- 'creation': '2012-03-27 14:35:44',
- 'docstatus': 0,
- 'modified': '2012-03-27 14:35:44',
- 'modified_by': u'Administrator',
- 'owner': u'Administrator'
- },
-
- # These values are common for all DocType
- {
- '_last_update': u'1311555967',
- 'colour': u'White:FFF',
- 'default_print_format': u'Standard',
- 'doctype': 'DocType',
- 'module': u'Accounts',
- 'name': '__common__',
- 'section_style': u'Simple',
- 'show_in_menu': 0,
- 'version': 24
- },
-
- # These values are common for all DocField
- {
- 'doctype': u'DocField',
- 'name': '__common__',
- 'parent': u'Lease Agreement',
- 'parentfield': u'fields',
- 'parenttype': u'DocType'
- },
-
- # These values are common for all DocPerm
- {
- 'create': 1,
- 'doctype': u'DocPerm',
- 'name': '__common__',
- 'parent': u'Lease Agreement',
- 'parentfield': u'permissions',
- 'parenttype': u'DocType',
- 'read': 1,
- 'role': u'Accounts Manager'
- },
-
- # DocType, Lease Agreement
- {
- 'doctype': 'DocType',
- 'name': u'Lease Agreement'
- },
-
- # DocPerm
- {
- 'amend': 1,
- 'cancel': 1,
- 'doctype': u'DocPerm',
- 'submit': 1,
- 'write': 1
- },
-
- # DocPerm
- {
- 'amend': 0,
- 'cancel': 0,
- 'doctype': u'DocPerm',
- 'submit': 0,
- 'write': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'naming_series',
- 'fieldtype': u'Select',
- 'label': u'Naming Series',
- 'no_copy': 1,
- 'options': u'\nLA',
- 'permlevel': 0,
- 'reqd': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'lessee_info',
- 'fieldtype': u'Section Break',
- 'label': u'Lessee Info.',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'account',
- 'fieldtype': u'Link',
- 'label': u'Account',
- 'options': u'Account',
- 'permlevel': 0,
- 'reqd': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'lessee_father',
- 'fieldtype': u'Data',
- 'label': u'Lessee Father',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'lessee_nic',
- 'fieldtype': u'Data',
- 'label': u'Lessee NIC',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'lessee_contact',
- 'fieldtype': u'Data',
- 'label': u'Lessee Contact',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'lessee_address',
- 'fieldtype': u'Text',
- 'label': u'Lessee Address',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'vehicle_info',
- 'fieldtype': u'Section Break',
- 'label': u'Vehicle Info.',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'model_no',
- 'fieldtype': u'Data',
- 'label': u'Model No',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'engine_no',
- 'fieldtype': u'Data',
- 'label': u'Engine No',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'chassis_no',
- 'fieldtype': u'Data',
- 'label': u'Chassis No',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'invoice_and_payment_info',
- 'fieldtype': u'Section Break',
- 'label': u'Invoice and Payment Info.',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'colour': u'White:FFF',
- 'doctype': u'DocField',
- 'fieldname': u'invoice',
- 'fieldtype': u'Link',
- 'label': u'Invoice',
- 'options': u'Sales Invoice',
- 'permlevel': 0,
- 'reqd': 1,
- 'trigger': u'Client'
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'invoice_amount',
- 'fieldtype': u'Currency',
- 'label': u'Invoice Amount',
- 'permlevel': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'down_payment',
- 'fieldtype': u'Currency',
- 'label': u'Down Payment',
- 'permlevel': 0,
- 'reqd': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'start_date',
- 'fieldtype': u'Date',
- 'label': u'Start Date',
- 'permlevel': 0,
- 'reqd': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'no_of_installments',
- 'fieldtype': u'Int',
- 'label': u'No of Installments',
- 'permlevel': 0,
- 'reqd': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'installment_amount',
- 'fieldtype': u'Currency',
- 'label': u'Installment Amount',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'colour': u'White:FFF',
- 'doctype': u'DocField',
- 'fieldname': u'generate',
- 'fieldtype': u'Button',
- 'label': u'Generate',
- 'permlevel': 0,
- 'trigger': u'Client'
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'installments',
- 'fieldtype': u'Table',
- 'label': u'Installments',
- 'options': u'Lease Installment',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'allow_on_submit': 1,
- 'colour': u'White:FFF',
- 'doctype': u'DocField',
- 'fieldname': u'installment_reciept',
- 'fieldtype': u'Button',
- 'label': u'Installment Reciept',
- 'permlevel': 0
- }
-]
\ No newline at end of file
diff --git a/accounts/doctype/lease_installment/__init__.py b/accounts/doctype/lease_installment/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/accounts/doctype/lease_installment/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/accounts/doctype/lease_installment/lease_installment.txt b/accounts/doctype/lease_installment/lease_installment.txt
deleted file mode 100644
index 475d226..0000000
--- a/accounts/doctype/lease_installment/lease_installment.txt
+++ /dev/null
@@ -1,86 +0,0 @@
-# DocType, Lease Installment
-[
-
- # These values are common in all dictionaries
- {
- 'creation': '2012-03-27 14:35:44',
- 'docstatus': 0,
- 'modified': '2012-03-27 14:35:44',
- 'modified_by': u'Administrator',
- 'owner': u'Administrator'
- },
-
- # These values are common for all DocType
- {
- 'colour': u'White:FFF',
- 'doctype': 'DocType',
- 'istable': 1,
- 'module': u'Accounts',
- 'name': '__common__',
- 'section_style': u'Simple',
- 'show_in_menu': 0,
- 'version': 5
- },
-
- # These values are common for all DocField
- {
- 'doctype': u'DocField',
- 'name': '__common__',
- 'parent': u'Lease Installment',
- 'parentfield': u'fields',
- 'parenttype': u'DocType'
- },
-
- # DocType, Lease Installment
- {
- 'doctype': 'DocType',
- 'name': u'Lease Installment'
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'amount',
- 'fieldtype': u'Currency',
- 'label': u'Amount',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'due_date',
- 'fieldtype': u'Date',
- 'label': u'Due Date',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'cheque_number',
- 'fieldtype': u'Data',
- 'label': u'Cheque Number',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'cheque_date',
- 'fieldtype': u'Date',
- 'label': u'Cheque Date',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'jv_number',
- 'fieldtype': u'Link',
- 'hidden': 0,
- 'label': u'JV Number',
- 'options': u'Journal Voucher',
- 'permlevel': 1
- }
-]
\ No newline at end of file
diff --git a/accounts/page/voucher_import_tool/__init__.py b/accounts/page/voucher_import_tool/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/accounts/page/voucher_import_tool/__init__.py
diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.js b/accounts/page/voucher_import_tool/voucher_import_tool.js
new file mode 100644
index 0000000..4b9e3f7
--- /dev/null
+++ b/accounts/page/voucher_import_tool/voucher_import_tool.js
@@ -0,0 +1,55 @@
+wn.pages['voucher-import-tool'].onload = function(wrapper) {
+ wn.ui.make_app_page({
+ parent: wrapper,
+ title: 'Voucher Import Tool',
+ single_column: true
+ });
+
+ $(wrapper).find('.layout-main').html('\
+ <p class="help">Import multiple accounting entries via CSV (spreadsheet) file:</p>\
+ <h3>1. Download Template</h3><br>\
+ <div style="padding-left: 30px;">\
+ <button class="btn btn-small btn-download-multiple">Download</button>\
+ <p class="help">Import multiple vouchers with one debit and one credit entry</p>\
+ </div>\
+ <hr>\
+ <h3>2. Upload</h3><br>\
+ <div style="padding-left: 30px;">\
+ <p class="help">Upload file in CSV format with UTF-8 encoding</p>\
+ <div id="voucher-upload"></div>\
+ </div><br>\
+ <div class="working"></div>\
+ <div class="well messages" style="display: none;"></div>');
+
+ wn.upload.make({
+ parent: $(wrapper).find("#voucher-upload"),
+ args: {
+ method: "accounts.page.voucher_import_tool.voucher_import_tool.upload"
+ },
+ callback: function(r) {
+ wrapper.waiting.toggle(false);
+ $(wrapper).find(".messages").toggle(true).html(
+ r.join("<div style='margin:4px; border-top:1px solid #aaa;'></div>"))
+ }
+ });
+
+ wrapper.waiting = wn.messages.waiting($(wrapper).find('.working'),
+ "Importing Vouchers...").toggle(false);
+
+ $(wrapper).find(".btn-download-single").click(function() {
+ window.location.href = wn.request.url
+ + '?cmd=accounts.page.voucher_import_tool.voucher_import_tool.get_template_single';
+ });
+
+ $(wrapper).find(".btn-download-multiple").click(function() {
+ window.location.href = wn.request.url
+ + '?cmd=accounts.page.voucher_import_tool.voucher_import_tool.get_template_multiple';
+ });
+
+ // rename button
+ $(wrapper).find('#voucher-upload form input[type="submit"]')
+ .click(function() {
+ $(wrapper).find(".messages").toggle(false);
+ wrapper.waiting.toggle(true);
+ });
+}
\ No newline at end of file
diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py
new file mode 100644
index 0000000..1cbeb99
--- /dev/null
+++ b/accounts/page/voucher_import_tool/voucher_import_tool.py
@@ -0,0 +1,185 @@
+import webnotes
+from webnotes.utils import formatdate
+
+@webnotes.whitelist()
+def get_template_multiple():
+ """download single template"""
+ from webnotes.model.doctype import get_field_property
+ naming_options = get_field_property("Journal Voucher", "naming_series", "options")
+ voucher_type = get_field_property("Journal Voucher", "voucher_type", "options")
+
+ webnotes.response['result'] = '''"Voucher Import :Multiple"
+"Each entry below will be a separate Journal Voucher."
+"Note:"
+"1. Dates in format: %(user_fmt)s"
+"2. Cost Center is required for Income or Expense accounts"
+"3. Naming Series Options: %(naming_options)s"
+"4. Voucher Type Options: %(voucher_type)s"
+"-------Common Values-----------"
+"Company:","%(default_company)s"
+"--------Data----------"
+"Naming Series","Voucher Type","Posting Date","Amount","Debit Account","Credit Account","Cost Center","Against Sales Invoice","Against Purchase Invoice","Against Journal Voucher","Remarks","Due Date","Ref Number","Ref Date"
+''' % {
+ "user_fmt": webnotes.conn.get_value('Control Panel', None, 'date_format'),
+ "default_company": webnotes.conn.get_default("company"),
+ "naming_options": naming_options.replace("\n", ", "),
+ "voucher_type": voucher_type.replace("\n", ", ")
+ }
+ webnotes.response['type'] = 'csv'
+ webnotes.response['doctype'] = "Voucher-Import-Single"
+
+@webnotes.whitelist()
+def upload():
+ from webnotes.utils.datautils import read_csv_content_from_uploaded_file
+ rows = read_csv_content_from_uploaded_file()
+
+ common_values = get_common_values(rows)
+ data = get_data(rows)
+
+ if rows[0][0]=="Voucher Import :Single":
+ return import_single(common_values, data)
+ else:
+ return import_multiple(common_values, data)
+
+def map_fields(field_list, source, target):
+ for f in field_list:
+ if ":" in f:
+ target[f.split(":")[1]] = source.get(f.split(":")[0])
+ else:
+ target[f] = source.get(f)
+
+def import_multiple(common_values, data):
+ from webnotes.model.doc import Document
+ from webnotes.model.doclist import DocList
+ from webnotes.model.code import get_obj
+ from accounts.utils import get_fiscal_year_from_date
+ from webnotes.utils.dateutils import user_to_str
+
+ messages = []
+
+ def get_account_details(account):
+ acc_details = webnotes.conn.sql("""select is_pl_account,
+ master_name from tabAccount where name=%s""", account, as_dict=1)
+ if not acc_details:
+ webnotes.msgprint("%s is not an Account" % account, raise_exception=1)
+ return acc_details[0]
+
+ def apply_cost_center_and_against_invoice(detail, d):
+ account = get_account_details(detail.account)
+
+ if account.is_pl_account=="Yes":
+ detail.cost_center = d.cost_center
+
+ if account.master_name:
+ map_fields(["against_sales_invoice:against_invoice",
+ "against_purhase_invoice:against_voucher",
+ "against_journal_voucher:against_jv"], d, detail.fields)
+
+ webnotes.conn.commit()
+
+ for i in xrange(len(data)):
+ d = data[i]
+ jv = webnotes.DictObj()
+ webnotes.message_log = []
+ try:
+ d.posting_date = user_to_str(d.posting_date)
+ d.due_date = user_to_str(d.due_date)
+ d.ref_date = user_to_str(d.ref_date)
+ d.company = common_values.company
+
+ jv = Document("Journal Voucher")
+ map_fields(["voucher_type", "posting_date", "naming_series", "remarks:remark",
+ "ref_no:cheque_no", "ref_date:cheque_date", "is_opening",
+ "amount:total_debit", "amount:total_credit", "due_date", "company"], d, jv.fields)
+
+ jv.fiscal_year = get_fiscal_year_from_date(jv.posting_date)
+
+ detail1 = Document("Journal Voucher Detail")
+ detail1.parent = True
+ detail1.parentfield = "entries"
+ map_fields(["debit_account:account","amount:debit"], d, detail1.fields)
+ apply_cost_center_and_against_invoice(detail1, d)
+
+
+ detail2 = Document("Journal Voucher Detail")
+ detail2.parent = True
+ detail2.parentfield = "entries"
+ map_fields(["credit_account:account","amount:credit"], d, detail2.fields)
+ apply_cost_center_and_against_invoice(detail2, d)
+
+ webnotes.conn.begin()
+ doclist = DocList([jv, detail1, detail2])
+ doclist.submit()
+ webnotes.conn.commit()
+
+ messages.append("<p style='color: green'>[row #%s] %s imported</p>" \
+ % (i, jv.name))
+
+ except Exception, e:
+ webnotes.conn.rollback()
+ messages.append("<p style='color: red'>[row #%s] %s failed: %s</p>" \
+ % (i, jv.name, webnotes.message_log and webnotes.message_log[0] or "No message"))
+ webnotes.errprint(webnotes.getTraceback())
+
+ webnotes.message_log = []
+
+ return messages
+
+def get_common_values(rows):
+ start = False
+ common_values = webnotes.DictObj()
+
+ for r in rows:
+ if start:
+ if r[0].startswith("---"):
+ break
+ common_values[r[0][:-1].replace(" ", "_").lower()] = r[1]
+ if r[0]=="-------Common Values-----------":
+ start = True
+
+ return common_values
+
+def get_data(rows):
+ start_row = 0
+ data = []
+
+ for i in xrange(len(rows)):
+ r = rows[i]
+ if r[0]:
+ if start_row and i >= start_row:
+ d = webnotes.DictObj()
+ for cidx in xrange(len(columns)):
+ d[columns[cidx]] = r[cidx]
+ data.append(d)
+
+ if r[0]=="--------Data----------":
+ start_row = i+2
+ columns = [c.replace(" ", "_").lower() for c in rows[i+1]]
+
+ return data
+
+@webnotes.whitelist()
+def get_template_single():
+ """download single template"""
+
+ webnotes.response['result'] = '''"Voucher Import :Single"
+"All entries below will be uploaded in one Journal Voucher."
+"Enter details below:"
+"-------Common Values-----------"
+"Voucher Series:",
+"Voucher Type:",
+"Posting Date:","%(posting_date)s"
+"Remarks:",
+"Is Opening:","No"
+"Company:","%(default_company)s"
+"------------------"
+"Enter rows below headings:"
+"Cost Center is required for Income or Expense accounts"
+"--------Data----------"
+"Account","Cost Center","Debit Amount","Credit Amount","Against Sales Invoice","Against Purchase Invoice","Against Journal Voucher"
+''' % {
+ "posting_date": formatdate(),
+ "default_company": webnotes.conn.get_default("company")
+ }
+ webnotes.response['type'] = 'csv'
+ webnotes.response['doctype'] = "Voucher-Import-Single"
diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.txt b/accounts/page/voucher_import_tool/voucher_import_tool.txt
new file mode 100644
index 0000000..658ef00
--- /dev/null
+++ b/accounts/page/voucher_import_tool/voucher_import_tool.txt
@@ -0,0 +1,28 @@
+# Page, voucher-import-tool
+[
+
+ # These values are common in all dictionaries
+ {
+ u'creation': '2012-09-26 15:21:57',
+ u'docstatus': 0,
+ u'modified': '2012-09-26 15:21:57',
+ u'modified_by': u'Administrator',
+ u'owner': u'Administrator'
+ },
+
+ # These values are common for all Page
+ {
+ u'doctype': u'Page',
+ 'module': u'Accounts',
+ u'name': u'__common__',
+ 'page_name': u'voucher-import-tool',
+ 'standard': u'Yes',
+ 'title': u'Voucher Import Tool'
+ },
+
+ # Page, voucher-import-tool
+ {
+ u'doctype': u'Page',
+ u'name': u'voucher-import-tool'
+ }
+]
\ No newline at end of file
diff --git a/accounts/utils/__init__.py b/accounts/utils/__init__.py
index 05d2391f..3dbc728 100644
--- a/accounts/utils/__init__.py
+++ b/accounts/utils/__init__.py
@@ -15,30 +15,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
-from webnotes.model.doc import make_autoname, Document, addchild
-# Posts JV
-def post_jv(data):
- jv = Document('Journal Voucher')
- jv.voucher_type = data.get('voucher_type')
- jv.naming_series = data.get('naming_series')
- jv.voucher_date = data.get('cheque_date')
- jv.posting_date = data.get('cheque_date')
- jv.cheque_no = data.get('cheque_number')
- jv.cheque_date = data.get('cheque_date')
- jv.fiscal_year = data.get('fiscal_year') # To be modified to take care
- jv.company = data.get('company')
+import webnotes
- jv.save(1)
-
- jc = addchild(jv,'entries','Journal Voucher Detail',0)
- jc.account = data.get('debit_account')
- jc.debit = data.get('amount')
- jc.save()
-
- jc = addchild(jv,'entries','Journal Voucher Detail',0)
- jc.account = data.get('credit_account')
- jc.credit = data.get('amount')
- jc.save()
-
- return jv.name
\ No newline at end of file
+def get_fiscal_year_from_date(date):
+ from webnotes.utils import formatdate
+ fy = webnotes.conn.sql("""select name from `tabFiscal Year`
+ where %s between year_start_date and adddate(year_start_date,
+ interval 1 year)""", date)
+
+ if not fy:
+ webnotes.msgprint("""%s not in any Fiscal Year""" % formatdate(date), raise_exception=1)
+
+ return fy[0][0]
\ No newline at end of file
diff --git a/erpnext/patches/september_2012/event_permission.py b/patches/september_2012/event_permission.py
similarity index 100%
rename from erpnext/patches/september_2012/event_permission.py
rename to patches/september_2012/event_permission.py
diff --git a/erpnext/patches/september_2012/reload_gross_profit.py b/patches/september_2012/reload_gross_profit.py
similarity index 100%
rename from erpnext/patches/september_2012/reload_gross_profit.py
rename to patches/september_2012/reload_gross_profit.py
diff --git a/erpnext/patches/september_2012/repost_stock.py b/patches/september_2012/repost_stock.py
similarity index 100%
rename from erpnext/patches/september_2012/repost_stock.py
rename to patches/september_2012/repost_stock.py
diff --git a/utilities/page/users/users.js b/utilities/page/users/users.js
index ee05001..7f92609 100644
--- a/utilities/page/users/users.js
+++ b/utilities/page/users/users.js
@@ -95,7 +95,7 @@
if(data.file_list) {
data.imgsrc = 'files/' + data.file_list.split('\n')[0].split(',')[1];
} else {
- data.imgsrc = 'images/lib/ui/no_img_' + (data.gender=='Female' ? 'f' : 'm') + '.gif';
+ data.imgsrc = 'lib/images/ui/no_img_' + (data.gender=='Female' ? 'f' : 'm') + '.gif';
}
data.fullname = wn.user_info(data.name).fullname;
data.delete_html = '';
diff --git a/website/templates/html/outer.html b/website/templates/html/outer.html
index a671d98..1a036f0 100644
--- a/website/templates/html/outer.html
+++ b/website/templates/html/outer.html
@@ -45,7 +45,7 @@
{% endif %}
{% endfor %}
</ul>
- <img src="images/lib/ui/spinner.gif" id="spinner"/>
+ <img src="lib/images/ui/spinner.gif" id="spinner"/>
<ul class="nav pull-right">
<li id="login-topbar-item"><a href="login.html">Login</a></li>
</ul>