mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 20:59:11 +00:00
Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
@@ -307,35 +307,27 @@ cur_frm.cscript['Make Delivery Note'] = function() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.make_bank_voucher = function() {
|
||||||
|
wn.call({
|
||||||
// Make Bank Voucher Button
|
method: "accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",
|
||||||
// -------------------------
|
args: {
|
||||||
cur_frm.cscript.make_bank_voucher = function(doc, dt, dn) {
|
"company": cur_frm.doc.company,
|
||||||
$c('accounts.get_default_bank_account', { company: cur_frm.doc.company }, function(r, rt) {
|
"voucher_type": "Bank Voucher"
|
||||||
if(!r.exc) {
|
},
|
||||||
cur_frm.cscript.make_jv(cur_frm.doc, null, null, r.message);
|
callback: function(r) {
|
||||||
|
cur_frm.cscript.make_jv(cur_frm.doc, null, null, r.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ***************************** Get Query Functions ************************** */
|
|
||||||
|
|
||||||
// Debit To
|
|
||||||
// ---------
|
|
||||||
cur_frm.fields_dict.debit_to.get_query = function(doc) {
|
cur_frm.fields_dict.debit_to.get_query = function(doc) {
|
||||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cash/bank account
|
|
||||||
//------------------
|
|
||||||
cur_frm.fields_dict.cash_bank_account.get_query = function(doc) {
|
cur_frm.fields_dict.cash_bank_account.get_query = function(doc) {
|
||||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write off account
|
|
||||||
//------------------
|
|
||||||
cur_frm.fields_dict.write_off_account.get_query = function(doc) {
|
cur_frm.fields_dict.write_off_account.get_query = function(doc) {
|
||||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "Yes" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "Yes" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||||
}
|
}
|
||||||
@@ -429,17 +421,24 @@ cur_frm.fields_dict.delivery_note_main.get_query = function(doc) {
|
|||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.income_account = function(doc, cdt, cdn){
|
cur_frm.cscript.income_account = function(doc, cdt, cdn){
|
||||||
|
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "income_account");
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.expense_account = function(doc, cdt, cdn){
|
||||||
|
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "expense_account");
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.copy_account_in_all_row = function(doc, cdt, cdn, fieldname) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
if(d.income_account){
|
if(d[fieldname]){
|
||||||
var cl = getchildren('Sales Invoice Item', doc.name, cur_frm.cscript.fname, doc.doctype);
|
var cl = getchildren('Sales Invoice Item', doc.name, cur_frm.cscript.fname, doc.doctype);
|
||||||
for(var i = 0; i < cl.length; i++){
|
for(var i = 0; i < cl.length; i++){
|
||||||
if(!cl[i].income_account) cl[i].income_account = d.income_account;
|
if(!cl[i][fieldname]) cl[i][fieldname] = d[fieldname];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
refresh_field(cur_frm.cscript.fname);
|
refresh_field(cur_frm.cscript.fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.cost_center = function(doc, cdt, cdn){
|
cur_frm.cscript.cost_center = function(doc, cdt, cdn){
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
if(d.cost_center){
|
if(d.cost_center){
|
||||||
@@ -451,10 +450,6 @@ cur_frm.cscript.cost_center = function(doc, cdt, cdn){
|
|||||||
refresh_field(cur_frm.cscript.fname);
|
refresh_field(cur_frm.cscript.fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* **************************************** Utility Functions *************************************** */
|
|
||||||
|
|
||||||
// Details Calculation
|
|
||||||
// --------------------
|
|
||||||
cur_frm.cscript.calc_adjustment_amount = function(doc,cdt,cdn) {
|
cur_frm.cscript.calc_adjustment_amount = function(doc,cdt,cdn) {
|
||||||
var doc = locals[doc.doctype][doc.name];
|
var doc = locals[doc.doctype][doc.name];
|
||||||
var el = getchildren('Sales Invoice Advance',doc.name,'advance_adjustment_details');
|
var el = getchildren('Sales Invoice Advance',doc.name,'advance_adjustment_details');
|
||||||
@@ -488,8 +483,9 @@ cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) {
|
|||||||
|
|
||||||
// credit to bank
|
// credit to bank
|
||||||
var d1 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
|
var d1 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||||
d1.account = bank_account;
|
d1.account = bank_account.account;
|
||||||
d1.debit = doc.outstanding_amount;
|
d1.debit = doc.outstanding_amount;
|
||||||
|
d1.balance = bank_account.balance;
|
||||||
|
|
||||||
loaddoc('Journal Voucher', jv.name);
|
loaddoc('Journal Voucher', jv.name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,13 +318,11 @@ class DocType(SellingController):
|
|||||||
@property
|
@property
|
||||||
def pos_details(self):
|
def pos_details(self):
|
||||||
if not hasattr(self, "_pos_details"):
|
if not hasattr(self, "_pos_details"):
|
||||||
dtl = webnotes.conn.sql("""select income_account, warehouse, cost_center,
|
dtl = webnotes.conn.sql("""select * from `tabPOS Setting` where user = %s
|
||||||
expense_account from `tabPOS Setting` where user = %s and company = %s""",
|
and company = %s""", (webnotes.session['user'], self.doc.company), as_dict=1)
|
||||||
(webnotes.session['user'], self.doc.company), as_dict=1)
|
|
||||||
if not dtl:
|
if not dtl:
|
||||||
dtl = webnotes.conn.sql("""select income_account, warehouse, cost_center,
|
dtl = webnotes.conn.sql("""select * from `tabPOS Setting`
|
||||||
expense_account from `tabPOS Setting` where ifnull(user,'') = ''
|
where ifnull(user,'') = '' and company = %s""", self.doc.company, as_dict=1)
|
||||||
and company = %s""", self.doc.company, as_dict=1)
|
|
||||||
self._pos_details = dtl
|
self._pos_details = dtl
|
||||||
|
|
||||||
return self._pos_details
|
return self._pos_details
|
||||||
|
|||||||
@@ -310,6 +310,17 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.expense_account = function(doc, cdt, cdn){
|
||||||
|
var d = locals[cdt][cdn];
|
||||||
|
if(d.expense_account) {
|
||||||
|
var cl = getchildren('Delivery Note Item', doc.name, cur_frm.cscript.fname, doc.doctype);
|
||||||
|
for(var i = 0; i < cl.length; i++){
|
||||||
|
if(!cl[i].expense_account) cl[i].expense_account = d.expense_account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
refresh_field(cur_frm.cscript.fname);
|
||||||
|
}
|
||||||
|
|
||||||
// expense account
|
// expense account
|
||||||
cur_frm.fields_dict['delivery_note_details'].grid.get_field('expense_account').get_query = function(doc) {
|
cur_frm.fields_dict['delivery_note_details'].grid.get_field('expense_account').get_query = function(doc) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user