Merge branch 'master' of github.com:webnotes/erpnext into purchase_price_list

Conflicts:
	accounts/doctype/gl_control/gl_control.py
This commit is contained in:
Anand Doshi
2013-01-17 20:31:41 +05:30
92 changed files with 1234 additions and 1924 deletions

View File

@@ -2,20 +2,20 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-11-16 10:32:50",
"creation": "2013-01-17 12:30:10",
"modified_by": "Administrator",
"modified": "2012-12-03 11:26:49"
"modified": "2013-01-17 13:16:31"
},
{
"in_create": 1,
"allow_rename": 1,
"description": "Heads (or groups) against which Accounting Entries are made and balances are maintained.",
"search_fields": "debit_or_credit, group_or_ledger",
"module": "Accounts",
"document_type": "Master",
"description": "Heads (or groups) against which Accounting Entries are made and balances are maintained.",
"name": "__common__",
"allow_rename": 1,
"doctype": "DocType",
"allow_copy": 1
"allow_copy": 1,
"document_type": "Master",
"name": "__common__"
},
{
"name": "__common__",
@@ -28,8 +28,8 @@
"name": "__common__",
"parent": "Account",
"amend": 0,
"submit": 0,
"doctype": "DocPerm",
"submit": 0,
"read": 1,
"parenttype": "DocType",
"parentfield": "permissions"
@@ -139,32 +139,28 @@
"doctype": "DocField",
"label": "Parent Account",
"oldfieldname": "parent_account",
"trigger": "Client",
"options": "Account",
"fieldname": "parent_account",
"fieldtype": "Link",
"search_index": 1,
"options": "Account",
"permlevel": 0
},
{
"description": "Setting Account Type helps in selecting this Account in transactions.",
"oldfieldtype": "Select",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Account Type",
"oldfieldname": "account_type",
"permlevel": 0,
"trigger": "Client",
"options": "\nFixed Asset Account\nBank or Cash\nExpense Account\nTax\nIncome Account\nChargeable",
"fieldname": "account_type",
"fieldtype": "Select",
"search_index": 0,
"in_filter": 1,
"options": "\nFixed Asset Account\nBank or Cash\nExpense Account\nTax\nIncome Account\nChargeable"
"permlevel": 0,
"in_filter": 1
},
{
"description": "Rate at which this tax is applied",
"oldfieldtype": "Currency",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Rate",
"oldfieldname": "tax_rate",
@@ -177,7 +173,6 @@
{
"description": "If the account is frozen, entries are allowed for the \"Account Manager\" only.",
"oldfieldtype": "Select",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Frozen",
"oldfieldname": "freeze_account",
@@ -189,7 +184,6 @@
{
"print_hide": 1,
"oldfieldtype": "Int",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Credit Days",
"oldfieldname": "credit_days",
@@ -212,7 +206,6 @@
{
"description": "If this Account represents a Customer, Supplier or Employee, set it here.",
"oldfieldtype": "Select",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Master Type",
"oldfieldname": "master_type",
@@ -226,98 +219,127 @@
"doctype": "DocField",
"label": "Master Name",
"oldfieldname": "master_name",
"trigger": "Client",
"options": "[Select]",
"fieldname": "master_name",
"fieldtype": "Link",
"options": "[Select]",
"permlevel": 0
},
{
"read_only": 1,
"print_hide": 1,
"doctype": "DocField",
"label": "Lft",
"fieldname": "lft",
"fieldtype": "Int",
"hidden": 1,
"permlevel": 0
},
{
"read_only": 1,
"print_hide": 1,
"doctype": "DocField",
"label": "Rgt",
"fieldname": "rgt",
"fieldtype": "Int",
"hidden": 1,
"permlevel": 0
},
{
"read_only": 1,
"print_hide": 1,
"doctype": "DocField",
"label": "Old Parent",
"fieldname": "old_parent",
"fieldtype": "Data",
"hidden": 1,
"permlevel": 0
},
{
"create": 0,
"doctype": "DocPerm",
"write": 1,
"cancel": 0,
"role": "Auditor",
"cancel": 0,
"permlevel": 0
},
{
"create": 0,
"doctype": "DocPerm",
"write": 0,
"cancel": 0,
"role": "Auditor",
"cancel": 0,
"permlevel": 2
},
{
"create": 0,
"doctype": "DocPerm",
"write": 0,
"cancel": 0,
"role": "Auditor",
"cancel": 0,
"permlevel": 1
},
{
"create": 0,
"doctype": "DocPerm",
"write": 0,
"cancel": 0,
"role": "Sales User",
"cancel": 0,
"permlevel": 0
},
{
"create": 0,
"doctype": "DocPerm",
"write": 0,
"cancel": 0,
"role": "Purchase User",
"cancel": 0,
"permlevel": 0
},
{
"create": 0,
"doctype": "DocPerm",
"write": 1,
"cancel": 0,
"role": "Accounts User",
"cancel": 0,
"permlevel": 0
},
{
"create": 1,
"doctype": "DocPerm",
"write": 1,
"cancel": 1,
"role": "Accounts Manager",
"cancel": 1,
"permlevel": 0
},
{
"create": 0,
"doctype": "DocPerm",
"write": 0,
"cancel": 0,
"role": "Accounts User",
"cancel": 0,
"permlevel": 1
},
{
"create": 0,
"doctype": "DocPerm",
"write": 0,
"cancel": 0,
"role": "Accounts Manager",
"cancel": 0,
"permlevel": 1
},
{
"create": 0,
"doctype": "DocPerm",
"write": 1,
"cancel": 0,
"role": "Accounts Manager",
"cancel": 0,
"permlevel": 2
},
{
"create": 0,
"doctype": "DocPerm",
"write": 0,
"cancel": 0,
"role": "Accounts User",
"cancel": 0,
"permlevel": 2
}
]

View File

@@ -18,11 +18,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt, getdate
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql
from webnotes.model.wrapper import getlist
class DocType:
def __init__(self,d,dl):
@@ -31,53 +27,57 @@ class DocType:
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series + '.#####')
def validate(self):
"""Validate invoice that c-form is applicable
and no other c-form is received for that"""
for d in getlist(self.doclist, 'invoice_details'):
inv = webnotes.conn.sql("""select c_form_applicable, c_form_no from
`tabSales Invoice` where name = %s""", d.invoice_no)
if not inv:
webnotes.msgprint("Invoice: %s is not exists in the system, please check." %
d.invoice_no, raise_exception=1)
elif inv[0][0] != 'Yes':
webnotes.msgprint("C-form is not applicable for Invoice: %s" %
d.invoice_no, raise_exception=1)
elif inv[0][1] and inv[0][1] != self.doc.name:
webnotes.msgprint("""Invoice %s is tagged in another C-form: %s.
If you want to change C-form no for this invoice,
please remove invoice no from the previous c-form and then try again""" %
(d.invoice_no, inv[0][1]), raise_exception=1)
def on_update(self):
""" Update C-Form No on invoices"""
if len(getlist(self.doclist, 'invoice_details')):
inv = "'" + "', '".join([d.invoice_no for d in getlist(self.doclist, 'invoice_details')]) + "'"
sql("""update `tabSales Invoice` set c_form_no = '%s', modified ='%s'
where name in (%s)"""%(self.doc.name, self.doc.modified, inv))
sql("""update `tabSales Invoice` set c_form_no = '', modified = %s where name not
in (%s) and ifnull(c_form_no, '') = %s""", (self.doc.modified, self.doc.name, inv))
inv = [d.invoice_no for d in getlist(self.doclist, 'invoice_details')]
if inv:
webnotes.conn.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s
where name in (%s)""" % ('%s', '%s', ', '.join(['%s'] * len(inv))),
tuple([self.doc.name, self.doc.modified] + inv))
webnotes.conn.sql("""update `tabSales Invoice` set c_form_no = '', modified = %s
where name not in (%s) and ifnull(c_form_no, '') = %s""" %
('%s', ', '.join(['%s']*len(inv)), '%s'),
tuple([self.doc.modified] + inv + [self.doc.name]))
else:
msgprint("Please enter atleast 1 invoice in the table below", raise_exception=1)
webnotes.msgprint("Please enter atleast 1 invoice in the table", raise_exception=1)
self.calculate_total_invoiced_amount()
self.set_total_invoiced_amount()
def calculate_total_invoiced_amount(self):
total = 0
for d in getlist(self.doclist, 'invoice_details'):
total += flt(d.grand_total)
def set_total_invoiced_amount(self):
total = sum([flt(d.total) for d in getlist(self.doclist, 'invoice_details')])
webnotes.conn.set(self.doc, 'total_invoiced_amount', total)
def get_invoice_details(self, invoice_no):
""" Pull details from invoices for referrence """
inv = sql("""select posting_date, territory, net_total, grand_total from
`tabSales Invoice` where name = %s""", invoice_no)
ret = {
inv = webnotes.conn.sql("""select posting_date, territory, net_total, grand_total
from `tabSales Invoice` where name = %s""", invoice_no)
return {
'invoice_date' : inv and getdate(inv[0][0]).strftime('%Y-%m-%d') or '',
'territory' : inv and inv[0][1] or '',
'net_total' : inv and flt(inv[0][2]) or '',
'grand_total' : inv and flt(inv[0][3]) or ''
}
return ret
def validate_invoice(self):
"""Validate invoice that c-form is applicable and no other c-form is
received for that"""
for d in getlist(self.doclist, 'invoice_details'):
inv = sql("""select c_form_applicable, c_form_no from
`tabSales Invoice` where name = %s""", invoice_no)
if not inv:
msgprint("Invoice: %s is not exists in the system, please check." % d.invoice_no, raise_exception=1)
elif inv[0][0] != 'Yes':
msgprint("C-form is not applicable for Invoice: %s" % d.invoice_no, raise_exception=1)
elif inv[0][1] and inv[0][1] != self.doc.name:
msgprint("""Invoice %s is tagged in another C-form: %s. \nIf you want to change C-form no for this invoice,
please remove invoice no from the previous c-form and then try again""" % (d.invoice_no, inv[0][1]), raise_exception=1)
}

View File

@@ -46,9 +46,6 @@ class DocType:
return flt(bal)
# Add a new account
# -----------------
def add_ac(self,arg):
arg = eval(arg)
ac = Document('Account')
@@ -104,20 +101,28 @@ class DocType:
# Make a dictionary(le) for every gl entry and append to a list(self.entries)
#----------------------------------------------------------------------------
def make_single_entry(self,parent,d,le_map,cancel, merge_entries):
if self.get_val(le_map['account'], d, parent) and (self.get_val(le_map['debit'], d, parent) or self.get_val(le_map['credit'], d, parent)):
flist = ['account','cost_center','against','debit','credit','remarks','voucher_type','voucher_no','posting_date','fiscal_year','against_voucher','against_voucher_type','company','is_opening', 'aging_date']
if self.get_val(le_map['account'], d, parent) and \
(self.get_val(le_map['debit'], d, parent) \
or self.get_val(le_map['credit'], d, parent)):
flist = ['account', 'cost_center', 'against', 'debit', 'credit', 'remarks',
'voucher_type', 'voucher_no', 'posting_date', 'fiscal_year', 'against_voucher',
'against_voucher_type', 'company', 'is_opening', 'aging_date']
# Check budget before gl entry
#check budget only if account is expense account
is_expense_acct = webnotes.conn.sql("select name from tabAccount where is_pl_account='Yes' and debit_or_credit='Debit' and name=%s",self.get_val(le_map['account'], d, parent))
is_expense_acct = webnotes.conn.sql("""select name from tabAccount
where is_pl_account='Yes' and debit_or_credit='Debit'
and name=%s""",self.get_val(le_map['account'], d, parent))
if is_expense_acct and self.get_val(le_map['cost_center'], d, parent):
get_obj('Budget Control').check_budget([self.get_val(le_map[k], d, parent) for k in flist if k in ['account','cost_center','debit','credit','posting_date','fiscal_year','company']],cancel)
get_obj('Budget Control').check_budget([self.get_val(le_map[k], d, parent)
for k in flist if k in ['account', 'cost_center', 'debit',
'credit', 'posting_date', 'fiscal_year', 'company']],cancel)
# Create new GL entry object and map values
le = Document('GL Entry')
for k in flist:
le.fields[k] = self.get_val(le_map[k], d, parent)
# if there is already an entry in this account then just add it to that entry
same_head = self.check_if_in_list(le)
if same_head and merge_entries:
@@ -126,6 +131,7 @@ class DocType:
same_head.credit = flt(same_head.credit) + flt(le.credit)
else:
self.entries.append(le)
def manage_debit_credit(self, cancel):
total_debit, total_credit = 0, 0
@@ -183,7 +189,9 @@ class DocType:
if le_map['table_field']:
for d in getlist(doclist,le_map['table_field']):
# purchase_tax_details is the table of other charges in purchase cycle
if le_map['table_field'] != 'purchase_tax_details' or (le_map['table_field'] == 'purchase_tax_details' and d.fields.get('category') != 'Valuation'):
if le_map['table_field'] != 'purchase_tax_details' or \
(le_map['table_field'] == 'purchase_tax_details' and \
d.fields.get('category') != 'Valuation'):
self.make_single_entry(doc,d,le_map,cancel, merge_entries)
else:
self.make_single_entry(None,doc,le_map,cancel, merge_entries)
@@ -191,8 +199,6 @@ class DocType:
# save entries
self.save_entries(cancel, adv_adj, update_outstanding)
# set as cancelled
if cancel:
vt = self.get_val(le_map['voucher_type'], doc, doc)
@@ -209,7 +215,7 @@ class DocType:
and (t2.against_invoice is null or t2.against_invoice = '')
and (t2.against_jv is null or t2.against_jv = '')
and t2.account = '%s' and t2.is_advance = 'Yes' and t1.docstatus = 1
order by t1.voucher_date """ % (dr_or_cr,account_head))
order by t1.posting_date""" % (dr_or_cr,account_head))
# clear advance table
obj.doclist = obj.doc.clear_table(obj.doclist,table_field_name)
# Create advance table
@@ -300,9 +306,6 @@ class DocType:
return
######################################################################################################################
#------------------------------------------
def reconcile_against_document(self, args):
"""
Cancel JV, Update aginst document, split if required and resubmit jv
@@ -330,7 +333,6 @@ class DocType:
jv_obj = get_obj('Journal Voucher', d['voucher_no'], with_children =1)
self.make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel = 0, adv_adj =1)
#------------------------------------------
def update_against_doc(self, d, jv_obj):
"""
Updates against document, if partial amount splits into rows
@@ -338,9 +340,10 @@ class DocType:
webnotes.conn.sql("""
update `tabJournal Voucher Detail` t1, `tabJournal Voucher` t2
set t1.%(dr_or_cr)s = '%(allocated_amt)s', t1.%(against_fld)s = '%(against_voucher)s', t2.modified = now()
set t1.%(dr_or_cr)s = '%(allocated_amt)s',
t1.%(against_fld)s = '%(against_voucher)s', t2.modified = now()
where t1.name = '%(voucher_detail_no)s' and t1.parent = t2.name""" % d)
if d['allocated_amt'] < d['unadjusted_amt']:
jvd = webnotes.conn.sql("select cost_center, balance, against_account, is_advance from `tabJournal Voucher Detail` where name = '%s'" % d['voucher_detail_no'])
# new entry with balance amount
@@ -355,7 +358,6 @@ class DocType:
ch.docstatus = 1
ch.save(1)
#------------------------------------------
def check_if_jv_modified(self, args):
"""
check if there is already a voucher reference

View File

@@ -15,8 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if (!doc.voucher_date) doc.voucher_date = dateutil.obj_to_str(new Date());
cur_frm.cscript.load_defaults(doc, cdt, cdn);
}

View File

@@ -2,14 +2,14 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-12-03 17:26:38",
"creation": "2013-01-17 12:30:11",
"modified_by": "Administrator",
"modified": "2012-12-04 18:47:42"
"modified": "2013-01-17 14:27:43"
},
{
"is_submittable": 1,
"autoname": "naming_series:",
"name": "__common__",
"is_submittable": 1,
"search_fields": "voucher_type,posting_date, due_date, cheque_no",
"module": "Accounts",
"doctype": "DocType",
@@ -47,7 +47,6 @@
"description": "To manage multiple series please go to Setup > Manage Series",
"no_copy": 1,
"oldfieldtype": "Select",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Series",
"oldfieldname": "naming_series",
@@ -103,8 +102,8 @@
},
{
"print_hide": 0,
"allow_on_submit": 1,
"oldfieldtype": "Table",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Entries",
"oldfieldname": "entries",
@@ -163,7 +162,6 @@
"oldfieldtype": "Button",
"doctype": "DocField",
"label": "Make Difference Entry",
"trigger": "Client",
"fieldname": "get_balance",
"fieldtype": "Button",
"permlevel": 0
@@ -179,15 +177,14 @@
"description": "eg. Cheque Number",
"no_copy": 1,
"oldfieldtype": "Data",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Reference Number",
"oldfieldname": "cheque_no",
"fieldname": "cheque_no",
"fieldtype": "Data",
"search_index": 1,
"in_filter": 1,
"permlevel": 0
"permlevel": 0,
"in_filter": 1
},
{
"no_copy": 1,
@@ -291,12 +288,10 @@
"print_hide": 1,
"default": "No",
"oldfieldtype": "Select",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Is Opening",
"oldfieldname": "is_opening",
"permlevel": 0,
"trigger": "Client",
"fieldname": "is_opening",
"fieldtype": "Select",
"search_index": 1,
@@ -308,7 +303,6 @@
"description": "For opening invoice entry, this date will reflect in the period-wise aging report.",
"no_copy": 0,
"oldfieldtype": "Date",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Aging Date",
"oldfieldname": "aging_date",
@@ -320,7 +314,6 @@
"print_hide": 1,
"default": "Accounts Receivable",
"depends_on": "eval:doc.voucher_type == 'Write Off Voucher'",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Write Off Based On",
"options": "Accounts Receivable\nAccounts Payable",
@@ -332,7 +325,6 @@
{
"print_hide": 1,
"depends_on": "eval:doc.voucher_type == 'Write Off Voucher'",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Write Off Amount <=",
"fieldname": "write_off_amount",
@@ -343,30 +335,11 @@
{
"print_hide": 1,
"depends_on": "eval:doc.voucher_type == 'Write Off Voucher'",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Get Outstanding Invoices",
"trigger": "Server",
"options": "get_outstanding_invoices",
"fieldname": "get_outstanding_invoices",
"fieldtype": "Button",
"options": "get_outstanding_invoices",
"permlevel": 0
},
{
"print_hide": 0,
"description": "Date of entry (not posting to ledgers)",
"default": "Today",
"oldfieldtype": "Date",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Voucher Date",
"oldfieldname": "voucher_date",
"no_copy": 1,
"fieldname": "voucher_date",
"fieldtype": "Date",
"search_index": 1,
"reqd": 1,
"in_filter": 1,
"permlevel": 0
},
{
@@ -442,13 +415,11 @@
"print_hide": 1,
"no_copy": 1,
"oldfieldtype": "Link",
"colour": "White:FFF",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Select Print Heading",
"oldfieldname": "select_print_heading",
"permlevel": 0,
"trigger": "Client",
"fieldname": "select_print_heading",
"fieldtype": "Link",
"options": "Print Heading",
@@ -493,16 +464,14 @@
"print_hide": 1,
"no_copy": 1,
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Supplier Account",
"oldfieldname": "supplier_account",
"permlevel": 0,
"trigger": "Client",
"options": "Account",
"fieldname": "supplier_account",
"fieldtype": "Link",
"hidden": 0,
"options": "Account"
"permlevel": 0
},
{
"amend": 1,
@@ -510,8 +479,8 @@
"doctype": "DocPerm",
"submit": 1,
"write": 1,
"cancel": 1,
"role": "Accounts User",
"cancel": 1,
"permlevel": 0
},
{
@@ -520,8 +489,8 @@
"doctype": "DocPerm",
"submit": 0,
"write": 0,
"cancel": 0,
"role": "Accounts User",
"cancel": 0,
"permlevel": 1
},
{
@@ -530,8 +499,8 @@
"doctype": "DocPerm",
"submit": 0,
"write": 0,
"cancel": 0,
"role": "Accounts Manager",
"cancel": 0,
"permlevel": 1
},
{
@@ -540,8 +509,8 @@
"doctype": "DocPerm",
"submit": 1,
"write": 1,
"cancel": 1,
"role": "Accounts Manager",
"cancel": 1,
"permlevel": 0
},
{
@@ -550,8 +519,8 @@
"doctype": "DocPerm",
"submit": 0,
"write": 0,
"cancel": 0,
"role": "Auditor",
"cancel": 0,
"permlevel": 0
},
{
@@ -560,8 +529,8 @@
"doctype": "DocPerm",
"submit": 0,
"write": 0,
"cancel": 0,
"role": "Auditor",
"cancel": 0,
"permlevel": 1
}
]

View File

@@ -18,40 +18,37 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
from webnotes.model import db_exists
from webnotes.model.doc import addchild
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
class DocType:
def __init__(self, doc, doclist):
self.doc = doc
self.doclist = doclist
self.acc_type = self.doc.account and sql("select debit_or_credit from `tabAccount` where name = %s", self.doc.account)[0][0].lower() or ''
self.acc_type = self.doc.account and webnotes.conn.sql("""select debit_or_credit
from `tabAccount` where name = %s""", self.doc.account)[0][0].lower() or ''
self.dt = {
'Sales Invoice': 'Sales Invoice',
'Purchase Invoice': 'Purchase Invoice',
'Journal Voucher': 'Journal Voucher'
}
#--------------------------------------------------
def get_voucher_details(self):
tot_amt = sql("""
tot_amt = webnotes.conn.sql("""
select sum(%s) from `tabGL Entry` where
voucher_type = %s and voucher_no = %s
and account = %s and ifnull(is_cancelled, 'No') = 'No'
"""% (self.acc_type, '%s', '%s', '%s'), (self.dt[self.doc.voucher_type], self.doc.voucher_no, self.doc.account))
and account = %s and ifnull(is_cancelled, 'No') = 'No'""" %
(self.acc_type, '%s', '%s', '%s'),
(self.dt[self.doc.voucher_type], self.doc.voucher_no, self.doc.account))
outstanding = sql("""
outstanding = webnotes.conn.sql("""
select sum(%s) - sum(%s) from `tabGL Entry` where
against_voucher = %s and voucher_no != %s
and account = %s and ifnull(is_cancelled, 'No') = 'No'
""" % ((self.acc_type == 'debit' and 'credit' or 'debit'), self.acc_type, '%s', '%s', '%s'), (self.doc.voucher_no, self.doc.voucher_no, self.doc.account))
and account = %s and ifnull(is_cancelled, 'No') = 'No'""" %
((self.acc_type == 'debit' and 'credit' or 'debit'), self.acc_type, '%s', '%s', '%s'),
(self.doc.voucher_no, self.doc.voucher_no, self.doc.account))
ret = {
'total_amount': flt(tot_amt[0][0]) or 0,
@@ -60,8 +57,6 @@ class DocType:
return ret
#--------------------------------------------------
def get_payment_entries(self):
"""
Get payment entries for the account and period
@@ -72,7 +67,6 @@ class DocType:
gle = self.get_gl_entries()
self.create_payment_table(gle)
#--------------------------------------------------
def get_gl_entries(self):
self.validate_mandatory()
dc = self.acc_type == 'debit' and 'credit' or 'debit'
@@ -80,41 +74,40 @@ class DocType:
cond = self.doc.from_date and " and t1.posting_date >= '" + self.doc.from_date + "'" or ""
cond += self.doc.to_date and " and t1.posting_date <= '" + self.doc.to_date + "'"or ""
cond += self.doc.amt_greater_than and ' and t2.' + dc+' >= ' + self.doc.amt_greater_than or ''
cond += self.doc.amt_less_than and ' and t2.' + dc+' <= ' + self.doc.amt_less_than or ''
cond += self.doc.amt_greater_than and \
' and t2.' + dc+' >= ' + self.doc.amt_greater_than or ''
cond += self.doc.amt_less_than and \
' and t2.' + dc+' <= ' + self.doc.amt_less_than or ''
gle = sql("""
select t1.name as voucher_no, t1.posting_date, t1.total_debit as total_amt, sum(ifnull(t2.credit, 0)) - sum(ifnull(t2.debit, 0)) as amt_due, t1.remark, t2.against_account, t2.name as voucher_detail_no
gle = webnotes.conn.sql("""
select t1.name as voucher_no, t1.posting_date, t1.total_debit as total_amt,
sum(ifnull(t2.credit, 0)) - sum(ifnull(t2.debit, 0)) as amt_due, t1.remark,
t2.against_account, t2.name as voucher_detail_no
from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
where t1.name = t2.parent
and t1.docstatus = 1
and t2.account = %s
and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')='' and ifnull(t2.against_jv, '')=''
and t2.%s > 0
%s
group by t1.name, t2.name
"""% ('%s', dc, cond), self.doc.account, as_dict=1)
where t1.name = t2.parent and t1.docstatus = 1 and t2.account = %s
and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')=''
and ifnull(t2.against_jv, '')='' and t2.%s > 0 %s group by t1.name, t2.name """ %
('%s', dc, cond), self.doc.account, as_dict=1)
return gle
#--------------------------------------------------
def create_payment_table(self, gle):
for d in gle:
ch = addchild(self.doc, 'ir_payment_details', 'Payment to Invoice Matching Tool Detail', self.doclist)
ch = addchild(self.doc, 'ir_payment_details',
'Payment to Invoice Matching Tool Detail', self.doclist)
ch.voucher_no = d.get('voucher_no')
ch.posting_date = d.get('posting_date')
ch.amt_due = self.acc_type == 'debit' and flt(d.get('amt_due')) or -1*flt(d.get('amt_due'))
ch.amt_due = self.acc_type == 'debit' and flt(d.get('amt_due')) \
or -1*flt(d.get('amt_due'))
ch.total_amt = flt(d.get('total_amt'))
ch.against_account = d.get('against_account')
ch.remarks = d.get('remark')
ch.voucher_detail_no = d.get('voucher_detail_no')
#--------------------------------------------------
def validate_mandatory(self):
if not self.doc.account:
msgprint("Please select Account first", raise_exception=1)
#--------------------------------------------------
def reconcile(self):
"""
Links booking and payment voucher
@@ -122,7 +115,8 @@ class DocType:
2. split into multiple rows if partially adjusted, assign against voucher
3. submit payment voucher
"""
if not self.doc.voucher_no or not sql("select name from `tab%s` where name = %s" %(self.dt[self.doc.voucher_type], '%s'), self.doc.voucher_no):
if not self.doc.voucher_no or not webnotes.conn.sql("""select name from `tab%s`
where name = %s""" % (self.dt[self.doc.voucher_type], '%s'), self.doc.voucher_no):
msgprint("Please select valid Voucher No to proceed", raise_exception=1)
lst = []
@@ -142,7 +136,6 @@ class DocType:
lst.append(args)
if lst:
get_obj('GL Control').reconcile_against_document(lst)
msgprint("Successfully allocated.")

View File

@@ -43,7 +43,6 @@ $.extend(cur_frm.cscript, new_cscript);
cur_frm.cscript.onload = function(doc,dt,dn) {
if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()});
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
}

View File

@@ -31,7 +31,6 @@ wn.require('app/utilities/doctype/sms_control/sms_control.js');
cur_frm.cscript.onload = function(doc,dt,dn) {
if(!doc.customer && doc.debit_to) wn.meta.get_docfield(dt, 'debit_to', dn).print_hide = 0;
if (doc.__islocal) {
//if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()});
if(!doc.due_date) set_multiple(dt,dn,{due_date:get_today()});
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
if(!doc.currency && sys_defaults.currency) set_multiple(dt,dn,{currency:sys_defaults.currency});