Compare commits
238 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bfa8d560b | ||
|
|
96db41d996 | ||
|
|
9a74330d6f | ||
|
|
1951baca57 | ||
|
|
da08124df2 | ||
|
|
2aecc5a717 | ||
|
|
bc99c9d6e0 | ||
|
|
f32314dd0b | ||
|
|
7e73f35916 | ||
|
|
e1e63a91d6 | ||
|
|
9a05aad8ea | ||
|
|
f6b77479d7 | ||
|
|
3c279163fc | ||
|
|
6933617538 | ||
|
|
2648661757 | ||
|
|
e31a97f355 | ||
|
|
6bdb73c392 | ||
|
|
deda7e2c75 | ||
|
|
5cdb8cea13 | ||
|
|
90a8c9e636 | ||
|
|
c0c951b6a9 | ||
|
|
39eb7faeb9 | ||
|
|
4829ad3eb8 | ||
|
|
a682d45846 | ||
|
|
76dd468f0e | ||
|
|
a6df26839d | ||
|
|
c5d4fc38aa | ||
|
|
02f7e83bd1 | ||
|
|
f55d9414cd | ||
|
|
5644ed37a4 | ||
|
|
ee6200576a | ||
|
|
eeb8ba18cd | ||
|
|
3a19370892 | ||
|
|
6dc1ba6f7f | ||
|
|
d91af2853e | ||
|
|
d23ae108ae | ||
|
|
72f8ae2d5a | ||
|
|
1e347910d5 | ||
|
|
25cfb700bb | ||
|
|
8d2d4e82fd | ||
|
|
c43d58ac79 | ||
|
|
0b3c10601c | ||
|
|
14bf711d04 | ||
|
|
35a9d585b4 | ||
|
|
38e56eeb45 | ||
|
|
3dd1043d5e | ||
|
|
55387aa931 | ||
|
|
03463ef73b | ||
|
|
371663169c | ||
|
|
f3ded044e0 | ||
|
|
68b0d54b4b | ||
|
|
e4a71935eb | ||
|
|
3e846d19d4 | ||
|
|
5411ece766 | ||
|
|
aeb68b2899 | ||
|
|
0064dc6f4a | ||
|
|
11bf06ad76 | ||
|
|
5c6a2acff7 | ||
|
|
cdbd4218a8 | ||
|
|
701cddfb15 | ||
|
|
4bbf91bea1 | ||
|
|
e481e81e67 | ||
|
|
102b417b52 | ||
|
|
efc2a45835 | ||
|
|
5c119a7e95 | ||
|
|
f7a102ffe3 | ||
|
|
d659343541 | ||
|
|
dbf5e54eab | ||
|
|
5eb139a531 | ||
|
|
9e2358c544 | ||
|
|
8d0ef21911 | ||
|
|
9a8f37c579 | ||
|
|
029f698c65 | ||
|
|
806017c92a | ||
|
|
69951e5d1c | ||
|
|
10fd91c78e | ||
|
|
63d71d7f2f | ||
|
|
777bff6e8d | ||
|
|
1e42a3d028 | ||
|
|
da282d405f | ||
|
|
8f1bb82ab9 | ||
|
|
f2b46635b5 | ||
|
|
a11e14424c | ||
|
|
01441ef37f | ||
|
|
cb665285db | ||
|
|
6b66c387ad | ||
|
|
5e702de710 | ||
|
|
7e79f300a1 | ||
|
|
955902ccad | ||
|
|
b882fa14f4 | ||
|
|
d12d7142c6 | ||
|
|
42db5d76a9 | ||
|
|
bd4030bf85 | ||
|
|
a83337a2dd | ||
|
|
e51e5238ec | ||
|
|
5d5fe5d9d5 | ||
|
|
b476c989a4 | ||
|
|
7f0406f281 | ||
|
|
33f6b9d6e8 | ||
|
|
c196037cb0 | ||
|
|
866103bf66 | ||
|
|
528eb4e4ff | ||
|
|
481454298d | ||
|
|
8a0b7cece1 | ||
|
|
b4eba77f7b | ||
|
|
b0a9581e59 | ||
|
|
6472bdace2 | ||
|
|
c95b9f9221 | ||
|
|
a4db83a934 | ||
|
|
28acaeb345 | ||
|
|
5fbb757c2c | ||
|
|
df07c964f7 | ||
|
|
0e2a088ac4 | ||
|
|
ffc2f8885b | ||
|
|
a1ffacaf0b | ||
|
|
8c52258e6d | ||
|
|
ffe8af3f2f | ||
|
|
fe5728718f | ||
|
|
424b4a4b36 | ||
|
|
2a3d7e660f | ||
|
|
a0a43ca4e4 | ||
|
|
9cd9836e18 | ||
|
|
39a3f50732 | ||
|
|
ba7221c332 | ||
|
|
6a45588a2c | ||
|
|
ab9d755e4d | ||
|
|
1cf8bd8767 | ||
|
|
a4f99428d7 | ||
|
|
e761fe89e2 | ||
|
|
d51f805b78 | ||
|
|
9a064e9ced | ||
|
|
9dc1b00d87 | ||
|
|
9373ba96d5 | ||
|
|
a402079cd4 | ||
|
|
2ca388b0a5 | ||
|
|
6ebcc5c006 | ||
|
|
6a2edee914 | ||
|
|
de69ad0a48 | ||
|
|
25a4bd02f4 | ||
|
|
a3d058938e | ||
|
|
4cae8a0d54 | ||
|
|
454b6f9f8a | ||
|
|
9f1b59dfc6 | ||
|
|
74f64b67db | ||
|
|
2117afba07 | ||
|
|
e409d0d70b | ||
|
|
50125b35d2 | ||
|
|
c38527ef5f | ||
|
|
facde47c6c | ||
|
|
20dc79ac99 | ||
|
|
61da43f793 | ||
|
|
af30c3fdfd | ||
|
|
68888a21ec | ||
|
|
7d7661c9ed | ||
|
|
fbda00eef0 | ||
|
|
a0212d8014 | ||
|
|
c8d2604afc | ||
|
|
861453279d | ||
|
|
be96600c1c | ||
|
|
8709c51e84 | ||
|
|
6fc0262cb6 | ||
|
|
4b5ced03ec | ||
|
|
a888e29b0a | ||
|
|
ae2e8996b0 | ||
|
|
1c2bbd77a0 | ||
|
|
2ffba327ac | ||
|
|
4764f3ea1d | ||
|
|
104deeebb5 | ||
|
|
2a9e4e9a32 | ||
|
|
a38a7b8e76 | ||
|
|
88eedb7397 | ||
|
|
605cc93c90 | ||
|
|
1644fce273 | ||
|
|
8cc2bf7fcf | ||
|
|
fe6409debf | ||
|
|
edc58619d1 | ||
|
|
85800fa929 | ||
|
|
60ec0128a2 | ||
|
|
90e0700e24 | ||
|
|
48156e3d8b | ||
|
|
8b353e5e15 | ||
|
|
fcbd4d7638 | ||
|
|
9409efe02a | ||
|
|
b645a217fd | ||
|
|
ef295d2977 | ||
|
|
2d0e31b479 | ||
|
|
2678ed181a | ||
|
|
1fce0b1f79 | ||
|
|
649660d9f0 | ||
|
|
797e0713ea | ||
|
|
6a0ffabbd0 | ||
|
|
56f58cfa68 | ||
|
|
677ef0c3cf | ||
|
|
64367a905a | ||
|
|
c565de2c12 | ||
|
|
908f2dc0fd | ||
|
|
0b1a8e13fd | ||
|
|
a1ae0270e3 | ||
|
|
4d806c5fcb | ||
|
|
cf6e13d2fe | ||
|
|
ceb940ec17 | ||
|
|
a4080eb840 | ||
|
|
90f33c3249 | ||
|
|
592d27e7f1 | ||
|
|
8b7da55617 | ||
|
|
57e89ff6f1 | ||
|
|
8a98fc7e79 | ||
|
|
d94bab0e1d | ||
|
|
9d6e10c910 | ||
|
|
9ee20e8f5a | ||
|
|
3ddd0d89df | ||
|
|
60ec93811e | ||
|
|
dbb69dacff | ||
|
|
9ff9dafd00 | ||
|
|
ea4f66791e | ||
|
|
b0636edaf7 | ||
|
|
c55b55d959 | ||
|
|
585e936263 | ||
|
|
42c7c5b547 | ||
|
|
ba31ecc611 | ||
|
|
2d46d3cd04 | ||
|
|
1d361cf26c | ||
|
|
45a35ced33 | ||
|
|
fe5dcd49ae | ||
|
|
70cd146bb5 | ||
|
|
64c512dd61 | ||
|
|
4a8930fc67 | ||
|
|
c313ca99ff | ||
|
|
86da17d5d9 | ||
|
|
ce2dfadfbd | ||
|
|
01d2811ccd | ||
|
|
690c75fa0d | ||
|
|
462401c4df | ||
|
|
1b5de63163 | ||
|
|
9b0a6d426c | ||
|
|
bc6df5c71b | ||
|
|
47e40242bd | ||
|
|
7eb90d3d5c |
File diff suppressed because one or more lines are too long
@@ -95,9 +95,10 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
||||
wn.route_options = {
|
||||
"account": doc.name,
|
||||
"from_date": sys_defaults.year_start_date,
|
||||
"to_date": sys_defaults.year_end_date
|
||||
"to_date": sys_defaults.year_end_date,
|
||||
"company": doc.company
|
||||
};
|
||||
wn.set_route("general-ledger");
|
||||
wn.set_route("query-report", "General Ledger");
|
||||
}, "icon-table");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,6 +211,9 @@ class DocType:
|
||||
|
||||
# Validate properties before merging
|
||||
if merge:
|
||||
if not webnotes.conn.exists("Account", new):
|
||||
webnotes.throw(_("Account ") + new +_(" does not exists"))
|
||||
|
||||
val = list(webnotes.conn.get_value("Account", new_account,
|
||||
["group_or_ledger", "debit_or_credit", "is_pl_account"]))
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cint, cstr
|
||||
from webnotes import msgprint, _
|
||||
from webnotes import _
|
||||
from webnotes.utils import cint
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
@@ -15,7 +15,17 @@ class DocType:
|
||||
def on_update(self):
|
||||
webnotes.conn.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock)
|
||||
|
||||
if self.doc.auto_accounting_for_stock:
|
||||
for wh in webnotes.conn.sql("select name from `tabWarehouse`"):
|
||||
wh_bean = webnotes.bean("Warehouse", wh[0])
|
||||
if cint(self.doc.auto_accounting_for_stock):
|
||||
# set default perpetual account in company
|
||||
for company in webnotes.conn.sql("select name from tabCompany"):
|
||||
webnotes.bean("Company", company[0]).save()
|
||||
|
||||
# Create account head for warehouses
|
||||
warehouse_list = webnotes.conn.sql("select name, company from tabWarehouse", as_dict=1)
|
||||
warehouse_with_no_company = [d.name for d in warehouse_list if not d.company]
|
||||
if warehouse_with_no_company:
|
||||
webnotes.throw(_("Company is missing in following warehouses") + ": \n" +
|
||||
"\n".join(warehouse_with_no_company))
|
||||
for wh in warehouse_list:
|
||||
wh_bean = webnotes.bean("Warehouse", wh.name)
|
||||
wh_bean.save()
|
||||
@@ -146,11 +146,12 @@ def update_outstanding_amt(account, against_voucher_type, against_voucher, on_ca
|
||||
webnotes.conn.sql("update `tab%s` set outstanding_amount=%s where name='%s'" %
|
||||
(against_voucher_type, bal, against_voucher))
|
||||
|
||||
def validate_frozen_account(account, adv_adj):
|
||||
def validate_frozen_account(account, adv_adj=None):
|
||||
frozen_account = webnotes.conn.get_value("Account", account, "freeze_account")
|
||||
if frozen_account == 'Yes' and not adv_adj:
|
||||
frozen_accounts_modifier = webnotes.conn.get_value( 'Accounts Settings', None,
|
||||
'frozen_accounts_modifier')
|
||||
|
||||
if not frozen_accounts_modifier:
|
||||
webnotes.throw(account + _(" is a frozen account. \
|
||||
Either make the account active or assign role in Accounts Settings \
|
||||
|
||||
@@ -120,8 +120,10 @@ cur_frm.cscript.refresh = function(doc) {
|
||||
"voucher_no": doc.name,
|
||||
"from_date": doc.posting_date,
|
||||
"to_date": doc.posting_date,
|
||||
"company": doc.company,
|
||||
group_by_voucher: 0
|
||||
};
|
||||
wn.set_route("general-ledger");
|
||||
wn.set_route("query-report", "General Ledger");
|
||||
}, "icon-table");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,13 +140,13 @@ def gl_entry_details(doctype, txt, searchfield, start, page_len, filters):
|
||||
and ifnull(gle.%(account_type)s, 0) > 0
|
||||
and (select ifnull(abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))), 0)
|
||||
from `tabGL Entry`
|
||||
where against_voucher_type = '%(dt)s'
|
||||
where account = '%(acc)s'
|
||||
and against_voucher_type = '%(dt)s'
|
||||
and against_voucher = gle.voucher_no
|
||||
and voucher_no != gle.voucher_no)
|
||||
!= abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0)
|
||||
)
|
||||
and if(gle.voucher_type='Sales Invoice', (select is_pos from `tabSales Invoice`
|
||||
where name=gle.voucher_no), 0)=0
|
||||
!= abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0))
|
||||
and if(gle.voucher_type='Sales Invoice', ifnull((select is_pos from `tabSales Invoice`
|
||||
where name=gle.voucher_no), 0), 0)=0
|
||||
%(mcond)s
|
||||
ORDER BY gle.posting_date desc, gle.voucher_no desc
|
||||
limit %(start)s, %(page_len)s""" % {
|
||||
|
||||
@@ -7,7 +7,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
});
|
||||
|
||||
cur_frm.set_query("selling_price_list", function() {
|
||||
return { filters: { buying_or_selling: "Selling" } };
|
||||
return { filters: { selling: 1 } };
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 12:15:51",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-02 16:58:38",
|
||||
"modified": "2014-01-15 16:23:58",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -154,7 +154,7 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:sys_defaults.auto_accounting_for_stock",
|
||||
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "expense_account",
|
||||
"fieldtype": "Link",
|
||||
|
||||
@@ -35,8 +35,10 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||
"voucher_no": doc.name,
|
||||
"from_date": doc.posting_date,
|
||||
"to_date": doc.posting_date,
|
||||
"company": doc.company,
|
||||
group_by_voucher: 0
|
||||
};
|
||||
wn.set_route("general-ledger");
|
||||
wn.set_route("query-report", "General Ledger");
|
||||
}, "icon-table");
|
||||
}
|
||||
|
||||
|
||||
@@ -302,6 +302,7 @@ class DocType(BuyingController):
|
||||
self.make_gl_entries()
|
||||
self.update_against_document_in_jv()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||
|
||||
def make_gl_entries(self):
|
||||
auto_accounting_for_stock = \
|
||||
@@ -350,7 +351,6 @@ class DocType(BuyingController):
|
||||
# item gl entries
|
||||
stock_item_and_auto_accounting_for_stock = False
|
||||
stock_items = self.get_stock_items()
|
||||
rounding_diff = 0.0
|
||||
for item in self.doclist.get({"parentfield": "entries"}):
|
||||
if auto_accounting_for_stock and item.item_code in stock_items:
|
||||
if flt(item.valuation_rate):
|
||||
@@ -359,13 +359,8 @@ class DocType(BuyingController):
|
||||
# expense will be booked in sales invoice
|
||||
stock_item_and_auto_accounting_for_stock = True
|
||||
|
||||
valuation_amt = flt(flt(item.valuation_rate) * flt(item.qty) * \
|
||||
flt(item.conversion_factor), self.precision("valuation_rate", item))
|
||||
|
||||
rounding_diff += (flt(item.amount, self.precision("amount", item)) +
|
||||
flt(item.item_tax_amount, self.precision("item_tax_amount", item)) +
|
||||
flt(item.rm_supp_cost, self.precision("rm_supp_cost", item)) -
|
||||
valuation_amt)
|
||||
valuation_amt = flt(item.amount + item.item_tax_amount + item.rm_supp_cost,
|
||||
self.precision("amount", item))
|
||||
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
@@ -393,12 +388,6 @@ class DocType(BuyingController):
|
||||
# this will balance out valuation amount included in cost of goods sold
|
||||
expenses_included_in_valuation = \
|
||||
self.get_company_default("expenses_included_in_valuation")
|
||||
|
||||
if rounding_diff:
|
||||
import operator
|
||||
cost_center_with_max_value = max(valuation_tax.iteritems(),
|
||||
key=operator.itemgetter(1))[0]
|
||||
valuation_tax[cost_center_with_max_value] -= flt(rounding_diff)
|
||||
|
||||
for cost_center, amount in valuation_tax.items():
|
||||
gl_entries.append(
|
||||
@@ -433,7 +422,7 @@ class DocType(BuyingController):
|
||||
remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_voucher")
|
||||
|
||||
self.update_prevdoc_status()
|
||||
|
||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||
self.make_cancel_gl_entries()
|
||||
|
||||
def on_update(self):
|
||||
|
||||
@@ -19,8 +19,10 @@ erpnext.POS = Class.extend({
|
||||
<table class="table table-condensed table-hover" id="cart" style="table-layout: fixed;">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th style="width: 50%">Item</th>\
|
||||
<th style="width: 25%; text-align: right;">Qty</th>\
|
||||
<th style="width: 40%">Item</th>\
|
||||
<th style="width: 9%"></th>\
|
||||
<th style="width: 17%; text-align: right;">Qty</th>\
|
||||
<th style="width: 9%"></th>\
|
||||
<th style="width: 25%; text-align: right;">Rate</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
@@ -60,10 +62,16 @@ erpnext.POS = Class.extend({
|
||||
</div>\
|
||||
</div>\
|
||||
<br><br>\
|
||||
<button class="btn btn-success btn-lg make-payment">\
|
||||
<i class="icon-money"></i> Make Payment</button>\
|
||||
<button class="btn btn-default btn-lg delete-items pull-right" style="display: none;">\
|
||||
<i class="icon-trash"></i> Del</button>\
|
||||
<div class="row">\
|
||||
<div class="col-sm-9">\
|
||||
<button class="btn btn-success btn-lg make-payment">\
|
||||
<i class="icon-money"></i> Make Payment</button>\
|
||||
</div>\
|
||||
<div class="col-sm-3">\
|
||||
<button class="btn btn-default btn-lg remove-items" style="display: none;">\
|
||||
<i class="icon-trash"></i> Del</button>\
|
||||
</div>\
|
||||
</div>\
|
||||
<br><br>\
|
||||
</div>\
|
||||
<div class="col-sm-6">\
|
||||
@@ -82,7 +90,7 @@ erpnext.POS = Class.extend({
|
||||
me.refresh();
|
||||
});
|
||||
|
||||
this.call_function("delete-items", function() {me.remove_selected_item();});
|
||||
this.call_function("remove-items", function() {me.remove_selected_items();});
|
||||
this.call_function("make-payment", function() {me.make_payment();});
|
||||
},
|
||||
check_transaction_type: function() {
|
||||
@@ -333,7 +341,7 @@ erpnext.POS = Class.extend({
|
||||
}
|
||||
|
||||
this.disable_text_box_and_button();
|
||||
this.make_payment_button();
|
||||
this.hide_payment_button();
|
||||
|
||||
// If quotation to is not Customer then remove party
|
||||
if (this.frm.doctype == "Quotation") {
|
||||
@@ -351,8 +359,18 @@ erpnext.POS = Class.extend({
|
||||
|
||||
$(repl('<tr id="%(item_code)s" data-selected="false">\
|
||||
<td>%(item_code)s%(item_name)s</td>\
|
||||
<td><input type="text" value="%(qty)s" \
|
||||
<td style="vertical-align:middle;" align="right">\
|
||||
<div class="decrease-qty" style="cursor:pointer;">\
|
||||
<i class="icon-minus-sign icon-large text-danger"></i>\
|
||||
</div>\
|
||||
</td>\
|
||||
<td style="vertical-align:middle;"><input type="text" value="%(qty)s" \
|
||||
class="form-control qty" style="text-align: right;"></td>\
|
||||
<td style="vertical-align:middle;cursor:pointer;">\
|
||||
<div class="increase-qty" style="cursor:pointer;">\
|
||||
<i class="icon-plus-sign icon-large text-success"></i>\
|
||||
</div>\
|
||||
</td>\
|
||||
<td style="text-align: right;"><b>%(amount)s</b><br>%(rate)s</td>\
|
||||
</tr>',
|
||||
{
|
||||
@@ -364,27 +382,32 @@ erpnext.POS = Class.extend({
|
||||
}
|
||||
)).appendTo($items);
|
||||
});
|
||||
|
||||
this.wrapper.find(".increase-qty, .decrease-qty").on("click", function() {
|
||||
var item_code = $(this).closest("tr").attr("id");
|
||||
me.selected_item_qty_operation(item_code, $(this).attr("class"));
|
||||
});
|
||||
},
|
||||
show_taxes: function() {
|
||||
var me = this;
|
||||
var taxes = wn.model.get_children(this.sales_or_purchase + " Taxes and Charges",
|
||||
this.frm.doc.name, this.frm.cscript.other_fname, this.frm.doctype);
|
||||
$(this.wrapper).find(".tax-table")
|
||||
.toggle((taxes && taxes.length &&
|
||||
flt(me.frm.doc.other_charges_total_export ||
|
||||
me.frm.doc.other_charges_added_import) != 0.0) ? true : false)
|
||||
.toggle((taxes && taxes.length) ? true : false)
|
||||
.find("tbody").empty();
|
||||
|
||||
$.each(taxes, function(i, d) {
|
||||
$(repl('<tr>\
|
||||
<td>%(description)s %(rate)s</td>\
|
||||
<td style="text-align: right;">%(tax_amount)s</td>\
|
||||
<tr>', {
|
||||
description: d.description,
|
||||
rate: ((d.charge_type == "Actual") ? '' : ("(" + d.rate + "%)")),
|
||||
tax_amount: format_currency(flt(d.tax_amount)/flt(me.frm.doc.conversion_rate),
|
||||
me.frm.doc.currency)
|
||||
})).appendTo(".tax-table tbody");
|
||||
if (d.tax_amount) {
|
||||
$(repl('<tr>\
|
||||
<td>%(description)s %(rate)s</td>\
|
||||
<td style="text-align: right;">%(tax_amount)s</td>\
|
||||
<tr>', {
|
||||
description: d.description,
|
||||
rate: ((d.charge_type == "Actual") ? '' : ("(" + d.rate + "%)")),
|
||||
tax_amount: format_currency(flt(d.tax_amount)/flt(me.frm.doc.conversion_rate),
|
||||
me.frm.doc.currency)
|
||||
})).appendTo(".tax-table tbody");
|
||||
}
|
||||
});
|
||||
},
|
||||
set_totals: function() {
|
||||
@@ -427,7 +450,7 @@ erpnext.POS = Class.extend({
|
||||
$(this.wrapper).find('input, button').each(function () {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
$(this.wrapper).find(".delete-items").hide();
|
||||
$(this.wrapper).find(".remove-items").hide();
|
||||
$(this.wrapper).find(".make-payment").hide();
|
||||
}
|
||||
else {
|
||||
@@ -437,14 +460,14 @@ erpnext.POS = Class.extend({
|
||||
$(this.wrapper).find(".make-payment").show();
|
||||
}
|
||||
},
|
||||
make_payment_button: function() {
|
||||
hide_payment_button: function() {
|
||||
var me = this;
|
||||
// Show Make Payment button only in Sales Invoice
|
||||
if (this.frm.doctype != "Sales Invoice")
|
||||
$(this.wrapper).find(".make-payment").hide();
|
||||
},
|
||||
refresh_delete_btn: function() {
|
||||
$(this.wrapper).find(".delete-items").toggle($(".item-cart .warning").length ? true : false);
|
||||
$(this.wrapper).find(".remove-items").toggle($(".item-cart .warning").length ? true : false);
|
||||
},
|
||||
add_item_thru_barcode: function() {
|
||||
var me = this;
|
||||
@@ -466,7 +489,7 @@ erpnext.POS = Class.extend({
|
||||
}
|
||||
});
|
||||
},
|
||||
remove_selected_item: function() {
|
||||
remove_selected_items: function() {
|
||||
var me = this;
|
||||
var selected_items = [];
|
||||
var no_of_items = $(this.wrapper).find("#cart tbody tr").length;
|
||||
@@ -487,6 +510,7 @@ erpnext.POS = Class.extend({
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.refresh_grid();
|
||||
},
|
||||
refresh_grid: function() {
|
||||
@@ -494,6 +518,22 @@ erpnext.POS = Class.extend({
|
||||
this.frm.script_manager.trigger("calculate_taxes_and_totals");
|
||||
this.refresh();
|
||||
},
|
||||
selected_item_qty_operation: function(item_code, operation) {
|
||||
var me = this;
|
||||
var child = wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
|
||||
this.frm.cscript.fname, this.frm.doctype);
|
||||
|
||||
$.each(child, function(i, d) {
|
||||
if (d.item_code == item_code) {
|
||||
if (operation == "increase-qty")
|
||||
d.qty += 1;
|
||||
else if (operation == "decrease-qty")
|
||||
d.qty != 1 ? d.qty -= 1 : d.qty = 1;
|
||||
|
||||
me.refresh();
|
||||
}
|
||||
});
|
||||
},
|
||||
make_payment: function() {
|
||||
var me = this;
|
||||
var no_of_items = $(this.wrapper).find("#cart tbody tr").length;
|
||||
|
||||
@@ -54,8 +54,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
"voucher_no": doc.name,
|
||||
"from_date": doc.posting_date,
|
||||
"to_date": doc.posting_date,
|
||||
"company": doc.company,
|
||||
group_by_voucher: 0
|
||||
};
|
||||
wn.set_route("general-ledger");
|
||||
wn.set_route("query-report", "General Ledger");
|
||||
}, "icon-table");
|
||||
|
||||
var percent_paid = cint(flt(doc.grand_total - doc.outstanding_amount) / flt(doc.grand_total) * 100);
|
||||
|
||||
@@ -88,6 +88,7 @@ class DocType(SellingController):
|
||||
|
||||
self.update_status_updater_args()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
|
||||
|
||||
# this sequence because outstanding may get -ve
|
||||
self.make_gl_entries()
|
||||
@@ -114,6 +115,7 @@ class DocType(SellingController):
|
||||
|
||||
self.update_status_updater_args()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
|
||||
|
||||
self.make_cancel_gl_entries()
|
||||
|
||||
@@ -399,9 +401,10 @@ class DocType(SellingController):
|
||||
if not self.doc.cash_bank_account and flt(self.doc.paid_amount):
|
||||
msgprint("Cash/Bank Account is mandatory for POS, for making payment entry")
|
||||
raise Exception
|
||||
if (flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) - round(flt(self.doc.grand_total), 2))>0.001:
|
||||
msgprint("(Paid amount + Write Off Amount) can not be greater than Grand Total")
|
||||
raise Exception
|
||||
if flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) \
|
||||
- flt(self.doc.grand_total) > 1/(10**(self.precision("grand_total") + 1)):
|
||||
webnotes.throw(_("""(Paid amount + Write Off Amount) can not be \
|
||||
greater than Grand Total"""))
|
||||
|
||||
|
||||
def validate_item_code(self):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:05",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-18 15:16:50",
|
||||
"modified": "2014-01-16 15:36:16",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -1091,7 +1091,7 @@
|
||||
"fieldtype": "Select",
|
||||
"label": "Recurring Type",
|
||||
"no_copy": 1,
|
||||
"options": "Monthly\nQuarterly\nHalf-yearly\nYearly",
|
||||
"options": "\nMonthly\nQuarterly\nHalf-yearly\nYearly",
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
|
||||
@@ -364,7 +364,6 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||
order by account asc, debit asc""", si.doc.name, as_dict=1)
|
||||
self.assertTrue(gl_entries)
|
||||
# print gl_entries
|
||||
|
||||
stock_in_hand = webnotes.conn.get_value("Account", {"master_name": "_Test Warehouse - _TC"})
|
||||
|
||||
@@ -566,16 +565,17 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
where against_invoice=%s""", si.doc.name))
|
||||
|
||||
def test_recurring_invoice(self):
|
||||
from webnotes.utils import now_datetime, get_first_day, get_last_day, add_to_date
|
||||
today = now_datetime().date()
|
||||
|
||||
from webnotes.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate
|
||||
from accounts.utils import get_fiscal_year
|
||||
today = nowdate()
|
||||
base_si = webnotes.bean(copy=test_records[0])
|
||||
base_si.doc.fields.update({
|
||||
"convert_into_recurring_invoice": 1,
|
||||
"recurring_type": "Monthly",
|
||||
"notification_email_address": "test@example.com, test1@example.com, test2@example.com",
|
||||
"repeat_on_day_of_month": today.day,
|
||||
"repeat_on_day_of_month": getdate(today).day,
|
||||
"posting_date": today,
|
||||
"fiscal_year": get_fiscal_year(today)[0],
|
||||
"invoice_period_from_date": get_first_day(today),
|
||||
"invoice_period_to_date": get_last_day(today)
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-04-24 11:39:32",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:21",
|
||||
"modified": "2013-12-17 12:38:08",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -37,11 +37,20 @@
|
||||
"options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "row_id",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"label": "Enter Row",
|
||||
"oldfieldname": "row_id",
|
||||
"oldfieldtype": "Data"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "account_head",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Account Head",
|
||||
"oldfieldname": "account_head",
|
||||
"oldfieldtype": "Link",
|
||||
@@ -54,7 +63,7 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cost_center",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Cost Center",
|
||||
"oldfieldname": "cost_center_other_charges",
|
||||
"oldfieldtype": "Link",
|
||||
@@ -72,6 +81,24 @@
|
||||
"reqd": 1,
|
||||
"width": "300px"
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "included_in_print_rate",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is this Tax included in Basic Rate?",
|
||||
"no_copy": 0,
|
||||
"print_hide": 1,
|
||||
"print_width": "150px",
|
||||
"report_hide": 1,
|
||||
"width": "150px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_6",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "rate",
|
||||
@@ -80,7 +107,7 @@
|
||||
"label": "Rate",
|
||||
"oldfieldname": "rate",
|
||||
"oldfieldtype": "Currency",
|
||||
"reqd": 0
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -104,15 +131,6 @@
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "row_id",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"label": "Enter Row",
|
||||
"oldfieldname": "row_id",
|
||||
"oldfieldtype": "Data"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_wise_tax_detail",
|
||||
@@ -134,18 +152,5 @@
|
||||
"oldfieldtype": "Data",
|
||||
"print_hide": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "included_in_print_rate",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is this Tax included in Basic Rate?",
|
||||
"no_copy": 0,
|
||||
"print_hide": 1,
|
||||
"print_width": "150px",
|
||||
"report_hide": 1,
|
||||
"width": "150px"
|
||||
}
|
||||
]
|
||||
@@ -24,10 +24,6 @@ def process_gl_map(gl_map, merge_entries=True):
|
||||
gl_map = merge_similar_entries(gl_map)
|
||||
|
||||
for entry in gl_map:
|
||||
# round off upto 2 decimal
|
||||
entry.debit = flt(entry.debit, 2)
|
||||
entry.credit = flt(entry.credit, 2)
|
||||
|
||||
# toggle debit, credit if negative entry
|
||||
if flt(entry.debit) < 0:
|
||||
entry.credit = flt(entry.credit) - flt(entry.debit)
|
||||
@@ -49,7 +45,7 @@ def merge_similar_entries(gl_map):
|
||||
same_head.credit = flt(same_head.credit) + flt(entry.credit)
|
||||
else:
|
||||
merged_gl_map.append(entry)
|
||||
|
||||
|
||||
# filter zero debit and credit entries
|
||||
merged_gl_map = filter(lambda x: flt(x.debit)!=0 or flt(x.credit)!=0, merged_gl_map)
|
||||
return merged_gl_map
|
||||
|
||||
@@ -175,9 +175,10 @@ erpnext.AccountsChart = Class.extend({
|
||||
wn.route_options = {
|
||||
"account": node.data('label'),
|
||||
"from_date": sys_defaults.year_start_date,
|
||||
"to_date": sys_defaults.year_end_date
|
||||
"to_date": sys_defaults.year_end_date,
|
||||
"company": me.company
|
||||
};
|
||||
wn.set_route("general-ledger");
|
||||
wn.set_route("query-report", "General Ledger");
|
||||
},
|
||||
rename: function() {
|
||||
var node = this.selected_node();
|
||||
|
||||
@@ -157,7 +157,8 @@ wn.module_page["Accounts"] = [
|
||||
items: [
|
||||
{
|
||||
"label":wn._("General Ledger"),
|
||||
page: "general-ledger"
|
||||
doctype: "GL Entry",
|
||||
route: "query-report/General Ledger"
|
||||
},
|
||||
{
|
||||
"label":wn._("Trial Balance"),
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
General Ledger report (for all transactions and accounts).
|
||||
@@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -1,396 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.pages['general-ledger'].onload = function(wrapper) {
|
||||
wn.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: wn._('General Ledger'),
|
||||
single_column: true
|
||||
});
|
||||
|
||||
erpnext.general_ledger = new erpnext.GeneralLedger(wrapper);
|
||||
wrapper.appframe.add_module_icon("Accounts")
|
||||
|
||||
}
|
||||
|
||||
erpnext.GeneralLedger = wn.views.GridReport.extend({
|
||||
init: function(wrapper) {
|
||||
this._super({
|
||||
title: wn._("General Ledger"),
|
||||
page: wrapper,
|
||||
parent: $(wrapper).find('.layout-main'),
|
||||
appframe: wrapper.appframe,
|
||||
doctypes: ["Company", "Account", "GL Entry", "Cost Center"],
|
||||
});
|
||||
},
|
||||
setup_columns: function() {
|
||||
this.columns = [
|
||||
{id: "posting_date", name: wn._("Posting Date"), field: "posting_date", width: 100,
|
||||
formatter: this.date_formatter},
|
||||
{id: "account", name: wn._("Account"), field: "account", width: 240,
|
||||
link_formatter: {
|
||||
filter_input: "account",
|
||||
open_btn: true,
|
||||
doctype: "'Account'"
|
||||
}},
|
||||
{id: "against_account", name: wn._("Against Account"), field: "against_account",
|
||||
width: 240, hidden: !this.account},
|
||||
|
||||
{id: "debit", name: wn._("Debit"), field: "debit", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
{id: "credit", name: wn._("Credit"), field: "credit", width: 100,
|
||||
formatter: this.currency_formatter},
|
||||
{id: "voucher_type", name: wn._("Voucher Type"), field: "voucher_type", width: 120},
|
||||
{id: "voucher_no", name: wn._("Voucher No"), field: "voucher_no", width: 160,
|
||||
link_formatter: {
|
||||
filter_input: "voucher_no",
|
||||
open_btn: true,
|
||||
doctype: "dataContext.voucher_type"
|
||||
}},
|
||||
{id: "remarks", name: wn._("Remarks"), field: "remarks", width: 200,
|
||||
formatter: this.text_formatter},
|
||||
|
||||
];
|
||||
},
|
||||
|
||||
filters: [
|
||||
{fieldtype:"Select", label: wn._("Company"), link:"Company", default_value: wn._("Select Company..."),
|
||||
filter: function(val, item, opts) {
|
||||
return item.company == val || val == opts.default_value;
|
||||
}},
|
||||
{fieldtype:"Link", label: wn._("Account"), link:"Account",
|
||||
filter: function(val, item, opts, me) {
|
||||
if(!val) {
|
||||
return true;
|
||||
} else {
|
||||
// true if GL Entry belongs to selected
|
||||
// account ledger or group
|
||||
return me.is_child_account(val, item.account);
|
||||
}
|
||||
}},
|
||||
{fieldtype:"Data", label: wn._("Voucher No"),
|
||||
filter: function(val, item, opts) {
|
||||
if(!val) return true;
|
||||
return (item.voucher_no && item.voucher_no.indexOf(val)!=-1);
|
||||
}},
|
||||
{fieldtype:"Date", label: wn._("From Date"), filter: function(val, item) {
|
||||
return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date);
|
||||
}},
|
||||
{fieldtype:"Label", label: wn._("To")},
|
||||
{fieldtype:"Date", label: wn._("To Date"), filter: function(val, item) {
|
||||
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
|
||||
}},
|
||||
{fieldtype: "Check", label: wn._("Group by Ledger")},
|
||||
{fieldtype: "Check", label: wn._("Group by Voucher")},
|
||||
{fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"},
|
||||
{fieldtype:"Button", label: wn._("Reset Filters")}
|
||||
],
|
||||
setup_filters: function() {
|
||||
this._super();
|
||||
var me = this;
|
||||
|
||||
this.accounts_by_company = this.make_accounts_by_company();
|
||||
|
||||
// filter accounts options by company
|
||||
this.filter_inputs.company.on("change", function() {
|
||||
me.setup_account_filter(this);
|
||||
me.refresh();
|
||||
});
|
||||
|
||||
this.trigger_refresh_on_change(["group_by_ledger", "group_by_voucher"]);
|
||||
},
|
||||
setup_account_filter: function(company_filter) {
|
||||
var me = this;
|
||||
|
||||
var $account = me.filter_inputs.account;
|
||||
var company = $(company_filter).val();
|
||||
var default_company = this.filter_inputs.company.get(0).opts.default_value;
|
||||
var opts = $account.get(0).opts;
|
||||
opts.list = $.map(wn.report_dump.data["Account"], function(ac) {
|
||||
return (company===default_company ||
|
||||
me.accounts_by_company[company].indexOf(ac.name)!=-1) ?
|
||||
ac.name : null;
|
||||
});
|
||||
|
||||
this.set_autocomplete($account, opts.list);
|
||||
|
||||
},
|
||||
init_filter_values: function() {
|
||||
this._super();
|
||||
this.toggle_group_by_checks();
|
||||
this.filter_inputs.company.trigger("change");
|
||||
},
|
||||
apply_filters_from_route: function() {
|
||||
this._super();
|
||||
this.toggle_group_by_checks();
|
||||
},
|
||||
make_accounts_by_company: function() {
|
||||
var accounts_by_company = {};
|
||||
var me = this;
|
||||
$.each(wn.report_dump.data["Account"], function(i, ac) {
|
||||
if(!accounts_by_company[ac.company]) accounts_by_company[ac.company] = [];
|
||||
accounts_by_company[ac.company].push(ac.name);
|
||||
});
|
||||
return accounts_by_company;
|
||||
},
|
||||
is_child_account: function(account, item_account) {
|
||||
account = this.account_by_name[account];
|
||||
item_account = this.account_by_name[item_account];
|
||||
return ((item_account.lft >= account.lft) && (item_account.rgt <= account.rgt));
|
||||
},
|
||||
toggle_group_by_checks: function() {
|
||||
this.make_account_by_name();
|
||||
|
||||
// this.filter_inputs.group_by_ledger
|
||||
// .parent().toggle(!!(this.account_by_name[this.account]
|
||||
// && this.account_by_name[this.account].group_or_ledger==="Group"));
|
||||
//
|
||||
// this.filter_inputs.group_by_voucher
|
||||
// .parent().toggle(!!(this.account_by_name[this.account]
|
||||
// && this.account_by_name[this.account].group_or_ledger==="Ledger"));
|
||||
},
|
||||
prepare_data: function() {
|
||||
var me = this;
|
||||
var data = wn.report_dump.data["GL Entry"];
|
||||
var out = [];
|
||||
|
||||
this.toggle_group_by_checks();
|
||||
|
||||
var from_date = dateutil.str_to_obj(this.from_date);
|
||||
var to_date = dateutil.str_to_obj(this.to_date);
|
||||
|
||||
if(to_date < from_date) {
|
||||
msgprint(wn._("From Date must be before To Date"));
|
||||
return;
|
||||
}
|
||||
|
||||
// add Opening, Closing, Totals rows
|
||||
// if filtered by account and / or voucher
|
||||
var opening = this.make_summary_row("Opening", this.account);
|
||||
var totals = this.make_summary_row("Totals", this.account);
|
||||
|
||||
var grouped_ledgers = {};
|
||||
$.each(data, function(i, item) {
|
||||
if(me.apply_filter(item, "company") &&
|
||||
(me.account ? me.is_child_account(me.account, item.account)
|
||||
: true) && (me.voucher_no ? item.voucher_no==me.voucher_no : true)) {
|
||||
var date = dateutil.str_to_obj(item.posting_date);
|
||||
|
||||
// create grouping by ledger
|
||||
if(!grouped_ledgers[item.account]) {
|
||||
grouped_ledgers[item.account] = {
|
||||
entries: [],
|
||||
entries_group_by_voucher: {},
|
||||
opening: me.make_summary_row("Opening", item.account),
|
||||
totals: me.make_summary_row("Totals", item.account),
|
||||
closing: me.make_summary_row("Closing (Opening + Totals)",
|
||||
item.account)
|
||||
};
|
||||
}
|
||||
|
||||
if(!grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]) {
|
||||
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] = {
|
||||
row: {},
|
||||
totals: {"debit": 0, "credit": 0}
|
||||
}
|
||||
}
|
||||
|
||||
if(!me.voucher_no && (date < from_date || item.is_opening=="Yes")) {
|
||||
opening.debit += item.debit;
|
||||
opening.credit += item.credit;
|
||||
|
||||
grouped_ledgers[item.account].opening.debit += item.debit;
|
||||
grouped_ledgers[item.account].opening.credit += item.credit;
|
||||
|
||||
} else if(date <= to_date) {
|
||||
|
||||
totals.debit += item.debit;
|
||||
totals.credit += item.credit;
|
||||
|
||||
grouped_ledgers[item.account].totals.debit += item.debit;
|
||||
grouped_ledgers[item.account].totals.credit += item.credit;
|
||||
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
|
||||
.totals.debit += item.debit;
|
||||
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
|
||||
.totals.credit += item.credit;
|
||||
}
|
||||
if(item.account) {
|
||||
item.against_account = me.voucher_accounts[item.voucher_type + ":"
|
||||
+ item.voucher_no][(item.debit > 0 ? "credits" : "debits")].join(", ");
|
||||
}
|
||||
|
||||
if(me.apply_filters(item) && (me.voucher_no || item.is_opening=="No")) {
|
||||
out.push(item);
|
||||
grouped_ledgers[item.account].entries.push(item);
|
||||
|
||||
if(grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no].row){
|
||||
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
|
||||
.row = $.extend({}, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var closing = this.make_summary_row("Closing (Opening + Totals)", this.account);
|
||||
closing.debit = opening.debit + totals.debit;
|
||||
closing.credit = opening.credit + totals.credit;
|
||||
|
||||
if(me.account) {
|
||||
me.appframe.set_title(wn._("General Ledger: ") + me.account);
|
||||
|
||||
// group by ledgers
|
||||
if(this.account_by_name[this.account].group_or_ledger==="Group"
|
||||
&& this.group_by_ledger) {
|
||||
out = this.group_data_by_ledger(grouped_ledgers);
|
||||
}
|
||||
|
||||
if(this.account_by_name[this.account].group_or_ledger==="Ledger"
|
||||
&& this.group_by_voucher) {
|
||||
out = this.group_data_by_voucher(grouped_ledgers);
|
||||
}
|
||||
|
||||
opening = me.get_balance(me.account_by_name[me.account].debit_or_credit, opening)
|
||||
closing = me.get_balance(me.account_by_name[me.account].debit_or_credit, closing)
|
||||
|
||||
out = [opening].concat(out).concat([totals, closing]);
|
||||
} else {
|
||||
me.appframe.set_title(wn._("General Ledger"));
|
||||
out = out.concat([totals]);
|
||||
}
|
||||
|
||||
this.data = out;
|
||||
},
|
||||
|
||||
group_data_by_ledger: function(grouped_ledgers) {
|
||||
var me = this;
|
||||
var out = []
|
||||
$.each(Object.keys(grouped_ledgers).sort(), function(i, account) {
|
||||
if(grouped_ledgers[account].entries.length) {
|
||||
grouped_ledgers[account].closing.debit =
|
||||
grouped_ledgers[account].opening.debit
|
||||
+ grouped_ledgers[account].totals.debit;
|
||||
|
||||
grouped_ledgers[account].closing.credit =
|
||||
grouped_ledgers[account].opening.credit
|
||||
+ grouped_ledgers[account].totals.credit;
|
||||
|
||||
grouped_ledgers[account].opening =
|
||||
me.get_balance(me.account_by_name[me.account].debit_or_credit,
|
||||
grouped_ledgers[account].opening)
|
||||
grouped_ledgers[account].closing =
|
||||
me.get_balance(me.account_by_name[me.account].debit_or_credit,
|
||||
grouped_ledgers[account].closing)
|
||||
|
||||
out = out.concat([grouped_ledgers[account].opening])
|
||||
.concat(grouped_ledgers[account].entries)
|
||||
.concat([grouped_ledgers[account].totals,
|
||||
grouped_ledgers[account].closing,
|
||||
{id: "_blank" + i, debit: "", credit: ""}]);
|
||||
}
|
||||
});
|
||||
return [{id: "_blank_first", debit: "", credit: ""}].concat(out);
|
||||
},
|
||||
|
||||
group_data_by_voucher: function(grouped_ledgers) {
|
||||
var me = this;
|
||||
var out = []
|
||||
$.each(Object.keys(grouped_ledgers).sort(), function(i, account) {
|
||||
if(grouped_ledgers[account].entries.length) {
|
||||
$.each(Object.keys(grouped_ledgers[account].entries_group_by_voucher),
|
||||
function(j, voucher) {
|
||||
voucher_dict = grouped_ledgers[account].entries_group_by_voucher[voucher];
|
||||
if(voucher_dict &&
|
||||
(voucher_dict.totals.debit || voucher_dict.totals.credit)) {
|
||||
voucher_dict.row.debit = voucher_dict.totals.debit;
|
||||
voucher_dict.row.credit = voucher_dict.totals.credit;
|
||||
voucher_dict.row.id = "entry_grouped_by_" + voucher
|
||||
out = out.concat(voucher_dict.row);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return out;
|
||||
},
|
||||
|
||||
get_balance: function(debit_or_credit, balance) {
|
||||
if(debit_or_credit == "Debit") {
|
||||
balance.debit -= balance.credit; balance.credit = 0;
|
||||
} else {
|
||||
balance.credit -= balance.debit; balance.debit = 0;
|
||||
}
|
||||
return balance
|
||||
},
|
||||
|
||||
make_summary_row: function(label, item_account) {
|
||||
return {
|
||||
account: label,
|
||||
debit: 0.0,
|
||||
credit: 0.0,
|
||||
id: ["", label, item_account].join("_").replace(" ", "_").toLowerCase(),
|
||||
_show: true,
|
||||
_style: "font-weight: bold"
|
||||
}
|
||||
},
|
||||
|
||||
make_account_by_name: function() {
|
||||
this.account_by_name = this.make_name_map(wn.report_dump.data["Account"]);
|
||||
this.make_voucher_accounts_map();
|
||||
},
|
||||
|
||||
make_voucher_accounts_map: function() {
|
||||
this.voucher_accounts = {};
|
||||
var data = wn.report_dump.data["GL Entry"];
|
||||
for(var i=0, j=data.length; i<j; i++) {
|
||||
var gl = data[i];
|
||||
|
||||
if(!this.voucher_accounts[gl.voucher_type + ":" + gl.voucher_no])
|
||||
this.voucher_accounts[gl.voucher_type + ":" + gl.voucher_no] = {
|
||||
debits: [],
|
||||
credits: []
|
||||
}
|
||||
|
||||
var va = this.voucher_accounts[gl.voucher_type + ":" + gl.voucher_no];
|
||||
if(gl.debit > 0) {
|
||||
va.debits.push(gl.account);
|
||||
} else {
|
||||
va.credits.push(gl.account);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get_plot_data: function() {
|
||||
var data = [];
|
||||
var me = this;
|
||||
if(!me.account || me.voucher_no) return false;
|
||||
var debit_or_credit = me.account_by_name[me.account].debit_or_credit;
|
||||
var balance = debit_or_credit=="Debit" ? me.data[0].debit : me.data[0].credit;
|
||||
data.push({
|
||||
label: me.account,
|
||||
data: [[dateutil.str_to_obj(me.from_date).getTime(), balance]]
|
||||
.concat($.map(me.data, function(col, idx) {
|
||||
if (col.posting_date) {
|
||||
var diff = (debit_or_credit == "Debit" ? 1 : -1) * (flt(col.debit) - flt(col.credit));
|
||||
balance += diff;
|
||||
return [[dateutil.str_to_obj(col.posting_date).getTime(), balance - diff],
|
||||
[dateutil.str_to_obj(col.posting_date).getTime(), balance]]
|
||||
}
|
||||
return null;
|
||||
})).concat([
|
||||
// closing
|
||||
[dateutil.str_to_obj(me.to_date).getTime(), balance]
|
||||
]),
|
||||
points: {show: true},
|
||||
lines: {show: true, fill: true},
|
||||
});
|
||||
return data;
|
||||
},
|
||||
get_plot_options: function() {
|
||||
return {
|
||||
grid: { hoverable: true, clickable: true },
|
||||
xaxis: { mode: "time",
|
||||
min: dateutil.str_to_obj(this.from_date).getTime(),
|
||||
max: dateutil.str_to_obj(this.to_date).getTime() },
|
||||
series: { downsample: { threshold: 1000 } }
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -1,41 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2012-09-14 11:25:48",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-11 14:42:21",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Page",
|
||||
"icon": "icon-table",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"page_name": "general-ledger",
|
||||
"standard": "Yes",
|
||||
"title": "General Ledger"
|
||||
},
|
||||
{
|
||||
"doctype": "Page Role",
|
||||
"name": "__common__",
|
||||
"parent": "general-ledger",
|
||||
"parentfield": "roles",
|
||||
"parenttype": "Page"
|
||||
},
|
||||
{
|
||||
"doctype": "Page",
|
||||
"name": "general-ledger"
|
||||
},
|
||||
{
|
||||
"doctype": "Page Role",
|
||||
"role": "Analytics"
|
||||
},
|
||||
{
|
||||
"doctype": "Page Role",
|
||||
"role": "Accounts Manager"
|
||||
},
|
||||
{
|
||||
"doctype": "Page Role",
|
||||
"role": "Accounts User"
|
||||
}
|
||||
]
|
||||
@@ -9,17 +9,19 @@ from accounts.report.accounts_receivable.accounts_receivable import get_ageing_d
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
columns = get_columns()
|
||||
supplier_naming_by = webnotes.conn.get_value("Buying Settings", None, "supp_master_name")
|
||||
columns = get_columns(supplier_naming_by)
|
||||
entries = get_gl_entries(filters)
|
||||
account_supplier = dict(webnotes.conn.sql("""select account.name, supplier.supplier_name
|
||||
from `tabAccount` account, `tabSupplier` supplier
|
||||
where account.master_type="Supplier" and supplier.name=account.master_name"""))
|
||||
|
||||
account_map = dict(((r.name, r) for r in webnotes.conn.sql("""select acc.name,
|
||||
supp.supplier_name, supp.name as supplier
|
||||
from `tabAccount` acc, `tabSupplier` supp
|
||||
where acc.master_type="Supplier" and supp.name=acc.master_name""", as_dict=1)))
|
||||
|
||||
entries_after_report_date = [[gle.voucher_type, gle.voucher_no]
|
||||
for gle in get_gl_entries(filters, before_report_date=False)]
|
||||
|
||||
|
||||
account_supplier_type_map = get_account_supplier_type_map()
|
||||
pi_map = get_pi_map()
|
||||
voucher_detail_map = get_voucher_details()
|
||||
|
||||
# Age of the invoice on this date
|
||||
age_on = getdate(filters.get("report_date")) > getdate(nowdate()) \
|
||||
@@ -29,46 +31,57 @@ def execute(filters=None):
|
||||
for gle in entries:
|
||||
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
|
||||
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
|
||||
if gle.voucher_type == "Purchase Invoice":
|
||||
pi_info = pi_map.get(gle.voucher_no)
|
||||
due_date = pi_info.get("due_date")
|
||||
bill_no = pi_info.get("bill_no")
|
||||
bill_date = pi_info.get("bill_date")
|
||||
else:
|
||||
due_date = bill_no = bill_date = ""
|
||||
|
||||
voucher_details = voucher_detail_map.get(gle.voucher_type, {}).get(gle.voucher_no, {})
|
||||
|
||||
invoiced_amount = gle.credit > 0 and gle.credit or 0
|
||||
outstanding_amount = get_outstanding_amount(gle,
|
||||
filters.get("report_date") or nowdate())
|
||||
|
||||
if abs(flt(outstanding_amount)) > 0.01:
|
||||
paid_amount = invoiced_amount - outstanding_amount
|
||||
row = [gle.posting_date, gle.account, account_supplier.get(gle.account, ""),
|
||||
gle.voucher_type, gle.voucher_no,
|
||||
gle.remarks, account_supplier_type_map.get(gle.account), due_date, bill_no,
|
||||
bill_date, invoiced_amount, paid_amount, outstanding_amount]
|
||||
row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
|
||||
voucher_details.get("due_date", ""), voucher_details.get("bill_no", ""),
|
||||
voucher_details.get("bill_date", ""), invoiced_amount,
|
||||
paid_amount, outstanding_amount]
|
||||
|
||||
# Ageing
|
||||
if filters.get("ageing_based_on") == "Due Date":
|
||||
ageing_based_on_date = due_date
|
||||
ageing_based_on_date = voucher_details.get("due_date", "")
|
||||
else:
|
||||
ageing_based_on_date = gle.posting_date
|
||||
|
||||
row += get_ageing_data(age_on, ageing_based_on_date, outstanding_amount)
|
||||
row += get_ageing_data(age_on, ageing_based_on_date, outstanding_amount) + \
|
||||
[account_map.get(gle.account).get("supplier") or ""]
|
||||
|
||||
if supplier_naming_by == "Naming Series":
|
||||
row += [account_map.get(gle.account).get("supplier_name") or ""]
|
||||
|
||||
row += [account_supplier_type_map.get(gle.account), gle.remarks]
|
||||
data.append(row)
|
||||
|
||||
|
||||
for i in range(0, len(data)):
|
||||
data[i].insert(4, """<a href="%s"><i class="icon icon-share" style="cursor: pointer;"></i></a>""" \
|
||||
% ("/".join(["#Form", data[i][2], data[i][3]]),))
|
||||
|
||||
return columns, data
|
||||
|
||||
def get_columns():
|
||||
return [
|
||||
"Posting Date:Date:80", "Account:Link/Account:150", "Supplier::150", "Voucher Type::110",
|
||||
"Voucher No::120", "Remarks::150", "Supplier Type:Link/Supplier Type:120",
|
||||
"Due Date:Date:80", "Bill No::80", "Bill Date:Date:80",
|
||||
def get_columns(supplier_naming_by):
|
||||
columns = [
|
||||
"Posting Date:Date:80", "Account:Link/Account:150", "Voucher Type::110",
|
||||
"Voucher No::120", "::30", "Due Date:Date:80", "Bill No::80", "Bill Date:Date:80",
|
||||
"Invoiced Amount:Currency:100", "Paid Amount:Currency:100",
|
||||
"Outstanding Amount:Currency:100", "Age:Int:50", "0-30:Currency:100",
|
||||
"30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100"
|
||||
"30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100",
|
||||
"Supplier:Link/Supplier:150"
|
||||
]
|
||||
|
||||
|
||||
if supplier_naming_by == "Naming Series":
|
||||
columns += ["Supplier Name::110"]
|
||||
|
||||
columns += ["Supplier Type:Link/Supplier Type:120", "Remarks::150"]
|
||||
|
||||
return columns
|
||||
|
||||
def get_gl_entries(filters, before_report_date=True):
|
||||
conditions, supplier_accounts = get_conditions(filters, before_report_date)
|
||||
gl_entries = []
|
||||
@@ -106,20 +119,21 @@ def get_conditions(filters, before_report_date=True):
|
||||
|
||||
def get_account_supplier_type_map():
|
||||
account_supplier_type_map = {}
|
||||
for each in webnotes.conn.sql("""select t2.name, t1.supplier_type from `tabSupplier` t1,
|
||||
`tabAccount` t2 where t1.name = t2.master_name group by t2.name"""):
|
||||
for each in webnotes.conn.sql("""select acc.name, supp.supplier_type from `tabSupplier` supp,
|
||||
`tabAccount` acc where supp.name = acc.master_name group by acc.name"""):
|
||||
account_supplier_type_map[each[0]] = each[1]
|
||||
|
||||
|
||||
return account_supplier_type_map
|
||||
|
||||
def get_pi_map():
|
||||
""" get due_date from sales invoice """
|
||||
pi_map = {}
|
||||
for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date
|
||||
from `tabPurchase Invoice`""", as_dict=1):
|
||||
pi_map[t.name] = t
|
||||
def get_voucher_details():
|
||||
voucher_details = {}
|
||||
for dt in ["Purchase Invoice", "Journal Voucher"]:
|
||||
voucher_details.setdefault(dt, webnotes._dict())
|
||||
for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date
|
||||
from `tab%s`""" % dt, as_dict=1):
|
||||
voucher_details[dt].setdefault(t.name, t)
|
||||
|
||||
return pi_map
|
||||
return voucher_details
|
||||
|
||||
def get_outstanding_amount(gle, report_date):
|
||||
payment_amount = webnotes.conn.sql("""
|
||||
|
||||
@@ -15,26 +15,34 @@ class AccountsReceivableReport(object):
|
||||
else self.filters.report_date
|
||||
|
||||
def run(self):
|
||||
return self.get_columns(), self.get_data()
|
||||
customer_naming_by = webnotes.conn.get_value("Selling Settings", None, "cust_master_name")
|
||||
return self.get_columns(customer_naming_by), self.get_data(customer_naming_by)
|
||||
|
||||
def get_columns(self):
|
||||
return [
|
||||
def get_columns(self, customer_naming_by):
|
||||
columns = [
|
||||
"Posting Date:Date:80", "Account:Link/Account:150",
|
||||
"Voucher Type::110", "Voucher No::120", "::30",
|
||||
"Due Date:Date:80",
|
||||
"Invoiced Amount:Currency:100", "Payment Received:Currency:100",
|
||||
"Outstanding Amount:Currency:100", "Age:Int:50", "0-30:Currency:100",
|
||||
"30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100",
|
||||
"Customer:Link/Customer:200", "Territory:Link/Territory:80", "Remarks::200"
|
||||
"Customer:Link/Customer:200"
|
||||
]
|
||||
|
||||
def get_data(self):
|
||||
|
||||
if customer_naming_by == "Naming Series":
|
||||
columns += ["Customer Name::110"]
|
||||
|
||||
columns += ["Territory:Link/Territory:80", "Remarks::200"]
|
||||
|
||||
return columns
|
||||
|
||||
def get_data(self, customer_naming_by):
|
||||
data = []
|
||||
future_vouchers = self.get_entries_after(self.filters.report_date)
|
||||
for gle in self.get_entries_till(self.filters.report_date):
|
||||
if self.is_receivable(gle, future_vouchers):
|
||||
outstanding_amount = self.get_outstanding_amount(gle, self.filters.report_date)
|
||||
if abs(outstanding_amount) > 0.01:
|
||||
if abs(outstanding_amount) > 0.0:
|
||||
due_date = self.get_due_date(gle)
|
||||
invoiced_amount = gle.debit if (gle.debit > 0) else 0
|
||||
payment_received = invoiced_amount - outstanding_amount
|
||||
@@ -42,18 +50,23 @@ class AccountsReceivableReport(object):
|
||||
gle.voucher_type, gle.voucher_no, due_date,
|
||||
invoiced_amount, payment_received,
|
||||
outstanding_amount]
|
||||
entry_date = due_date if self.filters.ageing_based_on=="Due Date" \
|
||||
entry_date = due_date if self.filters.ageing_based_on == "Due Date" \
|
||||
else gle.posting_date
|
||||
row += get_ageing_data(self.age_as_on, entry_date, outstanding_amount)
|
||||
row += [self.get_customer(gle.account), self.get_territory(gle.account), gle.remarks]
|
||||
row += get_ageing_data(self.age_as_on, entry_date, outstanding_amount) + \
|
||||
[self.get_customer(gle.account)]
|
||||
|
||||
if customer_naming_by == "Naming Series":
|
||||
row += [self.get_customer_name(gle.account)]
|
||||
|
||||
row += [self.get_territory(gle.account), gle.remarks]
|
||||
data.append(row)
|
||||
|
||||
for i in range(0,len(data)):
|
||||
for i in range(0, len(data)):
|
||||
data[i].insert(4, """<a href="%s"><i class="icon icon-share" style="cursor: pointer;"></i></a>""" \
|
||||
% ("/".join(["#Form", data[i][2], data[i][3]]),))
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def get_entries_after(self, report_date):
|
||||
# returns a distinct list
|
||||
return list(set([(e.voucher_type, e.voucher_no) for e in self.get_gl_entries()
|
||||
@@ -65,30 +78,41 @@ class AccountsReceivableReport(object):
|
||||
if getdate(e.posting_date) <= report_date)
|
||||
|
||||
def is_receivable(self, gle, future_vouchers):
|
||||
return ((not gle.against_voucher) or (gle.against_voucher==gle.voucher_no) or
|
||||
((gle.against_voucher_type, gle.against_voucher) in future_vouchers))
|
||||
return (
|
||||
# advance
|
||||
(not gle.against_voucher) or
|
||||
|
||||
# sales invoice
|
||||
(gle.against_voucher==gle.voucher_no and gle.debit > 0) or
|
||||
|
||||
# entries adjusted with future vouchers
|
||||
((gle.against_voucher_type, gle.against_voucher) in future_vouchers)
|
||||
)
|
||||
|
||||
def get_outstanding_amount(self, gle, report_date):
|
||||
payment_received = 0.0
|
||||
for e in self.get_gl_entries_for(gle.account, gle.voucher_type, gle.voucher_no):
|
||||
if getdate(e.posting_date) <= report_date and e.name!=gle.name:
|
||||
payment_received += (flt(e.credit) - flt(e.debit))
|
||||
|
||||
|
||||
return flt(gle.debit) - flt(gle.credit) - payment_received
|
||||
|
||||
def get_customer(self, account):
|
||||
return self.get_account_map().get(account).get("customer") or ""
|
||||
|
||||
def get_customer_name(self, account):
|
||||
return self.get_account_map().get(account).get("customer_name") or ""
|
||||
|
||||
|
||||
def get_territory(self, account):
|
||||
return self.get_account_map().get(account).get("territory") or ""
|
||||
|
||||
def get_account_map(self):
|
||||
if not hasattr(self, "account_map"):
|
||||
self.account_map = dict(((r.name, r) for r in webnotes.conn.sql("""select
|
||||
account.name, customer.name as customer_name, customer.territory
|
||||
from `tabAccount` account, `tabCustomer` customer
|
||||
where account.master_type="Customer"
|
||||
and customer.name=account.master_name""", as_dict=True)))
|
||||
acc.name, cust.name as customer, cust.customer_name, cust.territory
|
||||
from `tabAccount` acc, `tabCustomer` cust
|
||||
where acc.master_type="Customer"
|
||||
and cust.name=acc.master_name""", as_dict=True)))
|
||||
|
||||
return self.account_map
|
||||
|
||||
@@ -147,7 +171,7 @@ class AccountsReceivableReport(object):
|
||||
|
||||
def execute(filters=None):
|
||||
return AccountsReceivableReport(filters).run()
|
||||
|
||||
|
||||
def get_ageing_data(age_as_on, entry_date, outstanding_amount):
|
||||
# [0-30, 30-60, 60-90, 90-above]
|
||||
outstanding_range = [0.0, 0.0, 0.0, 0.0]
|
||||
|
||||
@@ -8,6 +8,7 @@ wn.query_reports["Bank Reconciliation Statement"] = {
|
||||
"label": wn._("Bank Account"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Account",
|
||||
"reqd": 1,
|
||||
"get_query": function() {
|
||||
return {
|
||||
"query": "accounts.utils.get_account_list",
|
||||
@@ -22,7 +23,8 @@ wn.query_reports["Bank Reconciliation Statement"] = {
|
||||
"fieldname":"report_date",
|
||||
"label": wn._("Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": get_today()
|
||||
"default": get_today(),
|
||||
"reqd": 1
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -3,13 +3,14 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _, msgprint
|
||||
from webnotes.utils import flt
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
|
||||
columns = get_columns()
|
||||
|
||||
debit_or_credit = webnotes.conn.get_value("Account", filters["account"], "debit_or_credit")
|
||||
|
||||
columns = get_columns()
|
||||
data = get_entries(filters)
|
||||
|
||||
from accounts.utils import get_balance_on
|
||||
@@ -20,47 +21,39 @@ def execute(filters=None):
|
||||
total_debit += flt(d[4])
|
||||
total_credit += flt(d[5])
|
||||
|
||||
if webnotes.conn.get_value("Account", filters["account"], "debit_or_credit") == 'Debit':
|
||||
if debit_or_credit == 'Debit':
|
||||
bank_bal = flt(balance_as_per_company) - flt(total_debit) + flt(total_credit)
|
||||
else:
|
||||
bank_bal = flt(balance_as_per_company) + flt(total_debit) - flt(total_credit)
|
||||
|
||||
data += [
|
||||
["", "", "", "Balance as per company books", balance_as_per_company, ""],
|
||||
get_balance_row("Balance as per company books", balance_as_per_company, debit_or_credit),
|
||||
["", "", "", "Amounts not reflected in bank", total_debit, total_credit],
|
||||
["", "", "", "Balance as per bank", bank_bal, ""]
|
||||
get_balance_row("Balance as per bank", bank_bal, debit_or_credit)
|
||||
]
|
||||
|
||||
return columns, data
|
||||
|
||||
return columns, data
|
||||
|
||||
def get_columns():
|
||||
return ["Journal Voucher:Link/Journal Voucher:140", "Posting Date:Date:100",
|
||||
"Clearance Date:Date:110", "Against Account:Link/Account:200",
|
||||
"Debit:Currency:120", "Credit:Currency:120"
|
||||
]
|
||||
|
||||
def get_conditions(filters):
|
||||
conditions = ""
|
||||
if not filters.get("account"):
|
||||
msgprint(_("Please select Bank Account"), raise_exception=1)
|
||||
else:
|
||||
conditions += " and jvd.account = %(account)s"
|
||||
|
||||
if not filters.get("report_date"):
|
||||
msgprint(_("Please select Date on which you want to run the report"), raise_exception=1)
|
||||
else:
|
||||
conditions += """ and jv.posting_date <= %(report_date)s
|
||||
and ifnull(jv.clearance_date, '4000-01-01') > %(report_date)s"""
|
||||
|
||||
return conditions
|
||||
|
||||
def get_entries(filters):
|
||||
conditions = get_conditions(filters)
|
||||
entries = webnotes.conn.sql("""select jv.name, jv.posting_date, jv.clearance_date,
|
||||
jvd.against_account, jvd.debit, jvd.credit
|
||||
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
||||
where jvd.parent = jv.name and jv.docstatus=1 and ifnull(jv.cheque_no, '')!= '' %s
|
||||
order by jv.name DESC""" % conditions, filters, as_list=1)
|
||||
entries = webnotes.conn.sql("""select
|
||||
jv.name, jv.posting_date, jv.clearance_date, jvd.against_account, jvd.debit, jvd.credit
|
||||
from
|
||||
`tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
||||
where jvd.parent = jv.name and jv.docstatus=1 and ifnull(jv.cheque_no, '')!= ''
|
||||
and jvd.account = %(account)s and jv.posting_date <= %(report_date)s
|
||||
and ifnull(jv.clearance_date, '4000-01-01') > %(report_date)s
|
||||
order by jv.name DESC""", filters, as_list=1)
|
||||
|
||||
return entries
|
||||
return entries
|
||||
|
||||
def get_balance_row(label, amount, debit_or_credit):
|
||||
if debit_or_credit == "Debit":
|
||||
return ["", "", "", label, amount, 0]
|
||||
else:
|
||||
return ["", "", "", label, 0, amount]
|
||||
65
accounts/report/general_ledger/general_ledger.js
Normal file
65
accounts/report/general_ledger/general_ledger.js
Normal file
@@ -0,0 +1,65 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
wn.query_reports["General Ledger"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"company",
|
||||
"label": wn._("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company",
|
||||
"default": wn.defaults.get_user_default("company"),
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": wn._("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": wn.datetime.add_months(wn.datetime.get_today(), -1),
|
||||
"reqd": 1,
|
||||
"width": "60px"
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": wn._("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": wn.datetime.get_today(),
|
||||
"reqd": 1,
|
||||
"width": "60px"
|
||||
},
|
||||
{
|
||||
"fieldtype": "Break",
|
||||
},
|
||||
{
|
||||
"fieldname":"account",
|
||||
"label": wn._("Account"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Account",
|
||||
"get_query": function() {
|
||||
var company = wn.query_report.filters_by_name.company.get_value();
|
||||
return {
|
||||
"doctype": "Account",
|
||||
"filters": {
|
||||
"company": company,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"fieldname":"voucher_no",
|
||||
"label": wn._("Voucher No"),
|
||||
"fieldtype": "Data",
|
||||
},
|
||||
{
|
||||
"fieldname":"group_by_voucher",
|
||||
"label": wn._("Group by Voucher"),
|
||||
"fieldtype": "Check",
|
||||
"default": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"group_by_account",
|
||||
"label": wn._("Group by Account"),
|
||||
"fieldtype": "Check",
|
||||
}
|
||||
]
|
||||
}
|
||||
177
accounts/report/general_ledger/general_ledger.py
Normal file
177
accounts/report/general_ledger/general_ledger.py
Normal file
@@ -0,0 +1,177 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cstr, flt
|
||||
from webnotes import _
|
||||
|
||||
def execute(filters=None):
|
||||
account_details = {}
|
||||
for acc in webnotes.conn.sql("""select name, debit_or_credit, group_or_ledger
|
||||
from tabAccount""", as_dict=1):
|
||||
account_details.setdefault(acc.name, acc)
|
||||
|
||||
validate_filters(filters, account_details)
|
||||
|
||||
columns = get_columns()
|
||||
|
||||
res = get_result(filters, account_details)
|
||||
|
||||
return columns, res
|
||||
|
||||
def validate_filters(filters, account_details):
|
||||
if filters.get("account") and filters.get("group_by_account") \
|
||||
and account_details[filters.account].group_or_ledger == "Ledger":
|
||||
webnotes.throw(_("Can not filter based on Account, if grouped by Account"))
|
||||
|
||||
if filters.get("voucher_no") and filters.get("group_by_voucher"):
|
||||
webnotes.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
|
||||
|
||||
if filters.from_date > filters.to_date:
|
||||
webnotes.throw(_("From Date must be before To Date"))
|
||||
|
||||
def get_columns():
|
||||
return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Float:100",
|
||||
"Credit:Float:100", "Voucher Type::120", "Voucher No::160", "Link::20",
|
||||
"Against Account::120", "Cost Center:Link/Cost Center:100", "Remarks::200"]
|
||||
|
||||
def get_result(filters, account_details):
|
||||
gl_entries = get_gl_entries(filters)
|
||||
|
||||
data = get_data_with_opening_closing(filters, account_details, gl_entries)
|
||||
|
||||
result = get_result_as_list(data)
|
||||
|
||||
return result
|
||||
|
||||
def get_gl_entries(filters):
|
||||
group_by_condition = "group by voucher_type, voucher_no, account" \
|
||||
if filters.get("group_by_voucher") else "group by name"
|
||||
|
||||
gl_entries = webnotes.conn.sql("""select posting_date, account,
|
||||
sum(ifnull(debit, 0)) as debit, sum(ifnull(credit, 0)) as credit,
|
||||
voucher_type, voucher_no, cost_center, remarks, is_advance, against
|
||||
from `tabGL Entry`
|
||||
where company=%(company)s {conditions}
|
||||
{group_by_condition}
|
||||
order by posting_date, account"""\
|
||||
.format(conditions=get_conditions(filters), group_by_condition=group_by_condition),
|
||||
filters, as_dict=1)
|
||||
|
||||
return gl_entries
|
||||
|
||||
def get_conditions(filters):
|
||||
conditions = []
|
||||
if filters.get("account"):
|
||||
lft, rgt = webnotes.conn.get_value("Account", filters["account"], ["lft", "rgt"])
|
||||
conditions.append("""account in (select name from tabAccount
|
||||
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
|
||||
else:
|
||||
conditions.append("posting_date between %(from_date)s and %(to_date)s")
|
||||
|
||||
if filters.get("voucher_no"):
|
||||
conditions.append("voucher_no=%(voucher_no)s")
|
||||
|
||||
|
||||
from webnotes.widgets.reportview import build_match_conditions
|
||||
match_conditions = build_match_conditions("GL Entry")
|
||||
if match_conditions: conditions.append(match_conditions)
|
||||
|
||||
return "and {}".format(" and ".join(conditions)) if conditions else ""
|
||||
|
||||
def get_data_with_opening_closing(filters, account_details, gl_entries):
|
||||
data = []
|
||||
gle_map = initialize_gle_map(gl_entries)
|
||||
|
||||
opening, total_debit, total_credit, gle_map = get_accountwise_gle(filters, gl_entries, gle_map)
|
||||
|
||||
# Opening for filtered account
|
||||
if filters.get("account"):
|
||||
data += [get_balance_row("Opening", account_details[filters.account].debit_or_credit,
|
||||
opening), {}]
|
||||
|
||||
for acc, acc_dict in gle_map.items():
|
||||
if acc_dict.entries:
|
||||
# Opening for individual ledger, if grouped by account
|
||||
if filters.get("group_by_account"):
|
||||
data.append(get_balance_row("Opening", account_details[acc].debit_or_credit,
|
||||
acc_dict.opening))
|
||||
|
||||
data += acc_dict.entries
|
||||
|
||||
# Totals and closing for individual ledger, if grouped by account
|
||||
if filters.get("group_by_account"):
|
||||
data += [{"account": "Totals", "debit": acc_dict.total_debit,
|
||||
"credit": acc_dict.total_credit},
|
||||
get_balance_row("Closing (Opening + Totals)",
|
||||
account_details[acc].debit_or_credit, (acc_dict.opening
|
||||
+ acc_dict.total_debit - acc_dict.total_credit)), {}]
|
||||
|
||||
# Total debit and credit between from and to date
|
||||
if total_debit or total_credit:
|
||||
data.append({"account": "Totals", "debit": total_debit, "credit": total_credit})
|
||||
|
||||
# Closing for filtered account
|
||||
if filters.get("account"):
|
||||
data.append(get_balance_row("Closing (Opening + Totals)",
|
||||
account_details[filters.account].debit_or_credit,
|
||||
(opening + total_debit - total_credit)))
|
||||
|
||||
return data
|
||||
|
||||
def initialize_gle_map(gl_entries):
|
||||
gle_map = webnotes._dict()
|
||||
for gle in gl_entries:
|
||||
gle_map.setdefault(gle.account, webnotes._dict({
|
||||
"opening": 0,
|
||||
"entries": [],
|
||||
"total_debit": 0,
|
||||
"total_credit": 0,
|
||||
"closing": 0
|
||||
}))
|
||||
return gle_map
|
||||
|
||||
def get_accountwise_gle(filters, gl_entries, gle_map):
|
||||
opening, total_debit, total_credit = 0, 0, 0
|
||||
|
||||
for gle in gl_entries:
|
||||
amount = flt(gle.debit) - flt(gle.credit)
|
||||
if filters.get("account") and (gle.posting_date < filters.from_date
|
||||
or cstr(gle.is_advance) == "Yes"):
|
||||
gle_map[gle.account].opening += amount
|
||||
opening += amount
|
||||
elif gle.posting_date <= filters.to_date:
|
||||
gle_map[gle.account].entries.append(gle)
|
||||
gle_map[gle.account].total_debit += flt(gle.debit)
|
||||
gle_map[gle.account].total_credit += flt(gle.credit)
|
||||
|
||||
total_debit += flt(gle.debit)
|
||||
total_credit += flt(gle.credit)
|
||||
|
||||
return opening, total_debit, total_credit, gle_map
|
||||
|
||||
def get_balance_row(label, debit_or_credit, balance):
|
||||
return {
|
||||
"account": label,
|
||||
"debit": balance if debit_or_credit=="Debit" else 0,
|
||||
"credit": -1*balance if debit_or_credit=="Credit" else 0,
|
||||
}
|
||||
|
||||
def get_result_as_list(data):
|
||||
result = []
|
||||
for d in data:
|
||||
result.append([d.get("posting_date"), d.get("account"), d.get("debit"),
|
||||
d.get("credit"), d.get("voucher_type"), d.get("voucher_no"),
|
||||
get_voucher_link(d.get("voucher_type"), d.get("voucher_no")),
|
||||
d.get("against"), d.get("cost_center"), d.get("remarks")])
|
||||
|
||||
return result
|
||||
|
||||
def get_voucher_link(voucher_type, voucher_no):
|
||||
icon = ""
|
||||
if voucher_type and voucher_no:
|
||||
icon = """<a href="%s"><i class="icon icon-share" style="cursor: pointer;">
|
||||
</i></a>""" % ("/".join(["#Form", voucher_type, voucher_no]))
|
||||
|
||||
return icon
|
||||
21
accounts/report/general_ledger/general_ledger.txt
Normal file
21
accounts/report/general_ledger/general_ledger.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-12-06 13:22:23",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-12-06 13:22:23",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "GL Entry",
|
||||
"report_name": "General Ledger",
|
||||
"report_type": "Script Report"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"name": "General Ledger"
|
||||
}
|
||||
]
|
||||
@@ -12,7 +12,8 @@ def execute(filters=None):
|
||||
|
||||
item_list = get_items(filters)
|
||||
aii_account_map = get_aii_accounts()
|
||||
item_tax, tax_accounts = get_tax_accounts(item_list, columns)
|
||||
if item_list:
|
||||
item_tax, tax_accounts = get_tax_accounts(item_list, columns)
|
||||
|
||||
data = []
|
||||
for d in item_list:
|
||||
|
||||
@@ -11,7 +11,8 @@ def execute(filters=None):
|
||||
last_col = len(columns)
|
||||
|
||||
item_list = get_items(filters)
|
||||
item_tax, tax_accounts = get_tax_accounts(item_list, columns)
|
||||
if item_list:
|
||||
item_tax, tax_accounts = get_tax_accounts(item_list, columns)
|
||||
|
||||
data = []
|
||||
for d in item_list:
|
||||
@@ -39,7 +40,6 @@ def get_columns():
|
||||
"Qty:Float:120", "Rate:Currency:120", "Amount:Currency:120"
|
||||
]
|
||||
|
||||
|
||||
def get_conditions(filters):
|
||||
conditions = ""
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import webnotes
|
||||
from webnotes.utils import nowdate, nowtime, cstr, flt, now, getdate, add_months
|
||||
from webnotes.utils import nowdate, cstr, flt, now, getdate, add_months
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes import msgprint, _
|
||||
from webnotes.utils import formatdate
|
||||
@@ -16,7 +16,7 @@ class BudgetError(webnotes.ValidationError): pass
|
||||
|
||||
|
||||
def get_fiscal_year(date=None, fiscal_year=None, label="Date", verbose=1):
|
||||
return get_fiscal_years(date, fiscal_year, label, verbose=1)[0]
|
||||
return get_fiscal_years(date, fiscal_year, label, verbose)[0]
|
||||
|
||||
def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1):
|
||||
# if year start date is 2012-04-01, year end date should be 2013-03-31 (hence subdate)
|
||||
@@ -31,6 +31,8 @@ def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1):
|
||||
|
||||
if not fy:
|
||||
error_msg = """%s %s not in any Fiscal Year""" % (label, formatdate(date))
|
||||
error_msg = """{msg}: {date}""".format(msg=_("Fiscal Year does not exist for date"),
|
||||
date=formatdate(date))
|
||||
if verbose: webnotes.msgprint(error_msg)
|
||||
raise FiscalYearError, error_msg
|
||||
|
||||
@@ -62,7 +64,6 @@ def get_balance_on(account=None, date=None):
|
||||
try:
|
||||
year_start_date = get_fiscal_year(date, verbose=0)[1]
|
||||
except FiscalYearError, e:
|
||||
from webnotes.utils import getdate
|
||||
if getdate(date) > getdate(nowdate()):
|
||||
# if fiscal year not found and the date is greater than today
|
||||
# get fiscal year for today's date and its corresponding year start date
|
||||
@@ -220,17 +221,26 @@ def get_cost_center_list(doctype, txt, searchfield, start, page_len, filters):
|
||||
tuple(filter_values + ["%%%s%%" % txt, start, page_len]))
|
||||
|
||||
def remove_against_link_from_jv(ref_type, ref_no, against_field):
|
||||
webnotes.conn.sql("""update `tabJournal Voucher Detail` set `%s`=null,
|
||||
modified=%s, modified_by=%s
|
||||
where `%s`=%s and docstatus < 2""" % (against_field, "%s", "%s", against_field, "%s"),
|
||||
(now(), webnotes.session.user, ref_no))
|
||||
linked_jv = webnotes.conn.sql_list("""select parent from `tabJournal Voucher Detail`
|
||||
where `%s`=%s and docstatus < 2""" % (against_field, "%s"), (ref_no))
|
||||
|
||||
if linked_jv:
|
||||
webnotes.conn.sql("""update `tabJournal Voucher Detail` set `%s`=null,
|
||||
modified=%s, modified_by=%s
|
||||
where `%s`=%s and docstatus < 2""" % (against_field, "%s", "%s", against_field, "%s"),
|
||||
(now(), webnotes.session.user, ref_no))
|
||||
|
||||
webnotes.conn.sql("""update `tabGL Entry`
|
||||
set against_voucher_type=null, against_voucher=null,
|
||||
modified=%s, modified_by=%s
|
||||
where against_voucher_type=%s and against_voucher=%s
|
||||
and voucher_no != ifnull(against_voucher, '')""",
|
||||
(now(), webnotes.session.user, ref_type, ref_no))
|
||||
webnotes.conn.sql("""update `tabGL Entry`
|
||||
set against_voucher_type=null, against_voucher=null,
|
||||
modified=%s, modified_by=%s
|
||||
where against_voucher_type=%s and against_voucher=%s
|
||||
and voucher_no != ifnull(against_voucher, '')""",
|
||||
(now(), webnotes.session.user, ref_type, ref_no))
|
||||
|
||||
webnotes.msgprint("{msg} {linked_jv}".format(msg = _("""Following linked Journal Vouchers \
|
||||
made against this transaction has been unlinked. You can link them again with other \
|
||||
transactions via Payment Reconciliation Tool."""), linked_jv="\n".join(linked_jv)))
|
||||
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_company_default(company, fieldname):
|
||||
@@ -368,4 +378,4 @@ def get_account_for(account_for_doctype, account_for):
|
||||
account_for_field = "account_type"
|
||||
|
||||
return webnotes.conn.get_value("Account", {account_for_field: account_for_doctype,
|
||||
"master_name": account_for})
|
||||
"master_name": account_for})
|
||||
@@ -22,7 +22,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
if(this.frm.fields_dict.buying_price_list) {
|
||||
this.frm.set_query("buying_price_list", function() {
|
||||
return{
|
||||
filters: { 'buying_or_selling': "Buying" }
|
||||
filters: { 'buying': 1 }
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -302,11 +302,11 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
|
||||
calculate_totals: function() {
|
||||
var tax_count = this.frm.tax_doclist.length;
|
||||
this.frm.doc.grand_total = flt(
|
||||
tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total,
|
||||
this.frm.doc.grand_total = flt(tax_count ?
|
||||
this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total,
|
||||
precision("grand_total"));
|
||||
this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate,
|
||||
precision("grand_total_import"));
|
||||
this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total /
|
||||
this.frm.doc.conversion_rate, precision("grand_total_import"));
|
||||
|
||||
this.frm.doc.total_tax = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
|
||||
precision("total_tax"));
|
||||
@@ -321,20 +321,26 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
}
|
||||
|
||||
// other charges added/deducted
|
||||
this.frm.doc.other_charges_added = 0.0
|
||||
this.frm.doc.other_charges_deducted = 0.0
|
||||
if(tax_count) {
|
||||
this.frm.doc.other_charges_added = wn.utils.sum($.map(this.frm.tax_doclist,
|
||||
function(tax) { return (tax.add_deduct_tax == "Add" && in_list(["Valuation and Total", "Total"], tax.category)) ? tax.tax_amount : 0.0; }));
|
||||
function(tax) { return (tax.add_deduct_tax == "Add"
|
||||
&& in_list(["Valuation and Total", "Total"], tax.category)) ?
|
||||
tax.tax_amount : 0.0; }));
|
||||
|
||||
this.frm.doc.other_charges_deducted = wn.utils.sum($.map(this.frm.tax_doclist,
|
||||
function(tax) { return (tax.add_deduct_tax == "Deduct" && in_list(["Valuation and Total", "Total"], tax.category)) ? tax.tax_amount : 0.0; }));
|
||||
function(tax) { return (tax.add_deduct_tax == "Deduct"
|
||||
&& in_list(["Valuation and Total", "Total"], tax.category)) ?
|
||||
tax.tax_amount : 0.0; }));
|
||||
|
||||
wn.model.round_floats_in(this.frm.doc, ["other_charges_added", "other_charges_deducted"]);
|
||||
|
||||
this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added / this.frm.doc.conversion_rate,
|
||||
precision("other_charges_added_import"));
|
||||
this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted / this.frm.doc.conversion_rate,
|
||||
precision("other_charges_deducted_import"));
|
||||
wn.model.round_floats_in(this.frm.doc,
|
||||
["other_charges_added", "other_charges_deducted"]);
|
||||
}
|
||||
this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added /
|
||||
this.frm.doc.conversion_rate, precision("other_charges_added_import"));
|
||||
this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted /
|
||||
this.frm.doc.conversion_rate, precision("other_charges_deducted_import"));
|
||||
},
|
||||
|
||||
_cleanup: function() {
|
||||
|
||||
@@ -7,11 +7,9 @@ import webnotes
|
||||
from webnotes.utils import cstr, flt
|
||||
from webnotes.model.utils import getlist
|
||||
from webnotes import msgprint, _
|
||||
|
||||
from buying.utils import get_last_purchase_details
|
||||
|
||||
|
||||
from controllers.buying_controller import BuyingController
|
||||
|
||||
class DocType(BuyingController):
|
||||
def __init__(self, doc, doclist=None):
|
||||
self.doc = doc
|
||||
@@ -38,13 +36,13 @@ class DocType(BuyingController):
|
||||
if flt(d.conversion_factor):
|
||||
last_purchase_rate = flt(d.purchase_rate) / flt(d.conversion_factor)
|
||||
else:
|
||||
msgprint(_("Row ") + cstr(d.idx) + ": " +
|
||||
_("UOM Conversion Factor is mandatory"), raise_exception=1)
|
||||
webnotes.throw(_("Row ") + cstr(d.idx) + ": " +
|
||||
_("UOM Conversion Factor is mandatory"))
|
||||
|
||||
# update last purchsae rate
|
||||
if last_purchase_rate:
|
||||
webnotes.conn.sql("update `tabItem` set last_purchase_rate = %s where name = %s",
|
||||
(flt(last_purchase_rate),d.item_code))
|
||||
webnotes.conn.sql("""update `tabItem` set last_purchase_rate = %s where name = %s""",
|
||||
(flt(last_purchase_rate), d.item_code))
|
||||
|
||||
def get_last_purchase_rate(self, obj):
|
||||
"""get last purchase rates for all items"""
|
||||
@@ -76,11 +74,11 @@ class DocType(BuyingController):
|
||||
for d in getlist( obj.doclist, obj.fname):
|
||||
# validation for valid qty
|
||||
if flt(d.qty) < 0 or (d.parenttype != 'Purchase Receipt' and not flt(d.qty)):
|
||||
msgprint("Please enter valid qty for item %s" % cstr(d.item_code))
|
||||
raise Exception
|
||||
webnotes.throw("Please enter valid qty for item %s" % cstr(d.item_code))
|
||||
|
||||
# udpate with latest quantities
|
||||
bin = webnotes.conn.sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
bin = webnotes.conn.sql("""select projected_qty from `tabBin` where
|
||||
item_code = %s and warehouse = %s""", (d.item_code, d.warehouse), as_dict=1)
|
||||
|
||||
f_lst ={'projected_qty': bin and flt(bin[0]['projected_qty']) or 0, 'ordered_qty': 0, 'received_qty' : 0}
|
||||
if d.doctype == 'Purchase Receipt Item':
|
||||
@@ -89,48 +87,50 @@ class DocType(BuyingController):
|
||||
if d.fields.has_key(x):
|
||||
d.fields[x] = f_lst[x]
|
||||
|
||||
item = webnotes.conn.sql("select is_stock_item, is_purchase_item, is_sub_contracted_item, end_of_life from tabItem where name=%s",
|
||||
d.item_code)
|
||||
item = webnotes.conn.sql("""select is_stock_item, is_purchase_item,
|
||||
is_sub_contracted_item, end_of_life from `tabItem` where name=%s""", d.item_code)
|
||||
if not item:
|
||||
msgprint("Item %s does not exist in Item Master." % cstr(d.item_code), raise_exception=True)
|
||||
webnotes.throw("Item %s does not exist in Item Master." % cstr(d.item_code))
|
||||
|
||||
from stock.utils import validate_end_of_life
|
||||
validate_end_of_life(d.item_code, item[0][3])
|
||||
|
||||
# validate stock item
|
||||
if item[0][0]=='Yes' and d.qty and not d.warehouse:
|
||||
msgprint("Warehouse is mandatory for %s, since it is a stock item" %
|
||||
d.item_code, raise_exception=1)
|
||||
webnotes.throw("Warehouse is mandatory for %s, since it is a stock item" % d.item_code)
|
||||
|
||||
# validate purchase item
|
||||
if item[0][1] != 'Yes' and item[0][2] != 'Yes':
|
||||
msgprint("Item %s is not a purchase item or sub-contracted item. Please check" % (d.item_code), raise_exception=True)
|
||||
webnotes.throw("Item %s is not a purchase item or sub-contracted item. Please check" % (d.item_code))
|
||||
|
||||
# list criteria that should not repeat if item is stock item
|
||||
e = [d.schedule_date, d.item_code, d.description, d.warehouse, d.uom, d.fields.has_key('prevdoc_docname') and d.prevdoc_docname or '', d.fields.has_key('prevdoc_detail_docname') and d.prevdoc_detail_docname or '', d.fields.has_key('batch_no') and d.batch_no or '']
|
||||
e = [d.schedule_date, d.item_code, d.description, d.warehouse, d.uom,
|
||||
d.fields.has_key('prevdoc_docname') and d.prevdoc_docname or d.fields.has_key('sales_order_no') and d.sales_order_no or '',
|
||||
d.fields.has_key('prevdoc_detail_docname') and d.prevdoc_detail_docname or '',
|
||||
d.fields.has_key('batch_no') and d.batch_no or '']
|
||||
|
||||
# if is not stock item
|
||||
f = [d.schedule_date, d.item_code, d.description]
|
||||
|
||||
ch = webnotes.conn.sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
|
||||
ch = webnotes.conn.sql("""select is_stock_item from `tabItem` where name = %s""", d.item_code)
|
||||
|
||||
if ch and ch[0][0] == 'Yes':
|
||||
# check for same items
|
||||
if e in check_list:
|
||||
msgprint("""Item %s has been entered more than once with same description, schedule date, warehouse and uom.\n
|
||||
Please change any of the field value to enter the item twice""" % d.item_code, raise_exception = 1)
|
||||
webnotes.throw("""Item %s has been entered more than once with same description, schedule date, warehouse and uom.\n
|
||||
Please change any of the field value to enter the item twice""" % d.item_code)
|
||||
else:
|
||||
check_list.append(e)
|
||||
|
||||
elif ch and ch[0][0] == 'No':
|
||||
# check for same items
|
||||
if f in chk_dupl_itm:
|
||||
msgprint("""Item %s has been entered more than once with same description, schedule date.\n
|
||||
Please change any of the field value to enter the item twice.""" % d.item_code, raise_exception = 1)
|
||||
webnotes.throw("""Item %s has been entered more than once with same description, schedule date.\n
|
||||
Please change any of the field value to enter the item twice.""" % d.item_code)
|
||||
else:
|
||||
chk_dupl_itm.append(f)
|
||||
|
||||
def get_qty(self,curr_doctype,ref_tab_fname,ref_tab_dn,ref_doc_tname, transaction, curr_parent_name):
|
||||
def get_qty(self, curr_doctype, ref_tab_fname, ref_tab_dn, ref_doc_tname, transaction, curr_parent_name):
|
||||
# Get total Quantities of current doctype (eg. PR) except for qty of this transaction
|
||||
#------------------------------
|
||||
# please check as UOM changes from Material Request - Purchase Order ,so doing following else uom should be same .
|
||||
@@ -138,35 +138,37 @@ class DocType(BuyingController):
|
||||
# but if in Material Request uom KG it can change in PO
|
||||
|
||||
get_qty = (transaction == 'Material Request - Purchase Order') and 'qty * conversion_factor' or 'qty'
|
||||
qty = webnotes.conn.sql("select sum(%s) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% ( get_qty, curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
|
||||
qty = webnotes.conn.sql("""select sum(%s) from `tab%s` where %s = %s and
|
||||
docstatus = 1 and parent != %s""" % (get_qty, curr_doctype, ref_tab_fname, '%s', '%s'),
|
||||
(ref_tab_dn, curr_parent_name))
|
||||
qty = qty and flt(qty[0][0]) or 0
|
||||
|
||||
# get total qty of ref doctype
|
||||
#--------------------
|
||||
max_qty = webnotes.conn.sql("select qty from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
|
||||
max_qty = webnotes.conn.sql("""select qty from `tab%s` where name = %s
|
||||
and docstatus = 1""" % (ref_doc_tname, '%s'), ref_tab_dn)
|
||||
max_qty = max_qty and flt(max_qty[0][0]) or 0
|
||||
|
||||
return cstr(qty)+'~~~'+cstr(max_qty)
|
||||
|
||||
def check_for_stopped_status(self, doctype, docname):
|
||||
stopped = webnotes.conn.sql("select name from `tab%s` where name = '%s' and status = 'Stopped'" %
|
||||
( doctype, docname))
|
||||
stopped = webnotes.conn.sql("""select name from `tab%s` where name = %s and
|
||||
status = 'Stopped'""" % (doctype, '%s'), docname)
|
||||
if stopped:
|
||||
msgprint("One cannot do any transaction against %s : %s, it's status is 'Stopped'" %
|
||||
( doctype, docname), raise_exception=1)
|
||||
webnotes.throw("One cannot do any transaction against %s : %s, it's status is 'Stopped'" %
|
||||
(doctype, docname))
|
||||
|
||||
def check_docstatus(self, check, doctype, docname , detail_doctype = ''):
|
||||
def check_docstatus(self, check, doctype, docname, detail_doctype = ''):
|
||||
if check == 'Next':
|
||||
submitted = webnotes.conn.sql("""select t1.name from `tab%s` t1,`tab%s` t2
|
||||
where t1.name = t2.parent and t2.prevdoc_docname = %s and t1.docstatus = 1"""
|
||||
% (doctype, detail_doctype, '%s'), docname)
|
||||
if submitted:
|
||||
msgprint(cstr(doctype) + ": " + cstr(submitted[0][0])
|
||||
+ _(" has already been submitted."), raise_exception=1)
|
||||
webnotes.throw(cstr(doctype) + ": " + cstr(submitted[0][0])
|
||||
+ _("has already been submitted."))
|
||||
|
||||
if check == 'Previous':
|
||||
submitted = webnotes.conn.sql("""select name from `tab%s`
|
||||
where docstatus = 1 and name = %s"""% (doctype, '%s'), docname)
|
||||
where docstatus = 1 and name = %s""" % (doctype, '%s'), docname)
|
||||
if not submitted:
|
||||
msgprint(cstr(doctype) + ": " + cstr(submitted[0][0])
|
||||
+ _(" not submitted"), raise_exception=1)
|
||||
webnotes.throw(cstr(doctype) + ": " + cstr(submitted[0][0]) + _("not submitted"))
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
|
||||
pr = make_purchase_receipt(po.doc.name)
|
||||
pr[0]["supplier_warehouse"] = "_Test Warehouse 1 - _TC"
|
||||
|
||||
pr[0]["posting_date"] = "2013-05-12"
|
||||
self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
|
||||
self.assertEquals(len(pr), len(test_records[0]))
|
||||
|
||||
@@ -52,7 +52,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
|
||||
self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
|
||||
self.assertEquals(len(pr), len(test_records[0]))
|
||||
|
||||
pr[0]["posting_date"] = "2013-05-12"
|
||||
pr[0].naming_series = "_T-Purchase Receipt-"
|
||||
pr[1].qty = 4.0
|
||||
pr_bean = webnotes.bean(pr)
|
||||
@@ -66,6 +66,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
|
||||
pr1 = make_purchase_receipt(po.doc.name)
|
||||
pr1[0].naming_series = "_T-Purchase Receipt-"
|
||||
pr1[0]["posting_date"] = "2013-05-12"
|
||||
pr1[1].qty = 8
|
||||
pr1_bean = webnotes.bean(pr1)
|
||||
pr1_bean.insert()
|
||||
@@ -88,7 +89,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
|
||||
self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
|
||||
self.assertEquals(len(pi), len(test_records[0]))
|
||||
|
||||
pi[0]["posting_date"] = "2013-05-12"
|
||||
pi[0].bill_no = "NA"
|
||||
webnotes.bean(pi).insert()
|
||||
|
||||
|
||||
@@ -95,6 +95,6 @@ cur_frm.cscript.make_contact = function() {
|
||||
|
||||
cur_frm.fields_dict['default_price_list'].get_query = function(doc,cdt,cdn) {
|
||||
return{
|
||||
filters:{'buying_or_selling': "Buying"}
|
||||
filters:{'buying': 1}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-21 16:16:45",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-22 17:16:16",
|
||||
"modified": "2013-12-14 17:27:47",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -632,6 +632,7 @@
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "supplier",
|
||||
"role": "Supplier",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _
|
||||
from webnotes import msgprint, _, throw
|
||||
from webnotes.utils import getdate, flt, add_days, cstr
|
||||
import json
|
||||
|
||||
@@ -90,7 +90,7 @@ def _get_price_list_rate(args, item_bean, meta):
|
||||
# try fetching from price list
|
||||
if args.buying_price_list and args.price_list_currency:
|
||||
price_list_rate = webnotes.conn.sql("""select ref_rate from `tabItem Price`
|
||||
where price_list=%s and item_code=%s and buying_or_selling='Buying'""",
|
||||
where price_list=%s and item_code=%s and buying=1""",
|
||||
(args.buying_price_list, args.item_code), as_dict=1)
|
||||
|
||||
if price_list_rate:
|
||||
@@ -122,14 +122,12 @@ def _validate_item_details(args, item):
|
||||
|
||||
# validate if purchase item or subcontracted item
|
||||
if item.is_purchase_item != "Yes":
|
||||
msgprint(_("Item") + (" %s: " % item.name) + _("not a purchase item"),
|
||||
raise_exception=True)
|
||||
throw(_("Item") + (" %s: " % item.name) + _("not a purchase item"))
|
||||
|
||||
if args.is_subcontracted == "Yes" and item.is_sub_contracted_item != "Yes":
|
||||
msgprint(_("Item") + (" %s: " % item.name) +
|
||||
throw(_("Item") + (" %s: " % item.name) +
|
||||
_("not a sub-contracted item.") +
|
||||
_("Please select a sub-contracted item or do not sub-contract the transaction."),
|
||||
raise_exception=True)
|
||||
_("Please select a sub-contracted item or do not sub-contract the transaction."))
|
||||
|
||||
def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
|
||||
"""returns last purchase details in stock uom"""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"app_name": "ERPNext",
|
||||
"app_version": "3.2.2",
|
||||
"app_version": "3.6.3",
|
||||
"base_template": "app/portal/templates/base.html",
|
||||
"modules": {
|
||||
"Accounts": {
|
||||
@@ -74,5 +74,5 @@
|
||||
"type": "module"
|
||||
}
|
||||
},
|
||||
"requires_framework_version": "==3.2.0"
|
||||
"requires_framework_version": "==3.7.3"
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _, msgprint
|
||||
from webnotes import _, throw
|
||||
from webnotes.utils import flt, cint, today, cstr
|
||||
from webnotes.model.code import get_obj
|
||||
from setup.utils import get_company_currency
|
||||
@@ -44,14 +44,13 @@ class AccountsController(TransactionBase):
|
||||
def validate_for_freezed_account(self):
|
||||
for fieldname in ["customer", "supplier"]:
|
||||
if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname):
|
||||
accounts = webnotes.conn.get_values("Account", {"master_type": fieldname.title(),
|
||||
"master_name": self.doc.fields[fieldname], "company": self.doc.company},
|
||||
"freeze_account", as_dict=1)
|
||||
|
||||
accounts = webnotes.conn.get_values("Account",
|
||||
{"master_type": fieldname.title(), "master_name": self.doc.fields[fieldname],
|
||||
"company": self.doc.company}, "name")
|
||||
if accounts:
|
||||
if not filter(lambda x: cstr(x.freeze_account) in ["", "No"], accounts):
|
||||
msgprint(_("Account for this ") + fieldname + _(" has been freezed. ") +
|
||||
self.doc.doctype + _(" can not be made."), raise_exception=1)
|
||||
from accounts.doctype.gl_entry.gl_entry import validate_frozen_account
|
||||
for account in accounts:
|
||||
validate_frozen_account(account[0])
|
||||
|
||||
def set_price_list_currency(self, buying_or_selling):
|
||||
if self.meta.get_field("currency"):
|
||||
@@ -179,17 +178,17 @@ class AccountsController(TransactionBase):
|
||||
"""
|
||||
if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"] and \
|
||||
(not tax.row_id or cint(tax.row_id) >= tax.idx):
|
||||
msgprint((_("Row") + " # %(idx)s [%(taxes_doctype)s]: " + \
|
||||
throw((_("Row") + " # %(idx)s [%(taxes_doctype)s]: " + \
|
||||
_("Please specify a valid") + " %(row_id_label)s") % {
|
||||
"idx": tax.idx,
|
||||
"taxes_doctype": tax.doctype,
|
||||
"row_id_label": self.meta.get_label("row_id",
|
||||
parentfield=self.other_fname)
|
||||
}, raise_exception=True)
|
||||
})
|
||||
|
||||
def validate_inclusive_tax(self, tax):
|
||||
def _on_previous_row_error(row_range):
|
||||
msgprint((_("Row") + " # %(idx)s [%(doctype)s]: " +
|
||||
throw((_("Row") + " # %(idx)s [%(doctype)s]: " +
|
||||
_("to be included in Item's rate, it is required that: ") +
|
||||
" [" + _("Row") + " # %(row_range)s] " + _("also be included in Item's rate")) % {
|
||||
"idx": tax.idx,
|
||||
@@ -200,12 +199,12 @@ class AccountsController(TransactionBase):
|
||||
parentfield=self.other_fname),
|
||||
"charge_type": tax.charge_type,
|
||||
"row_range": row_range
|
||||
}, raise_exception=True)
|
||||
})
|
||||
|
||||
if cint(tax.included_in_print_rate):
|
||||
if tax.charge_type == "Actual":
|
||||
# inclusive tax cannot be of type Actual
|
||||
msgprint((_("Row")
|
||||
throw((_("Row")
|
||||
+ " # %(idx)s [%(doctype)s]: %(charge_type_label)s = \"%(charge_type)s\" "
|
||||
+ "cannot be included in Item's rate") % {
|
||||
"idx": tax.idx,
|
||||
@@ -213,7 +212,7 @@ class AccountsController(TransactionBase):
|
||||
"charge_type_label": self.meta.get_label("charge_type",
|
||||
parentfield=self.other_fname),
|
||||
"charge_type": tax.charge_type,
|
||||
}, raise_exception=True)
|
||||
})
|
||||
elif tax.charge_type == "On Previous Row Amount" and \
|
||||
not cint(self.tax_doclist[tax.row_id - 1].included_in_print_rate):
|
||||
# referred row should also be inclusive
|
||||
@@ -224,23 +223,22 @@ class AccountsController(TransactionBase):
|
||||
_on_previous_row_error("1 - %d" % (tax.row_id,))
|
||||
|
||||
def calculate_taxes(self):
|
||||
for item in self.item_doclist:
|
||||
# maintain actual tax rate based on idx
|
||||
actual_tax_dict = dict([[tax.idx, tax.rate] for tax in self.tax_doclist
|
||||
if tax.charge_type == "Actual"])
|
||||
|
||||
for n, item in enumerate(self.item_doclist):
|
||||
item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
|
||||
|
||||
for i, tax in enumerate(self.tax_doclist):
|
||||
# tax_amount represents the amount of tax for the current step
|
||||
current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map)
|
||||
|
||||
if hasattr(self, "set_item_tax_amount"):
|
||||
self.set_item_tax_amount(item, tax, current_tax_amount)
|
||||
|
||||
# case when net total is 0 but there is an actual type charge
|
||||
# in this case add the actual amount to tax.tax_amount
|
||||
# and tax.grand_total_for_current_item for the first such iteration
|
||||
if tax.charge_type=="Actual" and \
|
||||
not (current_tax_amount or self.doc.net_total or tax.tax_amount):
|
||||
zero_net_total_adjustment = flt(tax.rate, self.precision("tax_amount", tax))
|
||||
current_tax_amount += zero_net_total_adjustment
|
||||
|
||||
# Adjust divisional loss to the last item
|
||||
if tax.charge_type == "Actual":
|
||||
actual_tax_dict[tax.idx] -= current_tax_amount
|
||||
if n == len(self.item_doclist) - 1:
|
||||
current_tax_amount += actual_tax_dict[tax.idx]
|
||||
|
||||
# store tax_amount for current item as it will be used for
|
||||
# charge type = 'On Previous Row Amount'
|
||||
@@ -252,7 +250,8 @@ class AccountsController(TransactionBase):
|
||||
if tax.category:
|
||||
# if just for valuation, do not add the tax amount in total
|
||||
# hence, setting it as 0 for further steps
|
||||
current_tax_amount = 0.0 if (tax.category == "Valuation") else current_tax_amount
|
||||
current_tax_amount = 0.0 if (tax.category == "Valuation") \
|
||||
else current_tax_amount
|
||||
|
||||
current_tax_amount *= -1.0 if (tax.add_deduct_tax == "Deduct") else 1.0
|
||||
|
||||
@@ -271,6 +270,11 @@ class AccountsController(TransactionBase):
|
||||
# in tax.total, accumulate grand total of each item
|
||||
tax.total += tax.grand_total_for_current_item
|
||||
|
||||
# set precision in the last item iteration
|
||||
if n == len(self.item_doclist) - 1:
|
||||
tax.total = flt(tax.total, self.precision("total", tax))
|
||||
tax.tax_amount = flt(tax.tax_amount, self.precision("tax_amount", tax))
|
||||
|
||||
def get_current_tax_amount(self, item, tax, item_tax_map):
|
||||
tax_rate = self._get_tax_rate(tax, item_tax_map)
|
||||
current_tax_amount = 0.0
|
||||
@@ -384,24 +388,45 @@ class AccountsController(TransactionBase):
|
||||
})
|
||||
|
||||
def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield):
|
||||
from controllers.status_updater import get_tolerance_for
|
||||
item_tolerance = {}
|
||||
global_tolerance = None
|
||||
|
||||
for item in self.doclist.get({"parentfield": "entries"}):
|
||||
if item.fields.get(item_ref_dn):
|
||||
already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
|
||||
where %s=%s and docstatus=1""" % (based_on, self.tname, item_ref_dn, '%s'),
|
||||
item.fields[item_ref_dn])[0][0]
|
||||
|
||||
max_allowed_amt = flt(webnotes.conn.get_value(ref_dt + " Item",
|
||||
ref_amt = flt(webnotes.conn.get_value(ref_dt + " Item",
|
||||
item.fields[item_ref_dn], based_on), self.precision(based_on, item))
|
||||
if not ref_amt:
|
||||
webnotes.msgprint(_("As amount for item") + ": " + item.item_code + _(" in ") +
|
||||
ref_dt + _(" is zero, system will not check for over-billed"))
|
||||
else:
|
||||
already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
|
||||
where %s=%s and docstatus=1 and parent != %s""" %
|
||||
(based_on, self.tname, item_ref_dn, '%s', '%s'),
|
||||
(item.fields[item_ref_dn], self.doc.name))[0][0]
|
||||
|
||||
total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]),
|
||||
self.precision(based_on, item))
|
||||
total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]),
|
||||
self.precision(based_on, item))
|
||||
|
||||
tolerance, item_tolerance, global_tolerance = get_tolerance_for(item.item_code,
|
||||
item_tolerance, global_tolerance)
|
||||
|
||||
if max_allowed_amt and total_billed_amt - max_allowed_amt > 0.02:
|
||||
webnotes.msgprint(_("Row ")+ cstr(item.idx) + ": " + cstr(item.item_code) +
|
||||
_(" will be over-billed against mentioned ") + cstr(ref_dt) +
|
||||
_(". Max allowed " + cstr(based_on) + ": " + cstr(max_allowed_amt)),
|
||||
raise_exception=1)
|
||||
|
||||
max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100)
|
||||
|
||||
if total_billed_amt - max_allowed_amt > 0.01:
|
||||
reduce_by = total_billed_amt - max_allowed_amt
|
||||
|
||||
webnotes.throw(_("Row #") + cstr(item.idx) + ": " +
|
||||
_(" Max amount allowed for Item ") + cstr(item.item_code) +
|
||||
_(" against ") + ref_dt + " " +
|
||||
cstr(item.fields[ref_dt.lower().replace(" ", "_")]) + _(" is ") +
|
||||
cstr(max_allowed_amt) + ". \n" +
|
||||
_("""If you want to increase your overflow tolerance, please increase \
|
||||
tolerance % in Global Defaults or Item master.
|
||||
Or, you must reduce the amount by """) + cstr(reduce_by) + "\n" +
|
||||
_("""Also, please check if the order item has already been billed \
|
||||
in the Sales Order"""))
|
||||
|
||||
def get_company_default(self, fieldname):
|
||||
from accounts.utils import get_company_default
|
||||
return get_company_default(self.doc.company, fieldname)
|
||||
|
||||
@@ -108,10 +108,11 @@ class BuyingController(StockController):
|
||||
item.import_amount = flt(item.import_rate * item.qty,
|
||||
self.precision("import_amount", item))
|
||||
item.item_tax_amount = 0.0;
|
||||
|
||||
|
||||
self._set_in_company_currency(item, "import_amount", "amount")
|
||||
self._set_in_company_currency(item, "import_ref_rate", "purchase_ref_rate")
|
||||
self._set_in_company_currency(item, "import_rate", "rate")
|
||||
self._set_in_company_currency(item, "import_amount", "amount")
|
||||
|
||||
|
||||
def calculate_net_total(self):
|
||||
self.doc.net_total = self.doc.net_total_import = 0.0
|
||||
@@ -123,8 +124,8 @@ class BuyingController(StockController):
|
||||
self.round_floats_in(self.doc, ["net_total", "net_total_import"])
|
||||
|
||||
def calculate_totals(self):
|
||||
self.doc.grand_total = flt(self.tax_doclist and \
|
||||
self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total"))
|
||||
self.doc.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist
|
||||
else self.doc.net_total, self.precision("grand_total"))
|
||||
self.doc.grand_total_import = flt(self.doc.grand_total / self.doc.conversion_rate,
|
||||
self.precision("grand_total_import"))
|
||||
|
||||
@@ -136,6 +137,24 @@ class BuyingController(StockController):
|
||||
|
||||
if self.meta.get_field("rounded_total_import"):
|
||||
self.doc.rounded_total_import = _round(self.doc.grand_total_import)
|
||||
|
||||
if self.meta.get_field("other_charges_added"):
|
||||
self.doc.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.tax_doclist
|
||||
if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]),
|
||||
self.precision("other_charges_added"))
|
||||
|
||||
if self.meta.get_field("other_charges_deducted"):
|
||||
self.doc.other_charges_deducted = flt(sum([flt(d.tax_amount) for d in self.tax_doclist
|
||||
if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]),
|
||||
self.precision("other_charges_deducted"))
|
||||
|
||||
if self.meta.get_field("other_charges_added_import"):
|
||||
self.doc.other_charges_added_import = flt(self.doc.other_charges_added /
|
||||
self.doc.conversion_rate, self.precision("other_charges_added_import"))
|
||||
|
||||
if self.meta.get_field("other_charges_deducted_import"):
|
||||
self.doc.other_charges_deducted_import = flt(self.doc.other_charges_deducted /
|
||||
self.doc.conversion_rate, self.precision("other_charges_deducted_import"))
|
||||
|
||||
def calculate_outstanding_amount(self):
|
||||
if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus < 2:
|
||||
@@ -162,35 +181,52 @@ class BuyingController(StockController):
|
||||
if not self.meta.get_field("item_tax_amount", parentfield=self.fname):
|
||||
for item in self.item_doclist:
|
||||
del item.fields["item_tax_amount"]
|
||||
|
||||
def set_item_tax_amount(self, item, tax, current_tax_amount):
|
||||
|
||||
# update valuation rate
|
||||
def update_valuation_rate(self, parentfield):
|
||||
"""
|
||||
item_tax_amount is the total tax amount applied on that item
|
||||
stored for valuation
|
||||
|
||||
TODO: rename item_tax_amount to valuation_tax_amount
|
||||
"""
|
||||
if tax.category in ["Valuation", "Valuation and Total"] and \
|
||||
self.meta.get_field("item_tax_amount", parentfield=self.fname):
|
||||
item.item_tax_amount += flt(current_tax_amount, self.precision("item_tax_amount", item))
|
||||
|
||||
# update valuation rate
|
||||
def update_valuation_rate(self, parentfield):
|
||||
for item in self.doclist.get({"parentfield": parentfield}):
|
||||
item.conversion_factor = item.conversion_factor or flt(webnotes.conn.get_value(
|
||||
"UOM Conversion Detail", {"parent": item.item_code, "uom": item.uom},
|
||||
"conversion_factor")) or 1
|
||||
stock_items = self.get_stock_items()
|
||||
|
||||
stock_items_qty, stock_items_amount = 0, 0
|
||||
last_stock_item_idx = 1
|
||||
for d in self.doclist.get({"parentfield": parentfield}):
|
||||
if d.item_code and d.item_code in stock_items:
|
||||
stock_items_qty += flt(d.qty)
|
||||
stock_items_amount += flt(d.amount)
|
||||
last_stock_item_idx = d.idx
|
||||
|
||||
if item.item_code and item.qty:
|
||||
total_valuation_amount = sum([flt(d.tax_amount) for d in
|
||||
self.doclist.get({"parentfield": "purchase_tax_details"})
|
||||
if d.category in ["Valuation", "Valuation and Total"]])
|
||||
|
||||
|
||||
valuation_amount_adjustment = total_valuation_amount
|
||||
for i, item in enumerate(self.doclist.get({"parentfield": parentfield})):
|
||||
if item.item_code and item.qty and item.item_code in stock_items:
|
||||
item_proportion = flt(item.amount) / stock_items_amount if stock_items_amount \
|
||||
else flt(item.qty) / stock_items_qty
|
||||
|
||||
if i == (last_stock_item_idx - 1):
|
||||
item.item_tax_amount = flt(valuation_amount_adjustment,
|
||||
self.precision("item_tax_amount", item))
|
||||
else:
|
||||
item.item_tax_amount = flt(item_proportion * total_valuation_amount,
|
||||
self.precision("item_tax_amount", item))
|
||||
valuation_amount_adjustment -= item.item_tax_amount
|
||||
|
||||
self.round_floats_in(item)
|
||||
|
||||
purchase_rate = item.rate if self.doc.doctype == "Purchase Invoice" else item.purchase_rate
|
||||
|
||||
# if no item code, which is sometimes the case in purchase invoice,
|
||||
# then it is not possible to track valuation against it
|
||||
item.valuation_rate = flt((purchase_rate +
|
||||
(item.item_tax_amount + item.rm_supp_cost) / item.qty) / item.conversion_factor,
|
||||
self.precision("valuation_rate", item))
|
||||
item.conversion_factor = item.conversion_factor or flt(webnotes.conn.get_value(
|
||||
"UOM Conversion Detail", {"parent": item.item_code, "uom": item.uom},
|
||||
"conversion_factor")) or 1
|
||||
qty_in_stock_uom = flt(item.qty * item.conversion_factor)
|
||||
item.valuation_rate = ((item.amount + item.item_tax_amount + item.rm_supp_cost)
|
||||
/ qty_in_stock_uom)
|
||||
else:
|
||||
item.valuation_rate = 0.0
|
||||
|
||||
|
||||
@@ -191,7 +191,8 @@ class SellingController(StockController):
|
||||
|
||||
self.doc.other_charges_total = flt(self.doc.grand_total - self.doc.net_total,
|
||||
self.precision("other_charges_total"))
|
||||
self.doc.other_charges_total_export = flt(self.doc.grand_total_export - self.doc.net_total_export,
|
||||
self.doc.other_charges_total_export = flt(
|
||||
self.doc.grand_total_export - self.doc.net_total_export,
|
||||
self.precision("other_charges_total_export"))
|
||||
|
||||
self.doc.rounded_total = _round(self.doc.grand_total)
|
||||
@@ -205,8 +206,8 @@ class SellingController(StockController):
|
||||
self.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount",
|
||||
"paid_amount"])
|
||||
total_amount_to_pay = self.doc.grand_total - self.doc.write_off_amount
|
||||
self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance - self.doc.paid_amount,
|
||||
self.precision("outstanding_amount"))
|
||||
self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance \
|
||||
- self.doc.paid_amount, self.precision("outstanding_amount"))
|
||||
|
||||
def calculate_commission(self):
|
||||
if self.meta.get_field("commission_rate"):
|
||||
|
||||
@@ -151,7 +151,9 @@ class StatusUpdater(DocListController):
|
||||
"""
|
||||
|
||||
# check if overflow is within tolerance
|
||||
tolerance = self.get_tolerance_for(item['item_code'])
|
||||
tolerance, self.tolerance, self.global_tolerance = get_tolerance_for(item['item_code'],
|
||||
self.tolerance, self.global_tolerance)
|
||||
|
||||
overflow_percent = ((item[args['target_field']] - item[args['target_ref_field']]) /
|
||||
item[args['target_ref_field']]) * 100
|
||||
|
||||
@@ -170,23 +172,6 @@ class StatusUpdater(DocListController):
|
||||
|
||||
Also, please check if the order item has already been billed in the Sales Order""" %
|
||||
item, raise_exception=1)
|
||||
|
||||
def get_tolerance_for(self, item_code):
|
||||
"""
|
||||
Returns the tolerance for the item, if not set, returns global tolerance
|
||||
"""
|
||||
if self.tolerance.get(item_code): return self.tolerance[item_code]
|
||||
|
||||
tolerance = flt(webnotes.conn.get_value('Item',item_code,'tolerance') or 0)
|
||||
|
||||
if not tolerance:
|
||||
if self.global_tolerance == None:
|
||||
self.global_tolerance = flt(webnotes.conn.get_value('Global Defaults', None,
|
||||
'tolerance'))
|
||||
tolerance = self.global_tolerance
|
||||
|
||||
self.tolerance[item_code] = tolerance
|
||||
return tolerance
|
||||
|
||||
|
||||
def update_qty(self, change_modified=True):
|
||||
@@ -245,4 +230,59 @@ class StatusUpdater(DocListController):
|
||||
set %(status_field)s = if(ifnull(%(target_parent_field)s,0)<0.001,
|
||||
'Not %(keyword)s', if(%(target_parent_field)s>=99.99,
|
||||
'Fully %(keyword)s', 'Partly %(keyword)s'))
|
||||
where name='%(name)s'""" % args)
|
||||
where name='%(name)s'""" % args)
|
||||
|
||||
|
||||
def update_billing_status_for_zero_amount_refdoc(self, ref_dt):
|
||||
ref_fieldname = ref_dt.lower().replace(" ", "_")
|
||||
zero_amount_refdoc = []
|
||||
all_zero_amount_refdoc = webnotes.conn.sql_list("""select name from `tab%s`
|
||||
where docstatus=1 and net_total = 0""" % ref_dt)
|
||||
|
||||
for item in self.doclist.get({"parentfield": "entries"}):
|
||||
if item.fields.get(ref_fieldname) \
|
||||
and item.fields.get(ref_fieldname) in all_zero_amount_refdoc \
|
||||
and item.fields.get(ref_fieldname) not in zero_amount_refdoc:
|
||||
zero_amount_refdoc.append(item.fields[ref_fieldname])
|
||||
|
||||
if zero_amount_refdoc:
|
||||
self.update_biling_status(zero_amount_refdoc, ref_dt, ref_fieldname)
|
||||
|
||||
def update_biling_status(self, zero_amount_refdoc, ref_dt, ref_fieldname):
|
||||
for ref_dn in zero_amount_refdoc:
|
||||
ref_doc_qty = flt(webnotes.conn.sql("""select sum(ifnull(qty, 0)) from `tab%s Item`
|
||||
where parent=%s""" % (ref_dt, '%s'), (ref_dn))[0][0])
|
||||
|
||||
billed_qty = flt(webnotes.conn.sql("""select sum(ifnull(qty, 0))
|
||||
from `tab%s Item` where %s=%s and docstatus=1""" %
|
||||
(self.doc.doctype, ref_fieldname, '%s'), (ref_dn))[0][0])
|
||||
|
||||
per_billed = ((ref_doc_qty if billed_qty > ref_doc_qty else billed_qty)\
|
||||
/ ref_doc_qty)*100
|
||||
webnotes.conn.set_value(ref_dt, ref_dn, "per_billed", per_billed)
|
||||
|
||||
from webnotes.model.meta import has_field
|
||||
if has_field(ref_dt, "billing_status"):
|
||||
if per_billed < 0.001: billing_status = "Not Billed"
|
||||
elif per_billed >= 99.99: billing_status = "Fully Billed"
|
||||
else: billing_status = "Partly Billed"
|
||||
|
||||
webnotes.conn.set_value(ref_dt, ref_dn, "billing_status", billing_status)
|
||||
|
||||
def get_tolerance_for(item_code, item_tolerance={}, global_tolerance=None):
|
||||
"""
|
||||
Returns the tolerance for the item, if not set, returns global tolerance
|
||||
"""
|
||||
if item_tolerance.get(item_code):
|
||||
return item_tolerance[item_code], item_tolerance, global_tolerance
|
||||
|
||||
tolerance = flt(webnotes.conn.get_value('Item',item_code,'tolerance') or 0)
|
||||
|
||||
if not tolerance:
|
||||
if global_tolerance == None:
|
||||
global_tolerance = flt(webnotes.conn.get_value('Global Defaults', None,
|
||||
'tolerance'))
|
||||
tolerance = global_tolerance
|
||||
|
||||
item_tolerance[item_code] = tolerance
|
||||
return tolerance, item_tolerance, global_tolerance
|
||||
@@ -43,7 +43,7 @@ cur_frm.cscript.make_jv = function(doc, dt, dn) {
|
||||
jv = locals['Journal Voucher'][jv];
|
||||
jv.voucher_type = 'Bank Voucher';
|
||||
jv.user_remark = wn._('Payment of salary for the month: ') + doc.month +
|
||||
wn._('and fiscal year: ') + doc.fiscal_year;
|
||||
wn._(' and fiscal year: ') + doc.fiscal_year;
|
||||
jv.fiscal_year = doc.fiscal_year;
|
||||
jv.company = doc.company;
|
||||
jv.posting_date = dateutil.obj_to_str(new Date());
|
||||
|
||||
@@ -7,7 +7,7 @@ wn.query_reports["Monthly Salary Register"] = {
|
||||
"fieldname":"month",
|
||||
"label": wn._("Month"),
|
||||
"fieldtype": "Select",
|
||||
"options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
|
||||
"options": "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
|
||||
"default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
|
||||
"Dec"][wn.datetime.str_to_obj(wn.datetime.get_today()).getMonth()],
|
||||
},
|
||||
|
||||
@@ -50,17 +50,17 @@ def get_columns(salary_slips):
|
||||
where ifnull(d_modified_amount, 0) != 0 and parent in (%s)""" %
|
||||
(', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]))
|
||||
|
||||
columns = columns + [(e + ":Link/Earning Type:120") for e in earning_types] + \
|
||||
columns = columns + [(e + ":Currency:120") for e in earning_types] + \
|
||||
["Arrear Amount:Currency:120", "Leave Encashment Amount:Currency:150",
|
||||
"Gross Pay:Currency:120"] + [(d + ":Link/Deduction Type:120") for d in ded_types] + \
|
||||
"Gross Pay:Currency:120"] + [(d + ":Currency:120") for d in ded_types] + \
|
||||
["Total Deduction:Currency:120", "Net Pay:Currency:120"]
|
||||
|
||||
return columns, earning_types, ded_types
|
||||
|
||||
def get_salary_slips(filters):
|
||||
conditions, filters = get_conditions(filters)
|
||||
salary_slips = webnotes.conn.sql("""select * from `tabSalary Slip` where docstatus = 1 %s""" %
|
||||
conditions, filters, as_dict=1)
|
||||
salary_slips = webnotes.conn.sql("""select * from `tabSalary Slip` where docstatus = 1 %s
|
||||
order by employee, month""" % conditions, filters, as_dict=1)
|
||||
|
||||
if not salary_slips:
|
||||
msgprint(_("No salary slip found for month: ") + cstr(filters.get("month")) +
|
||||
@@ -102,6 +102,6 @@ def get_ss_ded_map(salary_slips):
|
||||
ss_ded_map = {}
|
||||
for d in ss_deductions:
|
||||
ss_ded_map.setdefault(d.parent, webnotes._dict()).setdefault(d.d_type, [])
|
||||
ss_ded_map[d.parent][d.e_type] = flt(d.d_modified_amount)
|
||||
ss_ded_map[d.parent][d.d_type] = flt(d.d_modified_amount)
|
||||
|
||||
return ss_ded_map
|
||||
@@ -5,6 +5,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import os, sys
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
is_redhat = is_debian = None
|
||||
root_password = None
|
||||
@@ -19,7 +20,7 @@ requirements = [
|
||||
"jinja2",
|
||||
"markdown2",
|
||||
"markupsafe",
|
||||
"mysql-python",
|
||||
"mysql-python",
|
||||
"pygeoip",
|
||||
"python-dateutil",
|
||||
"python-memcached",
|
||||
@@ -80,7 +81,7 @@ def validate_install():
|
||||
return is_redhat, is_debian
|
||||
|
||||
def install_using_yum():
|
||||
packages = "python python-setuptools gcc python-devel MySQL-python git memcached ntp vim-enhanced screen"
|
||||
packages = "gcc MySQL-python git memcached ntp vim-enhanced screen"
|
||||
|
||||
print "-"*80
|
||||
print "Installing Packages: (This may take some time)"
|
||||
@@ -88,7 +89,10 @@ def install_using_yum():
|
||||
print "-"*80
|
||||
exec_in_shell("yum install -y %s" % packages)
|
||||
|
||||
if not exec_in_shell("which mysql"):
|
||||
|
||||
try:
|
||||
exec_in_shell("which mysql")
|
||||
except subprocess.CalledProcessError:
|
||||
packages = "mysql mysql-server mysql-devel"
|
||||
print "Installing Packages:", packages
|
||||
exec_in_shell("yum install -y %s" % packages)
|
||||
@@ -101,26 +105,19 @@ def install_using_yum():
|
||||
exec_in_shell('mysqladmin -u root password "%s"' % (root_password,))
|
||||
print "Root password set as", root_password
|
||||
|
||||
# install htop
|
||||
if not exec_in_shell("which htop"):
|
||||
try:
|
||||
exec_in_shell("cd /tmp && rpm -i --force http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm && yum install -y htop")
|
||||
except:
|
||||
pass
|
||||
|
||||
update_config_for_redhat()
|
||||
|
||||
def update_config_for_redhat():
|
||||
import re
|
||||
|
||||
# set to autostart on startup
|
||||
for service in ("mysqld", "memcached", "ntpd"):
|
||||
for service in ("mysqld", "memcached"):
|
||||
exec_in_shell("chkconfig --level 2345 %s on" % service)
|
||||
exec_in_shell("service %s restart" % service)
|
||||
|
||||
def install_using_apt():
|
||||
exec_in_shell("apt-get update")
|
||||
packages = "python python-setuptools python-dev build-essential python-pip python-mysqldb git memcached ntp vim screen htop"
|
||||
packages = "python python-setuptools python-dev build-essential python-mysqldb git memcached ntp vim screen htop"
|
||||
print "-"*80
|
||||
print "Installing Packages: (This may take some time)"
|
||||
print packages
|
||||
@@ -132,7 +129,9 @@ def install_using_apt():
|
||||
exec_in_shell("echo mysql-server mysql-server/root_password password %s | sudo debconf-set-selections" % root_password)
|
||||
exec_in_shell("echo mysql-server mysql-server/root_password_again password %s | sudo debconf-set-selections" % root_password)
|
||||
|
||||
if not exec_in_shell("which mysql"):
|
||||
try:
|
||||
exec_in_shell("which mysql")
|
||||
except subprocess.CalledProcessError:
|
||||
packages = "mysql-server libmysqlclient-dev"
|
||||
print "Installing Packages:", packages
|
||||
exec_in_shell("apt-get install -y %s" % packages)
|
||||
@@ -140,7 +139,7 @@ def install_using_apt():
|
||||
update_config_for_debian()
|
||||
|
||||
def update_config_for_debian():
|
||||
for service in ("mysql", "ntpd"):
|
||||
for service in ("mysql",):
|
||||
exec_in_shell("service %s restart" % service)
|
||||
|
||||
def install_python_modules():
|
||||
@@ -148,13 +147,14 @@ def install_python_modules():
|
||||
print "Installing Python Modules: (This may take some time)"
|
||||
print "-"*80
|
||||
|
||||
if not exec_in_shell("which pip"):
|
||||
exec_in_shell("easy_install pip")
|
||||
try:
|
||||
exec_in_shell("which pip2.7")
|
||||
except subprocess.CalledProcessError:
|
||||
exec_in_shell("easy_install-2.7 pip")
|
||||
|
||||
exec_in_shell("pip install --upgrade pip")
|
||||
exec_in_shell("pip install --upgrade setuptools")
|
||||
exec_in_shell("pip install --upgrade virtualenv")
|
||||
exec_in_shell("pip install {}".format(' '.join(requirements)))
|
||||
exec_in_shell("pip2.7 install --upgrade setuptools --no-use-wheel")
|
||||
exec_in_shell("pip2.7 install --upgrade setuptools")
|
||||
exec_in_shell("pip2.7 install {}".format(' '.join(requirements)))
|
||||
|
||||
def install_erpnext(install_path):
|
||||
print
|
||||
@@ -200,7 +200,7 @@ def setup_folders(install_path):
|
||||
app = os.path.join(install_path, "app")
|
||||
if not os.path.exists(app):
|
||||
print "Cloning erpnext"
|
||||
exec_in_shell("cd %s && git clone https://github.com/webnotes/erpnext.git app" % install_path)
|
||||
exec_in_shell("cd %s && git clone --branch master https://github.com/webnotes/erpnext.git app" % install_path)
|
||||
exec_in_shell("cd app && git config core.filemode false")
|
||||
if not os.path.exists(app):
|
||||
raise Exception, "Couldn't clone erpnext repository"
|
||||
@@ -208,7 +208,7 @@ def setup_folders(install_path):
|
||||
lib = os.path.join(install_path, "lib")
|
||||
if not os.path.exists(lib):
|
||||
print "Cloning wnframework"
|
||||
exec_in_shell("cd %s && git clone https://github.com/webnotes/wnframework.git lib" % install_path)
|
||||
exec_in_shell("cd %s && git clone --branch master https://github.com/webnotes/wnframework.git lib" % install_path)
|
||||
exec_in_shell("cd lib && git config core.filemode false")
|
||||
if not os.path.exists(lib):
|
||||
raise Exception, "Couldn't clone wnframework repository"
|
||||
@@ -243,28 +243,8 @@ def post_install(install_path):
|
||||
|
||||
def exec_in_shell(cmd):
|
||||
# using Popen instead of os.system - as recommended by python docs
|
||||
from subprocess import Popen
|
||||
import tempfile
|
||||
|
||||
with tempfile.TemporaryFile() as stdout:
|
||||
with tempfile.TemporaryFile() as stderr:
|
||||
p = Popen(cmd, shell=True, stdout=stdout, stderr=stderr)
|
||||
p.wait()
|
||||
|
||||
stdout.seek(0)
|
||||
out = stdout.read()
|
||||
if out: out = out.decode('utf-8')
|
||||
|
||||
stderr.seek(0)
|
||||
err = stderr.read()
|
||||
if err: err = err.decode('utf-8')
|
||||
|
||||
if err and any((kw in err.lower() for kw in ["traceback", "error", "exception"])):
|
||||
print out
|
||||
raise Exception, err
|
||||
else:
|
||||
print "."
|
||||
|
||||
import subprocess
|
||||
out = subprocess.check_output(cmd, shell=True)
|
||||
return out
|
||||
|
||||
def parse_args():
|
||||
|
||||
@@ -1,28 +1,56 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
if (!doc.status) doc.status = 'Draft';
|
||||
cfn_set_fields(doc, dt, dn);
|
||||
}
|
||||
$.extend(cur_frm.cscript, {
|
||||
onload: function (doc, dt, dn) {
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
cur_frm.dashboard.reset();
|
||||
erpnext.hide_naming_series();
|
||||
cur_frm.set_intro("");
|
||||
cfn_set_fields(doc, dt, dn);
|
||||
if (!doc.status) doc.status = 'Draft';
|
||||
cfn_set_fields(doc, dt, dn);
|
||||
|
||||
if(doc.docstatus===0 && !doc.__islocal) {
|
||||
cur_frm.set_intro(wn._("Submit this Production Order for further processing."));
|
||||
} else if(doc.docstatus===1) {
|
||||
var percent = flt(doc.produced_qty) / flt(doc.qty) * 100;
|
||||
cur_frm.dashboard.add_progress(cint(percent) + "% " + wn._("Complete"), percent);
|
||||
this.frm.add_fetch("sales_order", "delivery_date", "expected_delivery_date");
|
||||
},
|
||||
|
||||
if(doc.status === "Stopped") {
|
||||
cur_frm.dashboard.set_headline_alert(wn._("Stopped"), "alert-danger", "icon-stop");
|
||||
refresh: function(doc, dt, dn) {
|
||||
this.frm.dashboard.reset();
|
||||
erpnext.hide_naming_series();
|
||||
this.frm.set_intro("");
|
||||
cfn_set_fields(doc, dt, dn);
|
||||
|
||||
if (doc.docstatus === 0 && !doc.__islocal) {
|
||||
this.frm.set_intro(wn._("Submit this Production Order for further processing."));
|
||||
} else if (doc.docstatus === 1) {
|
||||
var percent = flt(doc.produced_qty) / flt(doc.qty) * 100;
|
||||
this.frm.dashboard.add_progress(cint(percent) + "% " + wn._("Complete"), percent);
|
||||
|
||||
if(doc.status === "Stopped") {
|
||||
this.frm.dashboard.set_headline_alert(wn._("Stopped"), "alert-danger", "icon-stop");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
production_item: function(doc) {
|
||||
return this.frm.call({
|
||||
method: "get_item_details",
|
||||
args: { item: doc.production_item }
|
||||
});
|
||||
},
|
||||
|
||||
make_se: function(purpose) {
|
||||
var me = this;
|
||||
|
||||
wn.call({
|
||||
method:"manufacturing.doctype.production_order.production_order.make_stock_entry",
|
||||
args: {
|
||||
"production_order_id": me.frm.doc.name,
|
||||
"purpose": purpose
|
||||
},
|
||||
callback: function(r) {
|
||||
var doclist = wn.model.sync(r.message);
|
||||
wn.set_route("Form", doclist[0].doctype, doclist[0].name);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var cfn_set_fields = function(doc, dt, dn) {
|
||||
if (doc.docstatus == 1) {
|
||||
@@ -38,13 +66,6 @@ var cfn_set_fields = function(doc, dt, dn) {
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.production_item = function(doc) {
|
||||
return cur_frm.call({
|
||||
method: "get_item_details",
|
||||
args: { item: doc.production_item }
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript['Stop Production Order'] = function() {
|
||||
var doc = cur_frm.doc;
|
||||
var check = confirm(wn._("Do you really want to stop production order: " + doc.name));
|
||||
@@ -57,7 +78,7 @@ cur_frm.cscript['Unstop Production Order'] = function() {
|
||||
var doc = cur_frm.doc;
|
||||
var check = confirm(wn._("Do really want to unstop production order: " + doc.name));
|
||||
if (check)
|
||||
return $c_obj(make_doclist(doc.doctype, doc.name), 'stop_unstop', 'Unstopped', function(r, rt) {cur_frm.refresh();});
|
||||
return $c_obj(make_doclist(doc.doctype, doc.name), 'stop_unstop', 'Unstopped', function(r, rt) {cur_frm.refresh();});
|
||||
}
|
||||
|
||||
cur_frm.cscript['Transfer Raw Materials'] = function() {
|
||||
@@ -68,20 +89,6 @@ cur_frm.cscript['Update Finished Goods'] = function() {
|
||||
cur_frm.cscript.make_se('Manufacture/Repack');
|
||||
}
|
||||
|
||||
cur_frm.cscript.make_se = function(purpose) {
|
||||
wn.call({
|
||||
method:"manufacturing.doctype.production_order.production_order.make_stock_entry",
|
||||
args: {
|
||||
"production_order_id": cur_frm.doc.name,
|
||||
"purpose": purpose
|
||||
},
|
||||
callback: function(r) {
|
||||
var doclist = wn.model.sync(r.message);
|
||||
wn.set_route("Form", doclist[0].doctype, doclist[0].name);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['production_item'].get_query = function(doc) {
|
||||
return {
|
||||
filters:[
|
||||
@@ -98,7 +105,6 @@ cur_frm.fields_dict['project_name'].get_query = function(doc, dt, dn) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_frm.set_query("bom_no", function(doc) {
|
||||
if (doc.production_item) {
|
||||
return{
|
||||
|
||||
@@ -8,7 +8,6 @@ from webnotes.utils import cstr, flt, nowdate
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
|
||||
|
||||
class OverProductionError(webnotes.ValidationError): pass
|
||||
|
||||
class DocType:
|
||||
@@ -37,15 +36,20 @@ class DocType:
|
||||
and is_active=1 and item=%s"""
|
||||
, (self.doc.bom_no, self.doc.production_item), as_dict =1)
|
||||
if not bom:
|
||||
msgprint("""Incorrect BOM: %s entered.
|
||||
webnotes.throw("""Incorrect BOM: %s entered.
|
||||
May be BOM not exists or inactive or not submitted
|
||||
or for some other item.""" % cstr(self.doc.bom_no), raise_exception=1)
|
||||
or for some other item.""" % cstr(self.doc.bom_no))
|
||||
|
||||
def validate_sales_order(self):
|
||||
if self.doc.sales_order:
|
||||
if not webnotes.conn.sql("""select name from `tabSales Order`
|
||||
where name=%s and docstatus = 1""", self.doc.sales_order):
|
||||
msgprint("Sales Order: %s is not valid" % self.doc.sales_order, raise_exception=1)
|
||||
so = webnotes.conn.sql("""select name, delivery_date from `tabSales Order`
|
||||
where name=%s and docstatus = 1""", self.doc.sales_order, as_dict=1)[0]
|
||||
|
||||
if not so.name:
|
||||
webnotes.throw("Sales Order: %s is not valid" % self.doc.sales_order)
|
||||
|
||||
if not self.doc.expected_delivery_date:
|
||||
self.doc.expected_delivery_date = so.delivery_date
|
||||
|
||||
self.validate_production_order_against_so()
|
||||
|
||||
@@ -76,11 +80,11 @@ class DocType:
|
||||
so_qty = flt(so_item_qty) + flt(dnpi_qty)
|
||||
|
||||
if total_qty > so_qty:
|
||||
webnotes.msgprint(_("Total production order qty for item") + ": " +
|
||||
webnotes.throw(_("Total production order qty for item") + ": " +
|
||||
cstr(self.doc.production_item) + _(" against sales order") + ": " +
|
||||
cstr(self.doc.sales_order) + _(" will be ") + cstr(total_qty) + ", " +
|
||||
_("which is greater than sales order qty ") + "(" + cstr(so_qty) + ")" +
|
||||
_("Please reduce qty."), raise_exception=OverProductionError)
|
||||
_("Please reduce qty."), exc=OverProductionError)
|
||||
|
||||
def stop_unstop(self, status):
|
||||
""" Called from client side on Stop/Unstop event"""
|
||||
@@ -114,8 +118,8 @@ class DocType:
|
||||
stock_entry = webnotes.conn.sql("""select name from `tabStock Entry`
|
||||
where production_order = %s and docstatus = 1""", self.doc.name)
|
||||
if stock_entry:
|
||||
msgprint("""Submitted Stock Entry %s exists against this production order.
|
||||
Hence can not be cancelled.""" % stock_entry[0][0], raise_exception=1)
|
||||
webnotes.throw("""Submitted Stock Entry %s exists against this production order.
|
||||
Hence can not be cancelled.""" % stock_entry[0][0])
|
||||
|
||||
webnotes.conn.set(self.doc,'status', 'Cancelled')
|
||||
self.update_planned_qty(-self.doc.qty)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-01-10 16:34:16",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-02 14:05:44",
|
||||
"modified": "2013-12-18 13:22:14",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -136,6 +136,14 @@
|
||||
"oldfieldtype": "Currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "sales_order",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "expected_delivery_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Expected Delivery Date",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "warehouses",
|
||||
|
||||
@@ -34,6 +34,8 @@ class TestProductionOrder(unittest.TestCase):
|
||||
stock_entry = webnotes.bean(stock_entry)
|
||||
|
||||
stock_entry.doc.fg_completed_qty = 4
|
||||
stock_entry.doc.posting_date = "2013-05-12"
|
||||
stock_entry.doc.fiscal_year = "_Test Fiscal Year 2013"
|
||||
stock_entry.run_method("get_items")
|
||||
stock_entry.submit()
|
||||
|
||||
@@ -50,7 +52,8 @@ class TestProductionOrder(unittest.TestCase):
|
||||
|
||||
stock_entry = make_stock_entry(pro_order, "Manufacture/Repack")
|
||||
stock_entry = webnotes.bean(stock_entry)
|
||||
|
||||
stock_entry.doc.posting_date = "2013-05-12"
|
||||
stock_entry.doc.fiscal_year = "_Test Fiscal Year 2013"
|
||||
stock_entry.doc.fg_completed_qty = 15
|
||||
stock_entry.run_method("get_items")
|
||||
stock_entry.insert()
|
||||
|
||||
@@ -9,7 +9,6 @@ from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, _
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
@@ -47,7 +46,7 @@ class DocType:
|
||||
|
||||
def validate_company(self):
|
||||
if not self.doc.company:
|
||||
msgprint("Please enter Company", raise_exception=1)
|
||||
webnotes.throw(_("Please enter Company"))
|
||||
|
||||
def get_open_sales_orders(self):
|
||||
""" Pull sales orders which are pending to deliver based on criteria selected"""
|
||||
@@ -106,7 +105,7 @@ class DocType:
|
||||
def get_items(self):
|
||||
so_list = filter(None, [d.sales_order for d in getlist(self.doclist, 'pp_so_details')])
|
||||
if not so_list:
|
||||
msgprint("Please enter sales order in the above table")
|
||||
msgprint(_("Please enter sales order in the above table"))
|
||||
return []
|
||||
|
||||
items = webnotes.conn.sql("""select distinct parent, item_code, reserved_warehouse,
|
||||
@@ -155,21 +154,21 @@ class DocType:
|
||||
for d in getlist(self.doclist, 'pp_details'):
|
||||
self.validate_bom_no(d)
|
||||
if not flt(d.planned_qty):
|
||||
msgprint("Please Enter Planned Qty for item: %s at row no: %s" %
|
||||
(d.item_code, d.idx), raise_exception=1)
|
||||
webnotes.throw("Please Enter Planned Qty for item: %s at row no: %s" %
|
||||
(d.item_code, d.idx))
|
||||
|
||||
def validate_bom_no(self, d):
|
||||
if not d.bom_no:
|
||||
msgprint("Please enter bom no for item: %s at row no: %s" %
|
||||
(d.item_code, d.idx), raise_exception=1)
|
||||
webnotes.throw("Please enter bom no for item: %s at row no: %s" %
|
||||
(d.item_code, d.idx))
|
||||
else:
|
||||
bom = webnotes.conn.sql("""select name from `tabBOM` where name = %s and item = %s
|
||||
and docstatus = 1 and is_active = 1""",
|
||||
(d.bom_no, d.item_code), as_dict = 1)
|
||||
if not bom:
|
||||
msgprint("""Incorrect BOM No: %s entered for item: %s at row no: %s
|
||||
webnotes.throw("""Incorrect BOM No: %s entered for item: %s at row no: %s
|
||||
May be BOM is inactive or for other item or does not exists in the system""" %
|
||||
(d.bom_no, d.item_doce, d.idx), raise_exception=1)
|
||||
(d.bom_no, d.item_doce, d.idx))
|
||||
|
||||
def raise_production_order(self):
|
||||
"""It will raise production order (Draft) for all distinct FG items"""
|
||||
@@ -183,16 +182,19 @@ class DocType:
|
||||
if pro:
|
||||
pro = ["""<a href="#Form/Production Order/%s" target="_blank">%s</a>""" % \
|
||||
(p, p) for p in pro]
|
||||
msgprint("Production Order(s) created:\n\n" + '\n'.join(pro))
|
||||
msgprint(_("Production Order(s) created:\n\n") + '\n'.join(pro))
|
||||
else :
|
||||
msgprint("No Production Order created.")
|
||||
|
||||
msgprint(_("No Production Order created."))
|
||||
|
||||
def get_distinct_items_and_boms(self):
|
||||
""" Club similar BOM and item for processing"""
|
||||
""" Club similar BOM and item for processing
|
||||
bom_dict {
|
||||
bom_no: ['sales_order', 'qty']
|
||||
}
|
||||
"""
|
||||
item_dict, bom_dict = {}, {}
|
||||
for d in self.doclist.get({"parentfield": "pp_details"}):
|
||||
bom_dict[d.bom_no] = bom_dict.get(d.bom_no, 0) + flt(d.planned_qty)
|
||||
bom_dict.setdefault(d.bom_no, []).append([d.sales_order, flt(d.planned_qty)])
|
||||
item_dict[(d.item_code, d.sales_order, d.warehouse)] = {
|
||||
"production_item" : d.item_code,
|
||||
"sales_order" : d.sales_order,
|
||||
@@ -241,48 +243,60 @@ class DocType:
|
||||
"item_code": [qty_required, description, stock_uom, min_order_qty]
|
||||
}
|
||||
"""
|
||||
for bom in bom_dict:
|
||||
bom_wise_item_details = {}
|
||||
item_list = []
|
||||
|
||||
for bom, so_wise_qty in bom_dict.items():
|
||||
if self.doc.use_multi_level_bom:
|
||||
# get all raw materials with sub assembly childs
|
||||
fl_bom_items = webnotes.conn.sql("""select fb.item_code,
|
||||
ifnull(sum(fb.qty_consumed_per_unit), 0)*%s as qty,
|
||||
for d in webnotes.conn.sql("""select fb.item_code,
|
||||
ifnull(sum(fb.qty_consumed_per_unit), 0) as qty,
|
||||
fb.description, fb.stock_uom, it.min_order_qty
|
||||
from `tabBOM Explosion Item` fb,`tabItem` it
|
||||
where it.name = fb.item_code and ifnull(it.is_pro_applicable, 'No') = 'No'
|
||||
where it.name = fb.item_code and ifnull(it.is_pro_applicable, 'No') = 'No'
|
||||
and ifnull(it.is_sub_contracted_item, 'No') = 'No'
|
||||
and fb.docstatus<2 and fb.parent=%s
|
||||
group by item_code, stock_uom""", (flt(bom_dict[bom]), bom))
|
||||
and fb.docstatus<2 and fb.parent=%s
|
||||
group by item_code, stock_uom""", bom, as_dict=1):
|
||||
bom_wise_item_details.setdefault(d.item_code, d)
|
||||
else:
|
||||
# Get all raw materials considering SA items as raw materials,
|
||||
# so no childs of SA items
|
||||
fl_bom_items = webnotes.conn.sql("""select bom_item.item_code,
|
||||
ifnull(sum(bom_item.qty_consumed_per_unit), 0) * %s,
|
||||
bom_item.description, bom_item.stock_uom, item.min_order_qty
|
||||
from `tabBOM Item` bom_item, tabItem item
|
||||
for d in webnotes.conn.sql("""select bom_item.item_code,
|
||||
ifnull(sum(bom_item.qty_consumed_per_unit), 0) as qty,
|
||||
bom_item.description, bom_item.stock_uom, item.min_order_qty
|
||||
from `tabBOM Item` bom_item, tabItem item
|
||||
where bom_item.parent = %s and bom_item.docstatus < 2
|
||||
and bom_item.item_code = item.name
|
||||
group by item_code""", (flt(bom_dict[bom]), bom))
|
||||
self.make_items_dict(fl_bom_items)
|
||||
group by item_code""", bom, as_dict=1):
|
||||
bom_wise_item_details.setdefault(d.item_code, d)
|
||||
|
||||
for item, item_details in bom_wise_item_details.items():
|
||||
for so_qty in so_wise_qty:
|
||||
item_list.append([item, flt(item_details.qty) * so_qty[1], item_details.description,
|
||||
item_details.stock_uom, item_details.min_order_qty, so_qty[0]])
|
||||
|
||||
self.make_items_dict(item_list)
|
||||
|
||||
def make_items_dict(self, item_list):
|
||||
for i in item_list:
|
||||
self.item_dict[i[0]] = [(flt(self.item_dict.get(i[0], [0])[0]) + flt(i[1])),
|
||||
i[2], i[3], i[4]]
|
||||
|
||||
self.item_dict.setdefault(i[0], []).append([flt(i[1]), i[2], i[3], i[4], i[5]])
|
||||
|
||||
def get_csv(self):
|
||||
item_list = [['Item Code', 'Description', 'Stock UOM', 'Required Qty', 'Warehouse',
|
||||
'Quantity Requested for Purchase', 'Ordered Qty', 'Actual Qty']]
|
||||
for d in self.item_dict:
|
||||
item_list.append([d, self.item_dict[d][1], self.item_dict[d][2], self.item_dict[d][0]])
|
||||
item_qty= webnotes.conn.sql("""select warehouse, indented_qty, ordered_qty, actual_qty
|
||||
from `tabBin` where item_code = %s""", d)
|
||||
i_qty, o_qty, a_qty = 0, 0, 0
|
||||
for w in item_qty:
|
||||
i_qty, o_qty, a_qty = i_qty + flt(w[1]), o_qty + flt(w[2]), a_qty + flt(w[3])
|
||||
item_list.append(['', '', '', '', w[0], flt(w[1]), flt(w[2]), flt(w[3])])
|
||||
if item_qty:
|
||||
item_list.append(['', '', '', '', 'Total', i_qty, o_qty, a_qty])
|
||||
for item in self.item_dict:
|
||||
total_qty = sum([flt(d[0]) for d in self.item_dict[item]])
|
||||
for item_details in self.item_dict[item]:
|
||||
item_list.append([item, item_details[1], item_details[2], item_details[0]])
|
||||
item_qty = webnotes.conn.sql("""select warehouse, indented_qty, ordered_qty, actual_qty
|
||||
from `tabBin` where item_code = %s""", item, as_dict=1)
|
||||
i_qty, o_qty, a_qty = 0, 0, 0
|
||||
for w in item_qty:
|
||||
i_qty, o_qty, a_qty = i_qty + flt(w.indented_qty), o_qty + flt(w.ordered_qty), a_qty + flt(w.actual_qty)
|
||||
item_list.append(['', '', '', '', w.warehouse, flt(w.indented_qty),
|
||||
flt(w.ordered_qty), flt(w.actual_qty)])
|
||||
if item_qty:
|
||||
item_list.append(['', '', '', '', 'Total', i_qty, o_qty, a_qty])
|
||||
|
||||
return item_list
|
||||
|
||||
@@ -293,31 +307,49 @@ class DocType:
|
||||
"""
|
||||
self.validate_data()
|
||||
if not self.doc.purchase_request_for_warehouse:
|
||||
webnotes.msgprint("Please enter Warehouse for which Material Request will be raised",
|
||||
raise_exception=1)
|
||||
webnotes.throw(_("Please enter Warehouse for which Material Request will be raised"))
|
||||
|
||||
bom_dict = self.get_distinct_items_and_boms()[0]
|
||||
self.get_raw_materials(bom_dict)
|
||||
|
||||
if not self.item_dict:
|
||||
return
|
||||
|
||||
if self.item_dict:
|
||||
self.insert_purchase_request()
|
||||
|
||||
def get_requested_items(self):
|
||||
item_projected_qty = self.get_projected_qty()
|
||||
|
||||
from accounts.utils import get_fiscal_year
|
||||
fiscal_year = get_fiscal_year(nowdate())[0]
|
||||
|
||||
items_to_be_requested = webnotes._dict()
|
||||
for item in self.item_dict:
|
||||
if flt(self.item_dict[item][0]) > item_projected_qty.get(item, 0):
|
||||
|
||||
for item, so_item_qty in self.item_dict.items():
|
||||
requested_qty = 0
|
||||
total_qty = sum([flt(d[0]) for d in so_item_qty])
|
||||
if total_qty > item_projected_qty.get(item, 0):
|
||||
# shortage
|
||||
requested_qty = flt(self.item_dict[item][0]) - item_projected_qty.get(item, 0)
|
||||
# comsider minimum order qty
|
||||
requested_qty = requested_qty > flt(self.item_dict[item][3]) and \
|
||||
requested_qty or flt(self.item_dict[item][3])
|
||||
items_to_be_requested[item] = requested_qty
|
||||
|
||||
self.insert_purchase_request(items_to_be_requested, fiscal_year)
|
||||
requested_qty = total_qty - item_projected_qty.get(item, 0)
|
||||
# consider minimum order qty
|
||||
requested_qty = requested_qty > flt(so_item_qty[0][3]) and \
|
||||
requested_qty or flt(so_item_qty[0][3])
|
||||
|
||||
# distribute requested qty SO wise
|
||||
for item_details in so_item_qty:
|
||||
if requested_qty:
|
||||
sales_order = item_details[4] or "No Sales Order"
|
||||
if requested_qty <= item_details[0]:
|
||||
adjusted_qty = requested_qty
|
||||
else:
|
||||
adjusted_qty = item_details[0]
|
||||
|
||||
items_to_be_requested.setdefault(item, {}).setdefault(sales_order, 0)
|
||||
items_to_be_requested[item][sales_order] += adjusted_qty
|
||||
requested_qty -= adjusted_qty
|
||||
else:
|
||||
break
|
||||
|
||||
# requested qty >= total so qty, due to minimum order qty
|
||||
if requested_qty:
|
||||
items_to_be_requested.setdefault(item, {}).setdefault("No Sales Order", 0)
|
||||
items_to_be_requested[item]["No Sales Order"] += requested_qty
|
||||
|
||||
return items_to_be_requested
|
||||
|
||||
def get_projected_qty(self):
|
||||
items = self.item_dict.keys()
|
||||
@@ -327,24 +359,29 @@ class DocType:
|
||||
|
||||
return dict(item_projected_qty)
|
||||
|
||||
def insert_purchase_request(self, items_to_be_requested, fiscal_year):
|
||||
def insert_purchase_request(self):
|
||||
items_to_be_requested = self.get_requested_items()
|
||||
|
||||
from accounts.utils import get_fiscal_year
|
||||
fiscal_year = get_fiscal_year(nowdate())[0]
|
||||
|
||||
purchase_request_list = []
|
||||
if items_to_be_requested:
|
||||
for item in items_to_be_requested:
|
||||
item_wrapper = webnotes.bean("Item", item)
|
||||
pr_doclist = [
|
||||
{
|
||||
"doctype": "Material Request",
|
||||
"__islocal": 1,
|
||||
"naming_series": "IDT",
|
||||
"transaction_date": nowdate(),
|
||||
"status": "Draft",
|
||||
"company": self.doc.company,
|
||||
"fiscal_year": fiscal_year,
|
||||
"requested_by": webnotes.session.user,
|
||||
"material_request_type": "Purchase"
|
||||
},
|
||||
{
|
||||
pr_doclist = [{
|
||||
"doctype": "Material Request",
|
||||
"__islocal": 1,
|
||||
"naming_series": "IDT",
|
||||
"transaction_date": nowdate(),
|
||||
"status": "Draft",
|
||||
"company": self.doc.company,
|
||||
"fiscal_year": fiscal_year,
|
||||
"requested_by": webnotes.session.user,
|
||||
"material_request_type": "Purchase"
|
||||
}]
|
||||
for sales_order, requested_qty in items_to_be_requested[item].items():
|
||||
pr_doclist.append({
|
||||
"doctype": "Material Request Item",
|
||||
"__islocal": 1,
|
||||
"parentfield": "indent_details",
|
||||
@@ -354,11 +391,12 @@ class DocType:
|
||||
"uom": item_wrapper.doc.stock_uom,
|
||||
"item_group": item_wrapper.doc.item_group,
|
||||
"brand": item_wrapper.doc.brand,
|
||||
"qty": items_to_be_requested[item],
|
||||
"qty": requested_qty,
|
||||
"schedule_date": add_days(nowdate(), cint(item_wrapper.doc.lead_time_days)),
|
||||
"warehouse": self.doc.purchase_request_for_warehouse
|
||||
}
|
||||
]
|
||||
"warehouse": self.doc.purchase_request_for_warehouse,
|
||||
"sales_order_no": sales_order if sales_order!="No Sales Order" else None
|
||||
})
|
||||
|
||||
pr_wrapper = webnotes.bean(pr_doclist)
|
||||
pr_wrapper.ignore_permissions = 1
|
||||
pr_wrapper.submit()
|
||||
@@ -367,7 +405,7 @@ class DocType:
|
||||
if purchase_request_list:
|
||||
pur_req = ["""<a href="#Form/Material Request/%s" target="_blank">%s</a>""" % \
|
||||
(p, p) for p in purchase_request_list]
|
||||
webnotes.msgprint("Material Request(s) created: \n%s" %
|
||||
msgprint("Material Request(s) created: \n%s" %
|
||||
"\n".join(pur_req))
|
||||
else:
|
||||
webnotes.msgprint("Nothing to request")
|
||||
msgprint(_("Nothing to request"))
|
||||
32
patches/1311/p07_scheduler_errors_digest.py
Normal file
32
patches/1311/p07_scheduler_errors_digest.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
webnotes.reload_doc("setup", "doctype", "email_digest")
|
||||
|
||||
from webnotes.profile import get_system_managers
|
||||
system_managers = get_system_managers(only_name=True)
|
||||
if not system_managers:
|
||||
return
|
||||
|
||||
# no default company
|
||||
company = webnotes.conn.sql_list("select name from `tabCompany`")
|
||||
if company:
|
||||
company = company[0]
|
||||
if not company:
|
||||
return
|
||||
|
||||
# scheduler errors digest
|
||||
edigest = webnotes.new_bean("Email Digest")
|
||||
edigest.doc.fields.update({
|
||||
"name": "Scheduler Errors",
|
||||
"company": company,
|
||||
"frequency": "Daily",
|
||||
"enabled": 1,
|
||||
"recipient_list": "\n".join(system_managers),
|
||||
"scheduler_errors": 1
|
||||
})
|
||||
edigest.insert()
|
||||
11
patches/1311/p08_email_digest_recipients.py
Normal file
11
patches/1311/p08_email_digest_recipients.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
from webnotes.utils import extract_email_id
|
||||
for name, recipients in webnotes.conn.sql("""select name, recipient_list from `tabEmail Digest`"""):
|
||||
recipients = "\n".join([extract_email_id(r) for r in recipients.split("\n")])
|
||||
webnotes.conn.set_value("Email Digest", name, "recipient_list", recipients)
|
||||
17
patches/1312/p01_delete_old_stock_reports.py
Normal file
17
patches/1312/p01_delete_old_stock_reports.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
def execute():
|
||||
import webnotes, os, shutil
|
||||
from webnotes.utils import get_base_path
|
||||
|
||||
webnotes.delete_doc('Page', 'stock-ledger')
|
||||
webnotes.delete_doc('Page', 'stock-ageing')
|
||||
webnotes.delete_doc('Page', 'stock-level')
|
||||
webnotes.delete_doc('Page', 'general-ledger')
|
||||
|
||||
for d in [["stock", "stock_ledger"], ["stock", "stock_ageing"],
|
||||
["stock", "stock_level"], ["accounts", "general_ledger"]]:
|
||||
path = os.path.join(get_base_path(), "app", d[0], "page", d[1])
|
||||
if os.path.exists(path):
|
||||
shutil.rmtree(path)
|
||||
10
patches/1312/p02_update_item_details_in_item_price.py
Normal file
10
patches/1312/p02_update_item_details_in_item_price.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
webnotes.conn.sql("""update `tabItem Price` ip INNER JOIN `tabItem` i
|
||||
ON (ip.item_code = i.name)
|
||||
set ip.item_name = i.item_name, ip.item_description = i.description""")
|
||||
@@ -0,0 +1,29 @@
|
||||
# Copyright (c) 2014, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
webnotes.reload_doc("stock", "doctype", "price_list")
|
||||
webnotes.reload_doc("stock", "doctype", "item_price")
|
||||
|
||||
if "buying_or_selling" in webnotes.conn.get_table_columns("Price List"):
|
||||
webnotes.conn.sql("""update `tabPrice List` set
|
||||
selling =
|
||||
case
|
||||
when buying_or_selling='Selling'
|
||||
then 1
|
||||
end,
|
||||
buying =
|
||||
case
|
||||
when buying_or_selling='Buying'
|
||||
then 1
|
||||
end
|
||||
""")
|
||||
webnotes.conn.sql("""update `tabItem Price` ip, `tabPrice List` pl
|
||||
set ip.buying=pl.buying, ip.selling=pl.selling
|
||||
where ip.price_list=pl.name""")
|
||||
|
||||
webnotes.conn.sql("""update `tabItem Price` set selling=1 where ifnull(selling, 0)=0 and
|
||||
ifnull(buying, 0)=0""")
|
||||
@@ -0,0 +1,25 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
webnotes.reload_doc("core", "doctype", "custom_field")
|
||||
|
||||
cf_doclist = webnotes.get_doctype("Custom Field")
|
||||
|
||||
delete_list = []
|
||||
for d in webnotes.conn.sql("""select cf.name as cf_name, ps.property,
|
||||
ps.value, ps.name as ps_name
|
||||
from `tabProperty Setter` ps, `tabCustom Field` cf
|
||||
where ps.doctype_or_field = 'DocField' and ps.property != 'previous_field'
|
||||
and ps.doc_type=cf.dt and ps.field_name=cf.fieldname""", as_dict=1):
|
||||
if cf_doclist.get_field(d.property):
|
||||
webnotes.conn.sql("""update `tabCustom Field`
|
||||
set `%s`=%s where name=%s""" % (d.property, '%s', '%s'), (d.value, d.cf_name))
|
||||
|
||||
delete_list.append(d.ps_name)
|
||||
|
||||
if delete_list:
|
||||
webnotes.conn.sql("""delete from `tabProperty Setter` where name in (%s)""" %
|
||||
', '.join(['%s']*len(delete_list)), tuple(delete_list))
|
||||
29
patches/1401/update_billing_status_for_zero_value_order.py
Normal file
29
patches/1401/update_billing_status_for_zero_value_order.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
import webnotes
|
||||
from webnotes.utils import flt
|
||||
|
||||
def execute():
|
||||
for order_type in ["Sales", "Purchase"]:
|
||||
for d in webnotes.conn.sql("""select par.name, sum(ifnull(child.qty, 0)) as total_qty
|
||||
from `tab%s Order` par, `tab%s Order Item` child
|
||||
where par.name = child.parent and par.docstatus = 1
|
||||
and ifnull(par.net_total, 0) = 0 group by par.name""" %
|
||||
(order_type, order_type), as_dict=1):
|
||||
|
||||
billed_qty = flt(webnotes.conn.sql("""select sum(ifnull(qty, 0))
|
||||
from `tab%s Invoice Item` where %s=%s and docstatus=1""" %
|
||||
(order_type, "sales_order" if order_type=="Sales" else "purchase_order", '%s'),
|
||||
(d.name))[0][0])
|
||||
|
||||
per_billed = ((d.total_qty if billed_qty > d.total_qty else billed_qty)\
|
||||
/ d.total_qty)*100
|
||||
webnotes.conn.set_value(order_type+ " Order", d.name, "per_billed", per_billed)
|
||||
|
||||
if order_type == "Sales":
|
||||
if per_billed < 0.001: billing_status = "Not Billed"
|
||||
elif per_billed >= 99.99: billing_status = "Fully Billed"
|
||||
else: billing_status = "Partly Billed"
|
||||
|
||||
webnotes.conn.set_value("Sales Order", d.name, "billing_status", billing_status)
|
||||
@@ -5,7 +5,8 @@ from __future__ import unicode_literals
|
||||
|
||||
def execute():
|
||||
import webnotes
|
||||
webnotes.reload_doc('stock', 'doctype', 'packed_item')
|
||||
for si in webnotes.conn.sql("""select name from `tabSales Invoice` where docstatus = 1"""):
|
||||
webnotes.get_obj("Sales Invoice", si[0],
|
||||
with_children=1).update_qty(change_modified=False)
|
||||
webnotes.conn.commit()
|
||||
webnotes.conn.commit()
|
||||
|
||||
@@ -8,20 +8,7 @@ from webnotes.utils import cint
|
||||
def execute():
|
||||
webnotes.reload_doc("stock", "doctype", "price_list")
|
||||
webnotes.reload_doc("stock", "doctype", "item_price")
|
||||
|
||||
try:
|
||||
for price_list in webnotes.conn.sql_list("""select name from `tabPrice List`"""):
|
||||
buying, selling = False, False
|
||||
for b, s in webnotes.conn.sql("""select distinct buying, selling
|
||||
from `tabItem Price` where price_list_name=%s""", price_list):
|
||||
buying = buying or cint(b)
|
||||
selling = selling or cint(s)
|
||||
|
||||
buying_or_selling = "Selling" if selling else "Buying"
|
||||
webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling)
|
||||
except webnotes.SQLError, e:
|
||||
if e.args[0] == 1054:
|
||||
webnotes.conn.sql("""update `tabPrice List` set buying_or_selling='Selling'
|
||||
where ifnull(buying_or_selling, '')='' """)
|
||||
else:
|
||||
raise
|
||||
|
||||
webnotes.conn.sql("""update `tabPrice List` pl, `tabItem Price` ip
|
||||
set pl.selling=ip.selling, pl.buying=ip.buying
|
||||
where pl.name=ip.price_list_name""")
|
||||
@@ -12,9 +12,7 @@ def execute():
|
||||
where ip.item_code=i.name""")
|
||||
|
||||
webnotes.conn.sql("""update `tabItem Price` ip, `tabPrice List` pl
|
||||
set ip.price_list=pl.name, ip.currency=pl.currency,
|
||||
ip.buying_or_selling=pl.buying_or_selling
|
||||
where ip.parent=pl.name""")
|
||||
set ip.price_list=pl.name, ip.currency=pl.currency where ip.parent=pl.name""")
|
||||
|
||||
webnotes.conn.sql("""update `tabItem Price`
|
||||
set parent=null, parenttype=null, parentfield=null, idx=null""")
|
||||
@@ -256,6 +256,14 @@ patch_list = [
|
||||
"patches.1311.p06_fix_report_columns",
|
||||
"execute:webnotes.delete_doc('DocType', 'Documentation Tool')",
|
||||
"execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29",
|
||||
"patches.1312.p01_delete_old_stock_reports",
|
||||
"execute:webnotes.delete_doc('Report', 'Payment Collection With Ageing')",
|
||||
"execute:webnotes.delete_doc('Report', 'Payment Made With Ageing')",
|
||||
"patches.1311.p07_scheduler_errors_digest",
|
||||
"patches.1311.p08_email_digest_recipients",
|
||||
"execute:webnotes.delete_doc('DocType', 'Warehouse Type')",
|
||||
"patches.1312.p02_update_item_details_in_item_price",
|
||||
"patches.1401.p01_move_related_property_setters_to_custom_field",
|
||||
"patches.1401.p01_make_buying_selling_as_check_box_in_price_list",
|
||||
"patches.1401.update_billing_status_for_zero_value_order",
|
||||
]
|
||||
@@ -28,7 +28,7 @@ class DocType:
|
||||
})
|
||||
|
||||
def validate_time_log_is_submitted(self, tl):
|
||||
if tl.status != "Submitted":
|
||||
if tl.status != "Submitted" and self.doc.docstatus == 0:
|
||||
webnotes.msgprint(_("Time Log must have status 'Submitted'") + \
|
||||
" :" + tl.name + " (" + _(tl.status) + ")", raise_exception=True)
|
||||
|
||||
@@ -57,7 +57,4 @@ class DocType:
|
||||
tl = webnotes.bean("Time Log", d.time_log)
|
||||
tl.doc.time_log_batch = time_log_batch
|
||||
tl.doc.sales_invoice = self.doc.sales_invoice
|
||||
tl.update_after_submit()
|
||||
|
||||
|
||||
|
||||
tl.update_after_submit()
|
||||
@@ -26,9 +26,10 @@ erpnext.AccountTreeGrid = wn.views.TreeGridReport.extend({
|
||||
show: true,
|
||||
parent_field: "parent_account",
|
||||
formatter: function(item) {
|
||||
return repl('<a href="#general-ledger/account=%(enc_value)s">%(value)s</a>', {
|
||||
return repl("<a \
|
||||
onclick='wn.cur_grid_report.show_general_ledger(\"%(value)s\")'>\
|
||||
%(value)s</a>", {
|
||||
value: item.name,
|
||||
enc_value: encodeURIComponent(item.name)
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -211,4 +212,14 @@ erpnext.AccountTreeGrid = wn.views.TreeGridReport.extend({
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
show_general_ledger: function(account) {
|
||||
wn.route_options = {
|
||||
account: account,
|
||||
company: this.company,
|
||||
from_date: this.from_date,
|
||||
to_date: this.to_date
|
||||
};
|
||||
wn.set_route("query-report", "General Ledger");
|
||||
}
|
||||
});
|
||||
@@ -24,16 +24,17 @@ $(document).bind('toolbar_setup', function() {
|
||||
wn.provide('wn.ui.misc');
|
||||
wn.ui.misc.about = function() {
|
||||
if(!wn.ui.misc.about_dialog) {
|
||||
var d = new wn.ui.Dialog({title: wn._('About ERPNext')})
|
||||
var d = new wn.ui.Dialog({title: wn._('About')})
|
||||
|
||||
$(d.body).html(repl("<div>\
|
||||
<p>"+wn._("ERPNext is an open-source web based ERP made by Web Notes Technologies Pvt Ltd.\
|
||||
to provide an integrated tool to manage most processes in a small organization.\
|
||||
For more information about Web Notes, or to buy hosting servies, go to ")+
|
||||
"<a href='https://erpnext.com'>https://erpnext.com</a>.</p>\
|
||||
<p>"+wn._("To report an issue, go to ")+"<a href='https://github.com/webnotes/erpnext/issues'>GitHub Issues</a></p>\
|
||||
<hr>\
|
||||
<h2>ERPNext</h2> \
|
||||
<p><strong>v" + wn.boot.app_version + "</strong></p>\
|
||||
<p>"+wn._("An open source ERP made for the web.</p>") +
|
||||
"<p>"+wn._("To report an issue, go to ")+"<a href='https://github.com/webnotes/erpnext/issues'>GitHub Issues</a></p> \
|
||||
<p><a href='http://erpnext.org' target='_blank'>http://erpnext.org</a>.</p>\
|
||||
<p><a href='http://www.gnu.org/copyleft/gpl.html'>License: GNU General Public License Version 3</a></p>\
|
||||
<hr>\
|
||||
<p>© 2014 Web Notes Technologies Pvt. Ltd and contributers </p> \
|
||||
</div>", wn.app));
|
||||
|
||||
wn.ui.misc.about_dialog = d;
|
||||
|
||||
@@ -11,9 +11,10 @@ erpnext.stock.StockController = wn.ui.form.Controller.extend({
|
||||
wn.route_options = {
|
||||
voucher_no: me.frm.doc.name,
|
||||
from_date: me.frm.doc.posting_date,
|
||||
to_date: me.frm.doc.posting_date
|
||||
to_date: me.frm.doc.posting_date,
|
||||
company: me.frm.doc.company
|
||||
};
|
||||
wn.set_route('stock-ledger');
|
||||
wn.set_route("query-report", "Stock Ledger");
|
||||
}, "icon-bar-chart");
|
||||
}
|
||||
|
||||
@@ -24,11 +25,13 @@ erpnext.stock.StockController = wn.ui.form.Controller.extend({
|
||||
if(this.frm.doc.docstatus===1 && cint(wn.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
cur_frm.appframe.add_button(wn._('Accounting Ledger'), function() {
|
||||
wn.route_options = {
|
||||
"voucher_no": me.frm.doc.name,
|
||||
"from_date": me.frm.doc.posting_date,
|
||||
"to_date": me.frm.doc.posting_date,
|
||||
voucher_no: me.frm.doc.name,
|
||||
from_date: me.frm.doc.posting_date,
|
||||
to_date: me.frm.doc.posting_date,
|
||||
company: me.frm.doc.company,
|
||||
group_by_voucher: false
|
||||
};
|
||||
wn.set_route("general-ledger");
|
||||
wn.set_route("query-report", "General Ledger");
|
||||
}, "icon-table");
|
||||
}
|
||||
},
|
||||
|
||||
@@ -17,10 +17,10 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
|
||||
parent_field: "parent_item_group",
|
||||
formatter: function(item) {
|
||||
if(!item.is_group) {
|
||||
return repl('<a href="#stock-ledger/item_code=%(enc_value)s">%(value)s</a>',
|
||||
{
|
||||
return repl("<a \
|
||||
onclick='wn.cur_grid_report.show_stock_ledger(\"%(value)s\")'>\
|
||||
%(value)s</a>", {
|
||||
value: item.name,
|
||||
enc_value: encodeURIComponent(item.name)
|
||||
});
|
||||
} else {
|
||||
return item.name;
|
||||
@@ -183,5 +183,13 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
|
||||
},
|
||||
get_plot_points: function(item, col, idx) {
|
||||
return [[dateutil.user_to_obj(col.name).getTime(), item[col.field]]]
|
||||
},
|
||||
show_stock_ledger: function(item_code) {
|
||||
wn.route_options = {
|
||||
item_code: item_code,
|
||||
from_date: this.from_date,
|
||||
to_date: this.to_date
|
||||
};
|
||||
wn.set_route("query-report", "Stock Ledger");
|
||||
}
|
||||
});
|
||||
@@ -21,6 +21,6 @@ erpnext.toolbar.setup = function() {
|
||||
<i class="icon-fixed-width icon-comments"></i> '+wn._('Live Chat')+'</a></li>');
|
||||
}
|
||||
|
||||
$("#toolbar-tools").append('<li><a href="#latest-updates">\
|
||||
$("#toolbar-tools").append('<li><a href="https://github.com/webnotes/erpnext/releases" target="_blank">\
|
||||
<i class="icon-fixed-width icon-rss"></i> Latest Updates</li>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,8 +330,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
doctype: tax.doctype,
|
||||
row_id_label: wn.meta.get_label(tax.doctype, "row_id", tax.name)
|
||||
});
|
||||
msgprint(msg);
|
||||
throw msg;
|
||||
wn.throw(msg);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -347,8 +346,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
charge_type_label: wn.meta.get_label(tax.doctype, "charge_type", tax.name),
|
||||
charge_type: tax.charge_type
|
||||
});
|
||||
msgprint(msg);
|
||||
throw msg;
|
||||
wn.throw(msg);
|
||||
};
|
||||
|
||||
var on_previous_row_error = function(row_range) {
|
||||
@@ -363,8 +361,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
row_range: row_range,
|
||||
});
|
||||
|
||||
msgprint(msg);
|
||||
throw msg;
|
||||
wn.throw(msg);
|
||||
};
|
||||
|
||||
if(cint(tax.included_in_print_rate)) {
|
||||
@@ -543,6 +540,14 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
|
||||
calculate_taxes: function() {
|
||||
var me = this;
|
||||
var actual_tax_dict = {};
|
||||
|
||||
// maintain actual tax rate based on idx
|
||||
$.each(this.frm.tax_doclist, function(i, tax) {
|
||||
if (tax.charge_type == "Actual") {
|
||||
actual_tax_dict[tax.idx] = flt(tax.rate);
|
||||
}
|
||||
});
|
||||
|
||||
$.each(this.frm.item_doclist, function(n, item) {
|
||||
var item_tax_map = me._load_item_tax_rate(item.item_tax_rate);
|
||||
@@ -552,15 +557,15 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
var current_tax_amount = me.get_current_tax_amount(item, tax, item_tax_map);
|
||||
|
||||
me.set_item_tax_amount && me.set_item_tax_amount(item, tax, current_tax_amount);
|
||||
|
||||
// case when net total is 0 but there is an actual type charge
|
||||
// in this case add the actual amount to tax.tax_amount
|
||||
// and tax.grand_total_for_current_item for the first such iteration
|
||||
if(tax.charge_type == "Actual" &&
|
||||
!(current_tax_amount || me.frm.doc.net_total || tax.tax_amount)) {
|
||||
var zero_net_total_adjustment = flt(tax.rate, precision("tax_amount", tax));
|
||||
current_tax_amount += zero_net_total_adjustment;
|
||||
|
||||
// Adjust divisional loss to the last item
|
||||
if (tax.charge_type == "Actual") {
|
||||
actual_tax_dict[tax.idx] -= current_tax_amount;
|
||||
if (n == me.frm.item_doclist.length - 1) {
|
||||
current_tax_amount += actual_tax_dict[tax.idx]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// store tax_amount for current item as it will be used for
|
||||
// charge type = 'On Previous Row Amount'
|
||||
@@ -592,6 +597,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
|
||||
// in tax.total, accumulate grand total for each item
|
||||
tax.total += tax.grand_total_for_current_item;
|
||||
|
||||
if (n == me.frm.item_doclist.length - 1) {
|
||||
tax.total = flt(tax.total, precision("total", tax));
|
||||
tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax));
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,13 +1,2 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
@@ -2,11 +2,12 @@
|
||||
{
|
||||
"creation": "2013-01-10 16:34:18",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:29:57",
|
||||
"modified": "2014-01-16 12:52:19",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:campaign_name",
|
||||
"description": "Keep Track of Sales Campaigns. Keep track of Leads, Quotations, Sales Order etc from Campaigns to gauge Return on Investment. ",
|
||||
"doctype": "DocType",
|
||||
|
||||
@@ -122,6 +122,6 @@ cur_frm.fields_dict.lead_name.get_query = function(doc,cdt,cdn) {
|
||||
|
||||
cur_frm.fields_dict['default_price_list'].get_query = function(doc,cdt,cdn) {
|
||||
return{
|
||||
filters:{'buying_or_selling': "Selling"}
|
||||
filters:{'selling': 1}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-06-11 14:26:44",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-03 14:01:33",
|
||||
"modified": "2013-12-25 11:15:05",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -16,7 +16,7 @@
|
||||
"icon": "icon-user",
|
||||
"module": "Selling",
|
||||
"name": "__common__",
|
||||
"search_fields": "customer_name,customer_group,country,territory"
|
||||
"search_fields": "customer_name,customer_group,territory"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:08",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-27 17:57:19",
|
||||
"modified": "2013-12-14 17:25:46",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -863,6 +863,7 @@
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "customer",
|
||||
"role": "Customer",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
|
||||
@@ -28,6 +28,7 @@ class TestQuotation(unittest.TestCase):
|
||||
|
||||
sales_order[0]["delivery_date"] = "2014-01-01"
|
||||
sales_order[0]["naming_series"] = "_T-Quotation-"
|
||||
sales_order[0]["transaction_date"] = "2013-05-12"
|
||||
webnotes.bean(sales_order).insert()
|
||||
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ class TestSalesOrder(unittest.TestCase):
|
||||
self.assertEquals(len([d for d in si if d["doctype"]=="Sales Invoice Item"]), 1)
|
||||
|
||||
si = webnotes.bean(si)
|
||||
si.doc.posting_date = "2013-10-10"
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
|
||||
if(this.frm.fields_dict.selling_price_list) {
|
||||
this.frm.set_query("selling_price_list", function() {
|
||||
return { filters: { buying_or_selling: "Selling" } };
|
||||
return { filters: { selling: 1 } };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -515,7 +515,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
setup_field_label_map(["net_total", "other_charges_total", "grand_total",
|
||||
"rounded_total", "in_words",
|
||||
"outstanding_amount", "total_advance", "paid_amount", "write_off_amount"],
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _
|
||||
from webnotes.utils import flt, cint, comma_and
|
||||
from webnotes import _, throw
|
||||
from webnotes.utils import flt, cint
|
||||
import json
|
||||
|
||||
def get_customer_list(doctype, txt, searchfield, start, page_len, filters):
|
||||
@@ -100,7 +100,7 @@ def _get_item_code(barcode=None, serial_no=None):
|
||||
where name=%s""", serial_no)
|
||||
|
||||
if not item_code:
|
||||
msgprint(_("No Item found with ") + input_type + ": %s" % (barcode or serial_no), raise_exception=True)
|
||||
throw(_("No Item found with ") + input_type + ": %s" % (barcode or serial_no))
|
||||
|
||||
return item_code[0]
|
||||
|
||||
@@ -111,22 +111,26 @@ def _validate_item_details(args, item):
|
||||
# validate if sales item or service item
|
||||
if args.order_type == "Maintenance":
|
||||
if item.is_service_item != "Yes":
|
||||
msgprint(_("Item") + (" %s: " % item.name) +
|
||||
throw(_("Item") + (" %s: " % item.name) +
|
||||
_("not a service item.") +
|
||||
_("Please select a service item or change the order type to Sales."),
|
||||
raise_exception=True)
|
||||
_("Please select a service item or change the order type to Sales."))
|
||||
|
||||
elif item.is_sales_item != "Yes":
|
||||
msgprint(_("Item") + (" %s: " % item.name) + _("not a sales item"),
|
||||
raise_exception=True)
|
||||
throw(_("Item") + (" %s: " % item.name) + _("not a sales item"))
|
||||
|
||||
def _get_basic_details(args, item_bean, warehouse_fieldname):
|
||||
item = item_bean.doc
|
||||
|
||||
from webnotes.defaults import get_user_default_as_list
|
||||
user_default_warehouse_list = get_user_default_as_list('warehouse')
|
||||
user_default_warehouse = user_default_warehouse_list[0] \
|
||||
if len(user_default_warehouse_list)==1 else ""
|
||||
|
||||
out = webnotes._dict({
|
||||
"item_code": item.name,
|
||||
"description": item.description_html or item.description,
|
||||
warehouse_fieldname: item.default_warehouse or args.get(warehouse_fieldname),
|
||||
warehouse_fieldname: user_default_warehouse or item.default_warehouse \
|
||||
or args.get(warehouse_fieldname),
|
||||
"income_account": item.default_income_account or args.income_account \
|
||||
or webnotes.conn.get_value("Company", args.company, "default_income_account"),
|
||||
"expense_account": item.purchase_account or args.expense_account \
|
||||
@@ -147,7 +151,7 @@ def _get_basic_details(args, item_bean, warehouse_fieldname):
|
||||
|
||||
def _get_price_list_rate(args, item_bean, meta):
|
||||
ref_rate = webnotes.conn.sql("""select ref_rate from `tabItem Price`
|
||||
where price_list=%s and item_code=%s and buying_or_selling='Selling'""",
|
||||
where price_list=%s and item_code=%s and selling=1""",
|
||||
(args.selling_price_list, args.item_code), as_dict=1)
|
||||
|
||||
if not ref_rate:
|
||||
|
||||
@@ -16,8 +16,6 @@ import webnotes
|
||||
from webnotes.utils import get_request_site_address, cstr
|
||||
from webnotes import _
|
||||
|
||||
from backup_manager import ignore_list
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_dropbox_authorize_url():
|
||||
sess = get_dropbox_session()
|
||||
@@ -100,9 +98,7 @@ def backup_to_dropbox():
|
||||
path = get_files_path()
|
||||
for filename in os.listdir(path):
|
||||
filename = cstr(filename)
|
||||
if filename in ignore_list:
|
||||
continue
|
||||
|
||||
|
||||
found = False
|
||||
filepath = os.path.join(path, filename)
|
||||
for file_metadata in response["contents"]:
|
||||
|
||||
@@ -87,7 +87,7 @@ $.extend(cur_frm.cscript, {
|
||||
cur_frm.save();
|
||||
},
|
||||
|
||||
upload_backups_to_gdrive: function() {
|
||||
cur_frm.save();
|
||||
},
|
||||
// upload_backups_to_gdrive: function() {
|
||||
// cur_frm.save();
|
||||
// },
|
||||
});
|
||||
@@ -7,8 +7,6 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
|
||||
ignore_list = []
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
@@ -39,10 +37,6 @@ def take_backups_dropbox():
|
||||
file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
|
||||
error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback())
|
||||
webnotes.errprint(error_message)
|
||||
|
||||
if not webnotes.conn:
|
||||
webnotes.connect()
|
||||
|
||||
send_email(False, "Dropbox", error_message)
|
||||
|
||||
#backup to gdrive
|
||||
@@ -62,6 +56,7 @@ def take_backups_gdrive():
|
||||
send_email(False, "Google Drive", error_message)
|
||||
|
||||
def send_email(success, service_name, error_status=None):
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
if success:
|
||||
subject = "Backup Upload Successful"
|
||||
message ="""<h3>Backup Uploaded Successfully</h3><p>Hi there, this is just to inform you
|
||||
@@ -76,7 +71,8 @@ def send_email(success, service_name, error_status=None):
|
||||
<p>Please contact your system manager for more information.</p>
|
||||
""" % (service_name, error_status)
|
||||
|
||||
# email system managers
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
sendmail(webnotes.conn.get_value("Backup Manager", None, "send_notifications_to").split(","),
|
||||
subject=subject, msg=message)
|
||||
if not webnotes.conn:
|
||||
webnotes.connect()
|
||||
|
||||
recipients = webnotes.conn.get_value("Backup Manager", None, "send_notifications_to").split(",")
|
||||
sendmail(recipients, subject=subject, msg=message)
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _, msgprint
|
||||
|
||||
from webnotes.utils import cstr
|
||||
from webnotes.utils import cstr, cint
|
||||
import webnotes.defaults
|
||||
|
||||
|
||||
@@ -237,21 +237,24 @@ class DocType:
|
||||
account.insert()
|
||||
|
||||
def set_default_accounts(self):
|
||||
accounts = {
|
||||
"default_income_account": "Sales",
|
||||
"default_expense_account": "Cost of Goods Sold",
|
||||
def _set_default_accounts(accounts):
|
||||
for a in accounts:
|
||||
account_name = accounts[a] + " - " + self.doc.abbr
|
||||
if not self.doc.fields.get(a) and webnotes.conn.exists("Account", account_name):
|
||||
webnotes.conn.set(self.doc, a, account_name)
|
||||
|
||||
_set_default_accounts({
|
||||
"receivables_group": "Accounts Receivable",
|
||||
"payables_group": "Accounts Payable",
|
||||
"default_cash_account": "Cash",
|
||||
"stock_received_but_not_billed": "Stock Received But Not Billed",
|
||||
"stock_adjustment_account": "Stock Adjustment",
|
||||
"expenses_included_in_valuation": "Expenses Included In Valuation"
|
||||
}
|
||||
"default_cash_account": "Cash"
|
||||
})
|
||||
|
||||
for a in accounts:
|
||||
account_name = accounts[a] + " - " + self.doc.abbr
|
||||
if not self.doc.fields.get(a) and webnotes.conn.exists("Account", account_name):
|
||||
webnotes.conn.set(self.doc, a, account_name)
|
||||
if cint(webnotes.conn.get_value("Accounts Settings", None, "auto_accounting_for_stock")):
|
||||
_set_default_accounts({
|
||||
"stock_received_but_not_billed": "Stock Received But Not Billed",
|
||||
"stock_adjustment_account": "Stock Adjustment",
|
||||
"expenses_included_in_valuation": "Expenses Included In Valuation"
|
||||
})
|
||||
|
||||
def create_default_cost_center(self):
|
||||
cc_list = [
|
||||
|
||||
@@ -70,8 +70,10 @@ cur_frm.cscript.addremove_recipients = function(doc, dt, dn) {
|
||||
check.checked = 1;
|
||||
add_or_update = 'Update';
|
||||
}
|
||||
var fullname = wn.user.full_name(v.name);
|
||||
if(fullname !== v.name) v.name = fullname + " <" + v.name + ">";
|
||||
if(v.enabled==0) {
|
||||
v.name = "<span style='color: red'>" + v.name + " (disabled user)</span>"
|
||||
v.name = repl("<span style='color: red'> %(name)s (disabled user)</span>", {name: v.name});
|
||||
}
|
||||
var profile = $a($td(tab, i+1, 1), 'span', '', '', v.name);
|
||||
//profile.onclick = function() { check.checked = !check.checked; }
|
||||
|
||||
@@ -9,6 +9,7 @@ from webnotes.utils import fmt_money, formatdate, now_datetime, cstr, esc, \
|
||||
from webnotes.utils.dateutils import datetime_in_user_format
|
||||
from datetime import timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
|
||||
content_sequence = [
|
||||
["Income / Expenses", ["income_year_to_date", "bank_balance",
|
||||
@@ -19,16 +20,16 @@ content_sequence = [
|
||||
["Selling", ["new_leads", "new_enquiries", "new_quotations", "new_sales_orders"]],
|
||||
["Stock", ["new_delivery_notes", "new_purchase_receipts", "new_stock_entries"]],
|
||||
["Support", ["new_communications", "new_support_tickets", "open_tickets"]],
|
||||
["Projects", ["new_projects"]]
|
||||
["Projects", ["new_projects"]],
|
||||
["System", ["scheduler_errors"]],
|
||||
]
|
||||
|
||||
user_specific_content = ["calendar_events", "todo_list"]
|
||||
|
||||
digest_template = """\
|
||||
<style>p.ed-indent { margin-right: 17px; }</style>
|
||||
<h2>%(digest)s</h2>
|
||||
<p style='color: grey'>%(date)s</p>
|
||||
digest_template = """<style>p.ed-indent { margin-right: 17px; }</style>
|
||||
<h2>%(name)s</h2>
|
||||
<h4>%(company)s</h4>
|
||||
<p style='color: grey'>%(date)s</p>
|
||||
<hr>
|
||||
%(with_value)s
|
||||
%(no_value)s
|
||||
@@ -53,10 +54,10 @@ class DocType(DocListController):
|
||||
|
||||
def get_profiles(self):
|
||||
"""get list of profiles"""
|
||||
import webnotes
|
||||
profile_list = webnotes.conn.sql("""
|
||||
select name, enabled from tabProfile
|
||||
where docstatus=0 and name not in ('Administrator', 'Guest')
|
||||
and user_type = "System User"
|
||||
order by enabled desc, name asc""", as_dict=1)
|
||||
|
||||
if self.doc.recipient_list:
|
||||
@@ -80,13 +81,15 @@ class DocType(DocListController):
|
||||
for user_id in recipients:
|
||||
msg_for_this_receipient = self.get_msg_html(self.get_user_specific_content(user_id) + \
|
||||
common_msg)
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
sendmail(recipients=user_id, subject="[ERPNext] " + (self.doc.frequency + " Digest"),
|
||||
msg=msg_for_this_receipient)
|
||||
if msg_for_this_receipient:
|
||||
sendmail(recipients=user_id,
|
||||
subject="[ERPNext] [{frequency} Digest] {name}".format(
|
||||
frequency=self.doc.frequency, name=self.doc.name),
|
||||
msg=msg_for_this_receipient)
|
||||
|
||||
def get_digest_msg(self):
|
||||
return self.get_msg_html(self.get_user_specific_content(webnotes.session.user) + \
|
||||
self.get_common_content())
|
||||
self.get_common_content(), send_only_if_updates=False)
|
||||
|
||||
def get_common_content(self):
|
||||
out = []
|
||||
@@ -117,14 +120,19 @@ class DocType(DocListController):
|
||||
|
||||
return out
|
||||
|
||||
def get_msg_html(self, out):
|
||||
def get_msg_html(self, out, send_only_if_updates=True):
|
||||
with_value = [o[1] for o in out if o[0]]
|
||||
|
||||
if with_value:
|
||||
has_updates = True
|
||||
with_value = "\n".join(with_value)
|
||||
else:
|
||||
with_value = "<p>There were no updates in the items selected for this digest.</p>"
|
||||
has_updates = False
|
||||
with_value = "<p>There were no updates in the items selected for this digest.</p><hr>"
|
||||
|
||||
if not has_updates and send_only_if_updates:
|
||||
return
|
||||
|
||||
# seperate out no value items
|
||||
no_value = [o[1] for o in out if not o[0]]
|
||||
if no_value:
|
||||
@@ -138,7 +146,8 @@ class DocType(DocListController):
|
||||
"date": date,
|
||||
"company": self.doc.company,
|
||||
"with_value": with_value,
|
||||
"no_value": no_value or ""
|
||||
"no_value": no_value or "",
|
||||
"name": self.doc.name
|
||||
}
|
||||
|
||||
return msg
|
||||
@@ -241,7 +250,7 @@ class DocType(DocListController):
|
||||
return self.get_new_count("Lead", self.meta.get_label("new_leads"))
|
||||
|
||||
def get_new_enquiries(self):
|
||||
return self.get_new_count("Opportunity", self.meta.get_label("new_enquiries"))
|
||||
return self.get_new_count("Opportunity", self.meta.get_label("new_enquiries"), docstatus=1)
|
||||
|
||||
def get_new_quotations(self):
|
||||
return self.get_new_sum("Quotation", self.meta.get_label("new_quotations"), "grand_total")
|
||||
@@ -253,7 +262,8 @@ class DocType(DocListController):
|
||||
return self.get_new_sum("Delivery Note", self.meta.get_label("new_delivery_notes"), "grand_total")
|
||||
|
||||
def get_new_purchase_requests(self):
|
||||
return self.get_new_count("Material Request", self.meta.get_label("new_purchase_requests"))
|
||||
return self.get_new_count("Material Request",
|
||||
self.meta.get_label("new_purchase_requests"), docstatus=1)
|
||||
|
||||
def get_new_supplier_quotations(self):
|
||||
return self.get_new_sum("Supplier Quotation", self.meta.get_label("new_supplier_quotations"),
|
||||
@@ -271,13 +281,16 @@ class DocType(DocListController):
|
||||
return self.get_new_sum("Stock Entry", self.meta.get_label("new_stock_entries"), "total_amount")
|
||||
|
||||
def get_new_support_tickets(self):
|
||||
return self.get_new_count("Support Ticket", self.meta.get_label("new_support_tickets"), False)
|
||||
return self.get_new_count("Support Ticket", self.meta.get_label("new_support_tickets"),
|
||||
filter_by_company=False)
|
||||
|
||||
def get_new_communications(self):
|
||||
return self.get_new_count("Communication", self.meta.get_label("new_communications"), False)
|
||||
return self.get_new_count("Communication", self.meta.get_label("new_communications"),
|
||||
filter_by_company=False)
|
||||
|
||||
def get_new_projects(self):
|
||||
return self.get_new_count("Project", self.meta.get_label("new_projects"), False)
|
||||
return self.get_new_count("Project", self.meta.get_label("new_projects"),
|
||||
filter_by_company=False)
|
||||
|
||||
def get_calendar_events(self, user_id):
|
||||
from core.doctype.event.event import get_events
|
||||
@@ -321,22 +334,22 @@ class DocType(DocListController):
|
||||
else:
|
||||
return 0, "<p>To Do</p>"
|
||||
|
||||
def get_new_count(self, doctype, label, filter_by_company=True):
|
||||
def get_new_count(self, doctype, label, docstatus=0, filter_by_company=True):
|
||||
if filter_by_company:
|
||||
company = """and company="%s" """ % self.doc.company
|
||||
else:
|
||||
company = ""
|
||||
count = webnotes.conn.sql("""select count(*) from `tab%s`
|
||||
where docstatus < 2 %s and
|
||||
date(creation)>=%s and date(creation)<=%s""" % (doctype, company, "%s", "%s"),
|
||||
(self.from_date, self.to_date))
|
||||
where docstatus=%s %s and
|
||||
date(creation)>=%s and date(creation)<=%s""" %
|
||||
(doctype, docstatus, company, "%s", "%s"), (self.from_date, self.to_date))
|
||||
count = count and count[0][0] or 0
|
||||
|
||||
return count, self.get_html(label, None, count)
|
||||
|
||||
def get_new_sum(self, doctype, label, sum_field):
|
||||
count_sum = webnotes.conn.sql("""select count(*), sum(ifnull(`%s`, 0))
|
||||
from `tab%s` where docstatus < 2 and company = %s and
|
||||
from `tab%s` where docstatus=1 and company = %s and
|
||||
date(creation)>=%s and date(creation)<=%s""" % (sum_field, doctype, "%s",
|
||||
"%s", "%s"), (self.doc.company, self.from_date, self.to_date))
|
||||
count, total = count_sum and count_sum[0] or (0, 0)
|
||||
@@ -448,6 +461,10 @@ class DocType(DocListController):
|
||||
t for t in open_tickets])
|
||||
else:
|
||||
return 0, "No Open Tickets!"
|
||||
|
||||
def get_scheduler_errors(self):
|
||||
import webnotes.utils.scheduler
|
||||
return webnotes.utils.scheduler.get_error_report(self.from_date, self.to_date)
|
||||
|
||||
def onload(self):
|
||||
self.get_next_sending()
|
||||
@@ -466,4 +483,4 @@ def send():
|
||||
where enabled=1 and docstatus<2""", as_list=1):
|
||||
ed_obj = get_obj('Email Digest', ed[0])
|
||||
if (now_date == ed_obj.get_next_sending()):
|
||||
ed_obj.send()
|
||||
ed_obj.send()
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-02-21 14:15:31",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:36:13",
|
||||
"modified": "2013-12-16 12:37:43",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -100,11 +100,10 @@
|
||||
"label": "Add/Remove Recipients"
|
||||
},
|
||||
{
|
||||
"description": "Check all the items below that you want to send in this digest.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "select_digest_content",
|
||||
"fieldname": "accounts",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Select Digest Content"
|
||||
"label": "Accounts"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -178,7 +177,7 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_20",
|
||||
"fieldtype": "Section Break",
|
||||
"options": "Simple"
|
||||
"label": "Buying & Selling"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -234,6 +233,12 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "New Sales Orders"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_34",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Inventory & Support"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_module",
|
||||
@@ -258,12 +263,6 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "New Stock Entries"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_34",
|
||||
"fieldtype": "Section Break",
|
||||
"options": "Simple"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "support_module",
|
||||
@@ -288,6 +287,12 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "New Communications"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_40",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Projects & System"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "projects_module",
|
||||
@@ -302,7 +307,25 @@
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "utilities_module",
|
||||
"fieldname": "core_module",
|
||||
"fieldtype": "Column Break",
|
||||
"label": "System"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "scheduler_errors",
|
||||
"fieldtype": "Check",
|
||||
"label": "Scheduler Failed Events"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "user_specific",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "User Specific"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "general",
|
||||
"fieldtype": "Column Break",
|
||||
"label": "General"
|
||||
},
|
||||
@@ -318,6 +341,12 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "To Do List"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stub",
|
||||
"fieldtype": "Column Break",
|
||||
"label": "Stub"
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2012-12-20 12:50:49",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-03 14:20:18",
|
||||
"modified": "2013-12-24 11:40:19",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -90,7 +90,7 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "fs_packing_details",
|
||||
"fieldtype": "Check",
|
||||
"label": "Packing Detials"
|
||||
"label": "Packing Details"
|
||||
},
|
||||
{
|
||||
"description": "To get Item Group in details table",
|
||||
|
||||
@@ -22,7 +22,7 @@ class DocType:
|
||||
where fieldname='naming_series'""")
|
||||
)))),
|
||||
"prefixes": "\n".join([''] + [i[0] for i in
|
||||
webnotes.conn.sql("""select name from tabSeries""")])
|
||||
webnotes.conn.sql("""select name from tabSeries order by name""")])
|
||||
}
|
||||
|
||||
def scrub_options_list(self, ol):
|
||||
@@ -38,7 +38,7 @@ class DocType:
|
||||
self.set_series_for(self.doc.select_doc_for_series, series_list)
|
||||
|
||||
# create series
|
||||
map(self.insert_series, series_list)
|
||||
map(self.insert_series, [d.split('.')[0] for d in series_list])
|
||||
|
||||
msgprint('Series Updated')
|
||||
|
||||
@@ -103,7 +103,8 @@ class DocType:
|
||||
dt.validate_series(series, self.doc.select_doc_for_series)
|
||||
for i in sr:
|
||||
if i[0]:
|
||||
if series in i[0].split("\n"):
|
||||
existing_series = [d.split('.')[0] for d in i[0].split("\n")]
|
||||
if series.split(".")[0] in existing_series:
|
||||
msgprint("Oops! Series name %s is already in use in %s. \
|
||||
Please select a new one" % (series, i[1]), raise_exception=1)
|
||||
|
||||
@@ -120,17 +121,21 @@ class DocType:
|
||||
|
||||
def get_current(self, arg=None):
|
||||
"""get series current"""
|
||||
self.doc.current_value = webnotes.conn.get_value("Series", self.doc.prefix, "current")
|
||||
self.doc.current_value = webnotes.conn.get_value("Series",
|
||||
self.doc.prefix.split('.')[0], "current")
|
||||
|
||||
def insert_series(self, series):
|
||||
"""insert series if missing"""
|
||||
if not webnotes.conn.exists('Series', series):
|
||||
webnotes.conn.sql("insert into tabSeries (name, current) values (%s,0)", (series))
|
||||
webnotes.conn.sql("insert into tabSeries (name, current) values (%s, 0)",
|
||||
(series))
|
||||
|
||||
def update_series_start(self):
|
||||
if self.doc.prefix:
|
||||
self.insert_series(self.doc.prefix)
|
||||
webnotes.conn.sql("update `tabSeries` set current = '%s' where name = '%s'" % (self.doc.current_value,self.doc.prefix))
|
||||
prefix = self.doc.prefix.split('.')[0]
|
||||
self.insert_series(prefix)
|
||||
webnotes.conn.sql("update `tabSeries` set current = %s where name = %s",
|
||||
(self.doc.current_value, prefix))
|
||||
msgprint("Series Updated Successfully")
|
||||
else:
|
||||
msgprint("Please select prefix first")
|
||||
|
||||
@@ -233,8 +233,9 @@ items = [
|
||||
"route": "Report/Scheduler Log", "type": "Link", "icon": "icon-exclamation-sign" },
|
||||
]
|
||||
|
||||
@webnotes.whitelist(allow_roles=["System Manager"])
|
||||
@webnotes.whitelist()
|
||||
def get():
|
||||
webnotes.only_for("System Manager")
|
||||
for item in items:
|
||||
if item.get("type")=="Section":
|
||||
continue
|
||||
|
||||
@@ -98,7 +98,8 @@ def create_price_lists(args):
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "Standard " + pl_type,
|
||||
"buying_or_selling": pl_type,
|
||||
"buying": 1 if pl_type == "Buying" else 0,
|
||||
"selling": 1 if pl_type == "Selling" else 0,
|
||||
"currency": args["currency"]
|
||||
},
|
||||
{
|
||||
@@ -158,6 +159,10 @@ def set_defaults(args):
|
||||
hr_settings.doc.emp_created_by = "Naming Series"
|
||||
hr_settings.save()
|
||||
|
||||
email_settings = webnotes.bean("Email Settings")
|
||||
email_settings.doc.send_print_in_body_and_attachment = 1
|
||||
email_settings.save()
|
||||
|
||||
# control panel
|
||||
cp = webnotes.doc("Control Panel", "Control Panel")
|
||||
cp.company_name = args["company_name"]
|
||||
@@ -171,11 +176,12 @@ def create_feed_and_todo():
|
||||
|
||||
def create_email_digest():
|
||||
from webnotes.profile import get_system_managers
|
||||
system_managers = get_system_managers()
|
||||
system_managers = get_system_managers(only_name=True)
|
||||
if not system_managers:
|
||||
return
|
||||
|
||||
for company in webnotes.conn.sql_list("select name FROM `tabCompany`"):
|
||||
companies = webnotes.conn.sql_list("select name FROM `tabCompany`")
|
||||
for company in companies:
|
||||
if not webnotes.conn.exists("Email Digest", "Default Weekly Digest - " + company):
|
||||
edigest = webnotes.bean({
|
||||
"doctype": "Email Digest",
|
||||
@@ -186,10 +192,24 @@ def create_email_digest():
|
||||
})
|
||||
|
||||
for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}):
|
||||
edigest.doc.fields[fieldname] = 1
|
||||
if fieldname != "scheduler_errors":
|
||||
edigest.doc.fields[fieldname] = 1
|
||||
|
||||
edigest.insert()
|
||||
|
||||
|
||||
# scheduler errors digest
|
||||
if companies:
|
||||
edigest = webnotes.new_bean("Email Digest")
|
||||
edigest.doc.fields.update({
|
||||
"name": "Scheduler Errors",
|
||||
"company": companies[0],
|
||||
"frequency": "Daily",
|
||||
"recipient_list": "\n".join(system_managers),
|
||||
"scheduler_errors": 1,
|
||||
"enabled": 1
|
||||
})
|
||||
edigest.insert()
|
||||
|
||||
def get_fy_details(fy_start_date, fy_end_date):
|
||||
start_year = getdate(fy_start_date).year
|
||||
if start_year == getdate(fy_end_date).year:
|
||||
|
||||
@@ -13,4 +13,5 @@ def on_method(bean, method):
|
||||
clear_doctype_notifications(bean.controller, method)
|
||||
|
||||
if bean.doc.doctype=="Stock Entry" and method in ("on_submit", "on_cancel"):
|
||||
update_completed_qty(bean.controller, method)
|
||||
update_completed_qty(bean.controller, method)
|
||||
|
||||
@@ -70,6 +70,6 @@ def on_build():
|
||||
|
||||
def comment_added(doc):
|
||||
"""add comment to feed"""
|
||||
home.make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by,
|
||||
'<i>"' + doc.comment + '"</i>', '#6B24B3')
|
||||
home.make_feed('Comment', doc.comment_doctype, doc.comment_docname,
|
||||
doc.comment_by or doc.owner, '<i>"' + doc.comment + '"</i>', '#6B24B3')
|
||||
|
||||
|
||||
@@ -34,10 +34,6 @@ def execute_daily():
|
||||
from core.doctype.notification_count.notification_count import delete_notification_count_for
|
||||
delete_notification_count_for("Event")
|
||||
|
||||
# email digest
|
||||
from setup.doctype.email_digest.email_digest import send
|
||||
run_fn(send)
|
||||
|
||||
# run recurring invoices
|
||||
from accounts.doctype.sales_invoice.sales_invoice import manage_recurring_invoices
|
||||
run_fn(manage_recurring_invoices)
|
||||
@@ -53,10 +49,15 @@ def execute_daily():
|
||||
# check reorder level
|
||||
from stock.utils import reorder_item
|
||||
run_fn(reorder_item)
|
||||
|
||||
# email digest
|
||||
from setup.doctype.email_digest.email_digest import send
|
||||
run_fn(send)
|
||||
|
||||
# auto close support tickets
|
||||
from support.doctype.support_ticket.support_ticket import auto_close_tickets
|
||||
run_fn(auto_close_tickets)
|
||||
|
||||
# scheduler error
|
||||
scheduler.report_errors()
|
||||
|
||||
def execute_weekly():
|
||||
from setup.doctype.backup_manager.backup_manager import take_backups_weekly
|
||||
run_fn(take_backups_weekly)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:09",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-12-09 16:24:08",
|
||||
"modified": "2013-12-14 17:26:12",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -1058,7 +1058,7 @@
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"match": "customer_name",
|
||||
"match": "customer",
|
||||
"role": "Customer"
|
||||
}
|
||||
]
|
||||
@@ -58,11 +58,6 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
self.assertEqual(stock_value, 0)
|
||||
self.assertEqual(stock_value_difference, -375)
|
||||
|
||||
|
||||
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Delivery Note' and voucher_no=%s
|
||||
order by account desc""", dn.doc.name, as_dict=1)
|
||||
|
||||
self.assertFalse(get_gl_entries("Delivery Note", dn.doc.name))
|
||||
|
||||
def test_delivery_note_gl_entry(self):
|
||||
@@ -111,8 +106,8 @@ class TestDeliveryNote(unittest.TestCase):
|
||||
gl_entries = get_gl_entries("Delivery Note", dn.doc.name)
|
||||
self.assertTrue(gl_entries)
|
||||
expected_values = {
|
||||
stock_in_hand_account: [0.0, 666.65],
|
||||
"Cost of Goods Sold - _TC": [666.65, 0.0]
|
||||
stock_in_hand_account: [0.0, 666.67],
|
||||
"Cost of Goods Sold - _TC": [666.67, 0.0]
|
||||
}
|
||||
for i, gle in enumerate(gl_entries):
|
||||
self.assertEquals([gle.debit, gle.credit], expected_values.get(gle.account))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user