mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
[minor] [fix] get queries
This commit is contained in:
@@ -14,9 +14,57 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
wn.provide("erpnext.accounts");
|
||||||
cur_frm.cscript.load_defaults(doc, cdt, cdn);
|
|
||||||
}
|
erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
|
||||||
|
onload: function() {
|
||||||
|
this.load_defaults(this.frm.doc);
|
||||||
|
this.setup_queries();
|
||||||
|
},
|
||||||
|
|
||||||
|
setup_queries: function() {
|
||||||
|
var me = this;
|
||||||
|
|
||||||
|
$.each(["account", "cost_center"], function(i, fieldname) {
|
||||||
|
me.frm.set_query(fieldname, "entries", function() {
|
||||||
|
wn.model.validate_missing(me.frm.doc, "company");
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: me.frm.doc.company,
|
||||||
|
group_or_ledger: "Ledger"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$.each([["against_voucher", "Purchase Invoice", "credit_to"],
|
||||||
|
["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) {
|
||||||
|
me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) {
|
||||||
|
var jvd = wn.model.get_doc(cdt, cdn);
|
||||||
|
wn.model.validate_missing(jvd, "account");
|
||||||
|
return {
|
||||||
|
filters: [
|
||||||
|
[opts[1], opts[2], "=", jvd.account],
|
||||||
|
[opts[1], "docstatus", "=", 1],
|
||||||
|
[opts[1], "outstanding_amount", ">", 0]
|
||||||
|
]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) {
|
||||||
|
var jvd = wn.model.get_doc(cdt, cdn);
|
||||||
|
wn.model.validate_missing(jvd, "account");
|
||||||
|
|
||||||
|
return {
|
||||||
|
query: "accounts.doctype.journal_voucher.journal_voucher.get_against_jv",
|
||||||
|
filters: { account: jvd.account }
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
cur_frm.script_manager.make(erpnext.accounts.JournalVoucher);
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc) {
|
cur_frm.cscript.refresh = function(doc) {
|
||||||
cur_frm.cscript.is_opening(doc)
|
cur_frm.cscript.is_opening(doc)
|
||||||
@@ -34,7 +82,7 @@ cur_frm.cscript.refresh = function(doc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.load_defaults = function(doc, cdt, cdn) {
|
cur_frm.cscript.load_defaults = function(doc) {
|
||||||
if(!cur_frm.doc.__islocal || !cur_frm.doc.company) { return; }
|
if(!cur_frm.doc.__islocal || !cur_frm.doc.company) { return; }
|
||||||
|
|
||||||
doc = locals[doc.doctype][doc.name];
|
doc = locals[doc.doctype][doc.name];
|
||||||
@@ -110,6 +158,7 @@ cur_frm.cscript.get_balance = function(doc,dt,dn) {
|
|||||||
|
|
||||||
cur_frm.cscript.account = function(doc,dt,dn) {
|
cur_frm.cscript.account = function(doc,dt,dn) {
|
||||||
var d = locals[dt][dn];
|
var d = locals[dt][dn];
|
||||||
|
if(d.account) {
|
||||||
wn.call({
|
wn.call({
|
||||||
method: "accounts.utils.get_balance_on",
|
method: "accounts.utils.get_balance_on",
|
||||||
args: {account: d.account, date: doc.posting_date},
|
args: {account: d.account, date: doc.posting_date},
|
||||||
@@ -118,6 +167,7 @@ cur_frm.cscript.account = function(doc,dt,dn) {
|
|||||||
refresh_field('balance', d.name, 'entries');
|
refresh_field('balance', d.name, 'entries');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.validate = function(doc,cdt,cdn) {
|
cur_frm.cscript.validate = function(doc,cdt,cdn) {
|
||||||
@@ -182,59 +232,3 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_query
|
|
||||||
|
|
||||||
cur_frm.fields_dict['entries'].grid.get_field('account').get_query = function(doc) {
|
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
group_or_ledger: "Ledger",
|
|
||||||
company: doc.company
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
|
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
'company': doc.company,
|
|
||||||
'group_or_ledger': 'Ledger'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict['entries'].grid.get_field('against_voucher').get_query = function(doc) {
|
|
||||||
var d = locals[this.doctype][this.docname];
|
|
||||||
return {
|
|
||||||
filters: [
|
|
||||||
['Purchase Invoice', 'credit_to', '=', d.account],
|
|
||||||
['Purchase Invoice', 'docstatus', '=', 1],
|
|
||||||
['Purchase Invoice', 'outstanding_amount', '>', 0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict['entries'].grid.get_field('against_invoice').get_query = function(doc) {
|
|
||||||
var d = locals[this.doctype][this.docname];
|
|
||||||
return {
|
|
||||||
filters: [
|
|
||||||
['Sales Invoice', 'debit_to', '=', d.account],
|
|
||||||
['Sales Invoice', 'docstatus', '=', 1],
|
|
||||||
['Sales Invoice', 'outstanding_amount', '>', 0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict['entries'].grid.get_field('against_jv').get_query = function(doc) {
|
|
||||||
var d = locals[this.doctype][this.docname];
|
|
||||||
|
|
||||||
if(!d.account) {
|
|
||||||
msgprint("Please select Account first!")
|
|
||||||
throw "account not selected"
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
query: "accounts.doctype.journal_voucher.journal_voucher.get_against_jv",
|
|
||||||
filters: { account: d.account }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,6 @@
|
|||||||
version="1.1"
|
version="1.1"
|
||||||
inkscape:version="0.48.2 r9819"
|
inkscape:version="0.48.2 r9819"
|
||||||
sodipodi:docname="splash-mono.svg"
|
sodipodi:docname="splash-mono.svg"
|
||||||
inkscape:export-filename="/Users/anandpdoshi/Dropbox/erpnext/logo 2013/erpnext-logo-2013 other colors 3.png"
|
|
||||||
inkscape:export-xdpi="167.56363"
|
inkscape:export-xdpi="167.56363"
|
||||||
inkscape:export-ydpi="167.56363"
|
inkscape:export-ydpi="167.56363"
|
||||||
viewBox="0 0 680 820"
|
viewBox="0 0 680 820"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.0 KiB |
Reference in New Issue
Block a user