fixed conflict

This commit is contained in:
Nabin Hait
2013-03-25 18:30:15 +05:30
25 changed files with 331 additions and 180 deletions

View File

@@ -1,34 +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.utils import flt
from webnotes.model.code import get_obj
from accounts.utils import get_balance_on
@webnotes.whitelist()
def get_default_bank_account():
"""
Get default bank account for a company
"""
company = webnotes.form_dict.get('company')
if not company: return
res = webnotes.conn.sql("""\
SELECT default_bank_account FROM `tabCompany`
WHERE name=%s AND docstatus<2""", company)
if res: return res[0][0]

View File

@@ -137,23 +137,29 @@ cur_frm.cscript.view_ledger_entry = function(doc,cdt,cdn){
cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
if(doc.voucher_type == 'Bank Voucher' && cstr(doc.company)) {
cur_frm.set_df_property("cheque_no", "reqd", true);
cur_frm.set_df_property("cheque_date", "reqd", true);
var children = getchildren('Journal Voucher Detail', doc.name, 'entries');
if(!children || children.length==0) {
$c('accounts.get_default_bank_account', {company: doc.company }, function(r, rt) {
if(!r.exc) {
var jvd = wn.model.add_child(doc, 'Journal Voucher Detail', 'entries');
jvd.account = cstr(r.message);
refresh_field('entries');
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");
if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)
&& doc.company
&& wn.model.get("Journal Voucher Detail", {"parent":doc.name}).length==0) {
wn.call({
type: "GET",
method: "accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",
args: {
"voucher_type": doc.voucher_type,
"company": doc.company
},
callback: function(r) {
if(r.message) {
var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries");
jvdetail.account = r.message.account;
// this is a data field????
jvdetail.balance = format_currency(r.message.balance);
refresh_field("entries");
}
});
}
} else {
cur_frm.set_df_property("cheque_no", "reqd", false);
cur_frm.set_df_property("cheque_date", "reqd", false);
}
})
}
}

View File

@@ -67,6 +67,11 @@ class DocType(AccountsController):
remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_jv")
self.make_gl_entries(cancel=1)
def on_trash(self):
pass
#if self.doc.amended_from:
# webnotes.delete_doc("Journal Voucher", self.doc.amended_from)
def validate_debit_credit(self):
for d in getlist(self.doclist, 'entries'):
@@ -344,6 +349,16 @@ class DocType(AccountsController):
from `tabPurchase Invoice` where docstatus = 1 and company = %s
and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company)
@webnotes.whitelist()
def get_default_bank_cash_account(company, voucher_type):
from accounts.utils import get_balance_on
account = webnotes.conn.get_value("Company", company,
voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account")
if account:
return {
"account": account,
"balance": get_balance_on(account)
}
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

View File

@@ -639,22 +639,23 @@ class DocType(SellingController):
def make_sl_entry(self, d, wh, qty, in_value, update_stock):
st_uom = webnotes.conn.sql("select stock_uom from `tabItem` where name = '%s'"%d['item_code'])
self.values.append({
'item_code' : d['item_code'],
'warehouse' : wh,
'transaction_date' : getdate(self.doc.modified).strftime('%Y-%m-%d'),
'posting_date' : self.doc.posting_date,
'posting_time' : self.doc.posting_time,
'voucher_type' : 'Sales Invoice',
'voucher_no' : cstr(self.doc.name),
'voucher_detail_no' : cstr(d['name']),
'actual_qty' : qty,
'stock_uom' : st_uom and st_uom[0][0] or '',
'incoming_rate' : in_value,
'company' : self.doc.company,
'fiscal_year' : self.doc.fiscal_year,
'is_cancelled' : (update_stock==1) and 'No' or 'Yes',
'batch_no' : cstr(d['batch_no']),
'serial_no' : d['serial_no']
'item_code' : d['item_code'],
'warehouse' : wh,
'transaction_date' : getdate(self.doc.modified).strftime('%Y-%m-%d'),
'posting_date' : self.doc.posting_date,
'posting_time' : self.doc.posting_time,
'voucher_type' : 'Sales Invoice',
'voucher_no' : cstr(self.doc.name),
'voucher_detail_no' : cstr(d['name']),
'actual_qty' : qty,
'stock_uom' : st_uom and st_uom[0][0] or '',
'incoming_rate' : in_value,
'company' : self.doc.company,
'fiscal_year' : self.doc.fiscal_year,
'is_cancelled' : (update_stock==1) and 'No' or 'Yes',
'batch_no' : cstr(d['batch_no']),
'serial_no' : d['serial_no'],
"project" : self.doc.project_name
})
def update_stock_ledger(self, update_stock):

View File

@@ -39,6 +39,16 @@ wn.module_page["Accounts"] = [
description: wn._("Structure cost centers for budgeting."),
doctype:"Cost Center"
},
{
label: wn._("Customer"),
description: wn._("Customer database."),
doctype:"Customer"
},
{
label: wn._("Supplier"),
description: wn._("Supplier database."),
doctype:"Supplier"
},
]
},
{