Compare commits
194 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6448076143 | ||
|
|
3f657bcf51 | ||
|
|
937103f840 | ||
|
|
47fcc0310d | ||
|
|
7e676f3aae | ||
|
|
30aac9bbcf | ||
|
|
c2a5858143 | ||
|
|
879b3a0cbc | ||
|
|
ef0a0e8209 | ||
|
|
f7f20f624a | ||
|
|
115dcc09d4 | ||
|
|
990d7c4862 | ||
|
|
166024a23c | ||
|
|
3c4bb0c7c9 | ||
|
|
258191ab40 | ||
|
|
d66396abe3 | ||
|
|
7c1976950d | ||
|
|
158200b209 | ||
|
|
a570cd66f7 | ||
|
|
d7f3d63a8e | ||
|
|
2e67426936 | ||
|
|
16f88ba3cd | ||
|
|
e31a41854b | ||
|
|
7349c191ab | ||
|
|
dc540dda4d | ||
|
|
5c494f79f3 | ||
|
|
191935bbf5 | ||
|
|
8c78a1abb7 | ||
|
|
8821541f33 | ||
|
|
5cec7ec84a | ||
|
|
9d5566634c | ||
|
|
9536f112b5 | ||
|
|
44a40b860e | ||
|
|
b3d26c08f6 | ||
|
|
98d4622ed8 | ||
|
|
24b26db327 | ||
|
|
fa9fabaa49 | ||
|
|
49e8e783e3 | ||
|
|
c4ee74857d | ||
|
|
fc13b87fd5 | ||
|
|
d9ba544e09 | ||
|
|
af21479665 | ||
|
|
eec59ae7c4 | ||
|
|
efa9a7ed5b | ||
|
|
557abdebe0 | ||
|
|
8589b1db22 | ||
|
|
82a21beba0 | ||
|
|
256c4da0a5 | ||
|
|
7395dc9969 | ||
|
|
d39bc09e62 | ||
|
|
c7676797e1 | ||
|
|
423932fab2 | ||
|
|
efda5b0d36 | ||
|
|
13a9e27320 | ||
|
|
b0433d96a3 | ||
|
|
f3aba2e536 | ||
|
|
1594f102fd | ||
|
|
b2f2df4c64 | ||
|
|
9f6c48d82e | ||
|
|
f0307dc75e | ||
|
|
872e4d1f3d | ||
|
|
b164e606f9 | ||
|
|
806343395a | ||
|
|
afe93d633c | ||
|
|
cd20717c3d | ||
|
|
529709e08b | ||
|
|
e82eee512b | ||
|
|
ee0c623760 | ||
|
|
dbb4955483 | ||
|
|
ed87335513 | ||
|
|
8a4111fe0e | ||
|
|
4bfa8d560b | ||
|
|
96db41d996 | ||
|
|
9a74330d6f | ||
|
|
1951baca57 | ||
|
|
da08124df2 | ||
|
|
2aecc5a717 | ||
|
|
a37ffe162b | ||
|
|
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 |
File diff suppressed because one or more lines are too long
@@ -6,6 +6,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
from webnotes.utils import cint
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
@@ -14,7 +15,12 @@ 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:
|
||||
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:
|
||||
|
||||
@@ -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,7 +120,8 @@ cur_frm.cscript.refresh = function(doc) {
|
||||
"voucher_no": doc.name,
|
||||
"from_date": doc.posting_date,
|
||||
"to_date": doc.posting_date,
|
||||
"company": doc.company
|
||||
"company": doc.company,
|
||||
group_by_voucher: 0
|
||||
};
|
||||
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,7 +35,8 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||
"voucher_no": doc.name,
|
||||
"from_date": doc.posting_date,
|
||||
"to_date": doc.posting_date,
|
||||
"company": doc.company
|
||||
"company": doc.company,
|
||||
group_by_voucher: 0
|
||||
};
|
||||
wn.set_route("query-report", "General Ledger");
|
||||
}, "icon-table");
|
||||
|
||||
@@ -32,6 +32,9 @@ class DocType(BuyingController):
|
||||
}]
|
||||
|
||||
def validate(self):
|
||||
if not self.doc.is_opening:
|
||||
self.doc.is_opening = 'No'
|
||||
|
||||
super(DocType, self).validate()
|
||||
|
||||
self.po_required()
|
||||
@@ -45,15 +48,8 @@ class DocType(BuyingController):
|
||||
self.check_for_stopped_status()
|
||||
self.validate_with_previous_doc()
|
||||
self.validate_uom_is_integer("uom", "qty")
|
||||
|
||||
if not self.doc.is_opening:
|
||||
self.doc.is_opening = 'No'
|
||||
|
||||
self.set_aging_date()
|
||||
|
||||
#set against account for credit to
|
||||
self.set_against_expense_account()
|
||||
|
||||
self.validate_write_off_account()
|
||||
self.update_raw_material_cost()
|
||||
self.update_valuation_rate("entries")
|
||||
@@ -215,7 +211,8 @@ class DocType(BuyingController):
|
||||
against_accounts = []
|
||||
stock_items = self.get_stock_items()
|
||||
for item in self.doclist.get({"parentfield": "entries"}):
|
||||
if auto_accounting_for_stock and item.item_code in stock_items:
|
||||
if auto_accounting_for_stock and item.item_code in stock_items \
|
||||
and self.doc.is_opening == 'No':
|
||||
# in case of auto inventory accounting, against expense account is always
|
||||
# Stock Received But Not Billed for a stock item
|
||||
item.expense_head = stock_not_billed_account
|
||||
@@ -302,6 +299,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 +348,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,12 +356,8 @@ class DocType(BuyingController):
|
||||
# expense will be booked in sales invoice
|
||||
stock_item_and_auto_accounting_for_stock = True
|
||||
|
||||
valuation_amt = item.amount + item.item_tax_amount + item.rm_supp_cost
|
||||
|
||||
# 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({
|
||||
@@ -392,12 +385,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(
|
||||
@@ -432,7 +419,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):
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
{
|
||||
"creation": "2013-01-10 16:34:08",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-22 15:22:25",
|
||||
"modified": "2014-01-28 12:28:56",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "wasim@webnotestech.com"
|
||||
},
|
||||
{
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:title",
|
||||
"description": "Standard tax template that can be applied to all Purchase Transactions. This template can contain list of tax heads and also other expense heads like \"Shipping\", \"Insurance\", \"Handling\" etc.\n\n#### Note\n\nThe tax rate you define here will be the standard tax rate for all **Items**. If there are **Items** that have different rates, they must be added in the **Item Tax** table in the **Item** master.\n\n#### Description of Columns\n\n1. Calculation Type: \n - This can be on **Net Total** (that is the sum of basic amount).\n - **On Previous Row Total / Amount** (for cumulative taxes or charges). If you select this option, the tax will be applied as a percentage of the previous row (in the tax table) amount or total.\n - **Actual** (as mentioned).\n2. Account Head: The Account ledger under which this tax will be booked\n3. Cost Center: If the tax / charge is an income (like shipping) or expense it needs to be booked against a Cost Center.\n4. Description: Description of the tax (that will be printed in invoices / quotes).\n5. Rate: Tax rate.\n6. Amount: Tax amount.\n7. Total: Cumulative total to this point.\n8. Enter Row: If based on \"Previous Row Total\" you can select the row number which will be taken as a base for this calculation (default is the previous row).\n9. Consider Tax or Charge for: In this section you can specify if the tax / charge is only for valuation (not a part of total) or only for total (does not add value to the item) or for both.\n10. Add or Deduct: Whether you want to add or deduct the tax.",
|
||||
"doctype": "DocType",
|
||||
|
||||
@@ -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() {
|
||||
@@ -101,6 +109,7 @@ erpnext.POS = Class.extend({
|
||||
this.party = party;
|
||||
this.price_list = (party == "Customer" ?
|
||||
this.frm.doc.selling_price_list : this.frm.doc.buying_price_list);
|
||||
this.price_list_field = (party == "Customer" ? "selling_price_list" : "buying_price_list");
|
||||
this.sales_or_purchase = (party == "Customer" ? "Sales" : "Purchase");
|
||||
this.net_total = "net_total_" + export_or_import;
|
||||
this.grand_total = "grand_total_" + export_or_import;
|
||||
@@ -261,22 +270,17 @@ erpnext.POS = Class.extend({
|
||||
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
|
||||
if (d.item_code == item_code) {
|
||||
caught = true;
|
||||
if (serial_no) {
|
||||
d.serial_no += '\n' + serial_no;
|
||||
me.frm.script_manager.trigger("serial_no", d.doctype, d.name);
|
||||
}
|
||||
else {
|
||||
d.qty += 1;
|
||||
me.frm.script_manager.trigger("qty", d.doctype, d.name);
|
||||
}
|
||||
if (serial_no)
|
||||
wn.model.set_value(d.doctype, d.name, "serial_no", d.serial_no + '\n' + serial_no);
|
||||
else
|
||||
wn.model.set_value(d.doctype, d.name, "qty", d.qty + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// if item not found then add new item
|
||||
if (!caught) {
|
||||
if (!caught)
|
||||
this.add_new_item_to_grid(item_code, serial_no);
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
this.refresh_search_box();
|
||||
@@ -311,15 +315,16 @@ erpnext.POS = Class.extend({
|
||||
wn.model.clear_doc(d.doctype, d.name);
|
||||
me.refresh_grid();
|
||||
} else {
|
||||
d.qty = qty;
|
||||
me.frm.script_manager.trigger("qty", d.doctype, d.name);
|
||||
wn.model.set_value(d.doctype, d.name, "qty", qty);
|
||||
}
|
||||
}
|
||||
});
|
||||
me.refresh();
|
||||
this.refresh();
|
||||
},
|
||||
refresh: function() {
|
||||
var me = this;
|
||||
|
||||
this.refresh_item_list();
|
||||
this.party_field.set_input(this.frm.doc[this.party.toLowerCase()]);
|
||||
this.barcode.set_input("");
|
||||
|
||||
@@ -333,7 +338,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") {
|
||||
@@ -342,6 +347,14 @@ erpnext.POS = Class.extend({
|
||||
this.make_party();
|
||||
}
|
||||
},
|
||||
refresh_item_list: function() {
|
||||
var me = this;
|
||||
// refresh item list on change of price list
|
||||
if (this.frm.doc[this.price_list_field] != this.price_list) {
|
||||
this.price_list = this.frm.doc[this.price_list_field];
|
||||
this.make_item_list();
|
||||
}
|
||||
},
|
||||
show_items_in_item_cart: function() {
|
||||
var me = this;
|
||||
var $items = this.wrapper.find("#cart tbody").empty();
|
||||
@@ -351,8 +364,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 +387,31 @@ erpnext.POS = Class.extend({
|
||||
}
|
||||
)).appendTo($items);
|
||||
});
|
||||
|
||||
this.wrapper.find("input.qty").on("focus", function() {
|
||||
$(this).select();
|
||||
});
|
||||
},
|
||||
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() {
|
||||
@@ -399,10 +426,16 @@ erpnext.POS = Class.extend({
|
||||
|
||||
// append quantity to the respective item after change from input box
|
||||
$(this.wrapper).find("input.qty").on("change", function() {
|
||||
var item_code = $(this).closest("tr")[0].id;
|
||||
var item_code = $(this).closest("tr").attr("id");
|
||||
me.update_qty(item_code, $(this).val());
|
||||
});
|
||||
|
||||
// increase/decrease qty on plus/minus button
|
||||
$(this.wrapper).find(".increase-qty, .decrease-qty").on("click", function() {
|
||||
var tr = $(this).closest("tr");
|
||||
me.increase_decrease_qty(tr, $(this).attr("class"));
|
||||
});
|
||||
|
||||
// on td click toggle the highlighting of row
|
||||
$(this.wrapper).find("#cart tbody tr td").on("click", function() {
|
||||
var row = $(this).closest("tr");
|
||||
@@ -420,6 +453,15 @@ erpnext.POS = Class.extend({
|
||||
me.refresh_delete_btn();
|
||||
this.barcode.$input.focus();
|
||||
},
|
||||
increase_decrease_qty: function(tr, operation) {
|
||||
var item_code = tr.attr("id");
|
||||
var item_qty = cint(tr.find("input.qty").val());
|
||||
|
||||
if (operation == "increase-qty")
|
||||
this.update_qty(item_code, item_qty + 1);
|
||||
else if (operation == "decrease-qty" && item_qty != 1)
|
||||
this.update_qty(item_code, item_qty - 1);
|
||||
},
|
||||
disable_text_box_and_button: function() {
|
||||
var me = this;
|
||||
// if form is submitted & cancelled then disable all input box & buttons
|
||||
@@ -427,7 +469,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 +479,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 +508,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,9 +529,11 @@ erpnext.POS = Class.extend({
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.refresh_grid();
|
||||
},
|
||||
refresh_grid: function() {
|
||||
this.frm.dirty();
|
||||
this.frm.fields_dict[this.frm.cscript.fname].grid.refresh();
|
||||
this.frm.script_manager.trigger("calculate_taxes_and_totals");
|
||||
this.refresh();
|
||||
|
||||
@@ -54,7 +54,8 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
"voucher_no": doc.name,
|
||||
"from_date": doc.posting_date,
|
||||
"to_date": doc.posting_date,
|
||||
"company": doc.company
|
||||
"company": doc.company,
|
||||
group_by_voucher: 0
|
||||
};
|
||||
wn.set_route("query-report", "General Ledger");
|
||||
}, "icon-table");
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -318,12 +320,9 @@ class DocType(SellingController):
|
||||
item = webnotes.conn.sql("select name,is_asset_item,is_sales_item from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())"% d.item_code)
|
||||
acc = webnotes.conn.sql("select account_type from `tabAccount` where name = '%s' and docstatus != 2" % d.income_account)
|
||||
if not acc:
|
||||
msgprint("Account: "+d.income_account+" does not exist in the system")
|
||||
raise Exception
|
||||
msgprint("Account: "+d.income_account+" does not exist in the system", raise_exception=True)
|
||||
elif item and item[0][1] == 'Yes' and not acc[0][0] == 'Fixed Asset Account':
|
||||
msgprint("Please select income head with account type 'Fixed Asset Account' as Item %s is an asset item" % d.item_code)
|
||||
raise Exception
|
||||
|
||||
msgprint("Please select income head with account type 'Fixed Asset Account' as Item %s is an asset item" % d.item_code, raise_exception=True)
|
||||
|
||||
def validate_with_previous_doc(self):
|
||||
super(DocType, self).validate_with_previous_doc(self.tname, {
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
@@ -565,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,11 +2,12 @@
|
||||
{
|
||||
"creation": "2013-01-10 16:34:09",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-10-31 19:25:09",
|
||||
"modified": "2014-01-28 12:28:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:title",
|
||||
"description": "Standard tax template that can be applied to all Sales Transactions. This template can contain list of tax heads and also other expense / income heads like \"Shipping\", \"Insurance\", \"Handling\" etc.\n\n#### Note\n\nThe tax rate you define here will be the standard tax rate for all **Items**. If there are **Items** that have different rates, they must be added in the **Item Tax** table in the **Item** master.\n\n#### Description of Columns\n\n1. Calculation Type: \n - This can be on **Net Total** (that is the sum of basic amount).\n - **On Previous Row Total / Amount** (for cumulative taxes or charges). If you select this option, the tax will be applied as a percentage of the previous row (in the tax table) amount or total.\n - **Actual** (as mentioned).\n2. Account Head: The Account ledger under which this tax will be booked\n3. Cost Center: If the tax / charge is an income (like shipping) or expense it needs to be booked against a Cost Center.\n4. Description: Description of the tax (that will be printed in invoices / quotes).\n5. Rate: Tax rate.\n6. Amount: Tax amount.\n7. Total: Cumulative total to this point.\n8. Enter Row: If based on \"Previous Row Total\" you can select the row number which will be taken as a base for this calculation (default is the previous row).\n9. Is this Tax included in Basic Rate?: If you check this, it means that this tax will not be shown below the item table, but will be included in the Basic Rate in your main item table. This is useful where you want give a flat price (inclusive of all taxes) price to customers.",
|
||||
"doctype": "DocType",
|
||||
|
||||
@@ -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,37 @@ 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):
|
||||
from accounts.utils import get_currency_precision
|
||||
currency_precision = get_currency_precision() or 2
|
||||
|
||||
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.1/10**currency_precision:
|
||||
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 +53,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 +81,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
|
||||
|
||||
@@ -105,7 +132,7 @@ class AccountsReceivableReport(object):
|
||||
if not hasattr(self, "gl_entries"):
|
||||
conditions, values = self.prepare_conditions()
|
||||
self.gl_entries = webnotes.conn.sql("""select * from `tabGL Entry`
|
||||
where docstatus < 2 {} order by posting_date, account""".format(conditions),
|
||||
where docstatus < 2 {0} order by posting_date, account""".format(conditions),
|
||||
values, as_dict=True)
|
||||
|
||||
return self.gl_entries
|
||||
@@ -126,8 +153,8 @@ class AccountsReceivableReport(object):
|
||||
if not account_map:
|
||||
webnotes.throw(_("No Customer Accounts found."))
|
||||
else:
|
||||
accounts_list = ['"{}"'.format(ac) for ac in account_map]
|
||||
conditions.append("account in ({})".format(", ".join(accounts_list)))
|
||||
accounts_list = ['"{0}"'.format(ac) for ac in account_map]
|
||||
conditions.append("account in ({0})".format(", ".join(accounts_list)))
|
||||
|
||||
return " and ".join(conditions), values
|
||||
|
||||
@@ -147,7 +174,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]
|
||||
@@ -38,7 +38,7 @@ wn.query_reports["General Ledger"] = {
|
||||
"get_query": function() {
|
||||
var company = wn.query_report.filters_by_name.company.get_value();
|
||||
return {
|
||||
"query": "accounts.utils.get_account_list",
|
||||
"doctype": "Account",
|
||||
"filters": {
|
||||
"company": company,
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ def validate_filters(filters, account_details):
|
||||
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"]
|
||||
"Against Account::120", "Cost Center:Link/Cost Center:100", "Remarks::400"]
|
||||
|
||||
def get_result(filters, account_details):
|
||||
gl_entries = get_gl_entries(filters)
|
||||
@@ -51,7 +51,7 @@ def get_gl_entries(filters):
|
||||
|
||||
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
|
||||
voucher_type, voucher_no, cost_center, remarks, is_opening, against
|
||||
from `tabGL Entry`
|
||||
where company=%(company)s {conditions}
|
||||
{group_by_condition}
|
||||
@@ -72,6 +72,11 @@ def get_conditions(filters):
|
||||
|
||||
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 ""
|
||||
|
||||
@@ -133,10 +138,10 @@ def get_accountwise_gle(filters, gl_entries, gle_map):
|
||||
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"):
|
||||
or cstr(gle.is_opening) == "Yes"):
|
||||
gle_map[gle.account].opening += amount
|
||||
opening += amount
|
||||
elif gle.posting_date < filters.to_date:
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
@@ -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):
|
||||
@@ -369,3 +379,12 @@ def get_account_for(account_for_doctype, account_for):
|
||||
|
||||
return webnotes.conn.get_value("Account", {account_for_field: account_for_doctype,
|
||||
"master_name": account_for})
|
||||
|
||||
def get_currency_precision(currency=None):
|
||||
if not currency:
|
||||
currency = webnotes.conn.get_value("Company",
|
||||
webnotes.conn.get_default("company"), "default_currency")
|
||||
currency_format = webnotes.conn.get_value("Currency", currency, "number_format")
|
||||
|
||||
from webnotes.utils import get_number_format_info
|
||||
return get_number_format_info(currency_format)[2]
|
||||
@@ -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() {
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
wn.require('app/setup/doctype/contact_control/contact_control.js');
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
cur_frm.cscript.make_dashboard(doc);
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
@@ -93,8 +93,8 @@ cur_frm.cscript.make_contact = function() {
|
||||
cur_frm.contact_list.run();
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['default_price_list'].get_query = function(doc,cdt,cdn) {
|
||||
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-13 16:10:02",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-13 16:21:07",
|
||||
"modified": "2014-01-24 18:19:11",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -11,7 +11,7 @@
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"name": "__common__",
|
||||
"query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tmr_item.qty as \"Qty:Float:100\",\n\tmr_item.ordered_qty as \"Ordered Qty:Float:100\", \n\t(mr_item.qty - ifnull(mr_item.ordered_qty, 0)) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\n\tand ifnull(mr_item.ordered_qty, 0) < ifnull(mr_item.qty, 0)\norder by mr.transaction_date asc",
|
||||
"query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tsum(ifnull(mr_item.qty, 0)) as \"Qty:Float:100\",\n\tsum(ifnull(mr_item.ordered_qty, 0)) as \"Ordered Qty:Float:100\", \n\t(sum(mr_item.qty) - sum(ifnull(mr_item.ordered_qty, 0))) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\ngroup by mr.name, mr_item.item_code\nhaving\n\tsum(ifnull(mr_item.ordered_qty, 0)) < sum(ifnull(mr_item.qty, 0))\norder by mr.transaction_date asc",
|
||||
"ref_doctype": "Purchase Order",
|
||||
"report_name": "Requested Items To Be Ordered",
|
||||
"report_type": "Query Report"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -89,8 +89,10 @@ 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'""",
|
||||
price_list_rate = webnotes.conn.sql("""select ip.ref_rate from
|
||||
`tabItem Price` ip, `tabPrice List` pl
|
||||
where ip.price_list=pl.name and ip.price_list=%s and
|
||||
ip.item_code=%s and ip.buying=1 and pl.enabled=1""",
|
||||
(args.buying_price_list, args.item_code), as_dict=1)
|
||||
|
||||
if price_list_rate:
|
||||
@@ -122,14 +124,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.4.1",
|
||||
"app_version": "3.8.0",
|
||||
"base_template": "app/portal/templates/base.html",
|
||||
"modules": {
|
||||
"Accounts": {
|
||||
@@ -74,5 +74,5 @@
|
||||
"type": "module"
|
||||
}
|
||||
},
|
||||
"requires_framework_version": "==3.4.1"
|
||||
"requires_framework_version": "==3.9.0"
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -124,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"))
|
||||
|
||||
@@ -137,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:
|
||||
@@ -163,30 +181,49 @@ 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)
|
||||
|
||||
# if no item code, which is sometimes the case in purchase invoice,
|
||||
# then it is not possible to track valuation against it
|
||||
|
||||
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -243,10 +243,10 @@ class DocType:
|
||||
"item_code": [qty_required, description, stock_uom, min_order_qty]
|
||||
}
|
||||
"""
|
||||
bom_wise_item_details = {}
|
||||
item_list = []
|
||||
|
||||
for bom, so_wise_qty in bom_dict.items():
|
||||
bom_wise_item_details = {}
|
||||
if self.doc.use_multi_level_bom:
|
||||
# get all raw materials with sub assembly childs
|
||||
for d in webnotes.conn.sql("""select fb.item_code,
|
||||
|
||||
0
patches/1401/__init__.py
Normal file
0
patches/1401/__init__.py
Normal file
9
patches/1401/enable_all_price_list.py
Normal file
9
patches/1401/enable_all_price_list.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# 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.conn.sql("""update `tabPrice List` set enabled=1""")
|
||||
13
patches/1401/fix_planned_qty.py
Normal file
13
patches/1401/fix_planned_qty.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
webnotes.conn.auto_commit_on_many_writes = 1
|
||||
from utilities.repost_stock import repost_stock
|
||||
for d in webnotes.conn.sql("""select distinct production_item, fg_warehouse
|
||||
from `tabProduction Order` where docstatus>0""", as_dict=1):
|
||||
repost_stock(d.production_item, d.fg_warehouse)
|
||||
|
||||
webnotes.conn.auto_commit_on_many_writes = 0
|
||||
17
patches/1401/fix_serial_no_status_and_warehouse.py
Normal file
17
patches/1401/fix_serial_no_status_and_warehouse.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
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
serial_nos = webnotes.conn.sql("""select name from `tabSerial No` where docstatus=0
|
||||
and status in ('Available', 'Sales Returned') and ifnull(warehouse, '') = ''""")
|
||||
for sr in serial_nos:
|
||||
try:
|
||||
sr_bean = webnotes.bean("Serial No", sr[0])
|
||||
sr_bean.make_controller().via_stock_ledger = True
|
||||
sr_bean.save()
|
||||
webnotes.conn.commit()
|
||||
except:
|
||||
pass
|
||||
@@ -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)
|
||||
@@ -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""")
|
||||
@@ -263,4 +263,10 @@ patch_list = [
|
||||
"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",
|
||||
"patches.1401.enable_all_price_list",
|
||||
"patches.1401.fix_serial_no_status_and_warehouse",
|
||||
"patches.1401.fix_planned_qty",
|
||||
]
|
||||
@@ -10,9 +10,9 @@
|
||||
<li class="active"><i class="icon-file icon-fixed-width"></i> {{ doc.name }}</li>
|
||||
</ul>
|
||||
<h3><i class="icon-file icon-fixed-width"></i> {{ doc.name }}</h3>
|
||||
{% if doc.name == "Not Allowed" -%}
|
||||
{% if session_user == "Guest" -%}
|
||||
<script>ask_to_login();</script>
|
||||
{% else %}
|
||||
{% elif doc.name != "Not Allowed"%}
|
||||
<hr>
|
||||
<div>
|
||||
<div class="row">
|
||||
|
||||
@@ -41,21 +41,23 @@ def get_currency_context():
|
||||
}
|
||||
|
||||
def get_transaction_context(doctype, name):
|
||||
context = {"session_user": webnotes.session.user}
|
||||
|
||||
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
|
||||
"customer")
|
||||
|
||||
bean = webnotes.bean(doctype, name)
|
||||
if bean.doc.customer != customer:
|
||||
return {
|
||||
"doc": {"name": "Not Allowed"}
|
||||
}
|
||||
context.update({"doc": {"name": "Not Allowed"}})
|
||||
else:
|
||||
return {
|
||||
context.update({
|
||||
"doc": bean.doc,
|
||||
"doclist": bean.doclist,
|
||||
"webnotes": webnotes,
|
||||
"utils": webnotes.utils
|
||||
}
|
||||
})
|
||||
|
||||
return context
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def send_message(subject="Website Query", message="", sender="", status="Open"):
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +28,8 @@ erpnext.stock.StockController = wn.ui.form.Controller.extend({
|
||||
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
|
||||
company: me.frm.doc.company,
|
||||
group_by_voucher: false
|
||||
};
|
||||
wn.set_route("query-report", "General Ledger");
|
||||
}, "icon-table");
|
||||
|
||||
@@ -7,35 +7,35 @@ $.extend(erpnext.queries, {
|
||||
profile: function() {
|
||||
return { query: "core.doctype.profile.profile.profile_query" };
|
||||
},
|
||||
|
||||
|
||||
lead: function() {
|
||||
return { query: "controllers.queries.lead_query" };
|
||||
},
|
||||
|
||||
|
||||
customer: function() {
|
||||
return { query: "controllers.queries.customer_query" };
|
||||
},
|
||||
|
||||
|
||||
supplier: function() {
|
||||
return { query: "controllers.queries.supplier_query" };
|
||||
},
|
||||
|
||||
|
||||
account: function() {
|
||||
return { query: "controllers.queries.account_query" };
|
||||
},
|
||||
|
||||
|
||||
item: function() {
|
||||
return { query: "controllers.queries.item_query" };
|
||||
},
|
||||
|
||||
|
||||
bom: function() {
|
||||
return { query: "controllers.queries.bom" };
|
||||
},
|
||||
|
||||
|
||||
task: function() {
|
||||
return { query: "projects.utils.query_task" };
|
||||
},
|
||||
|
||||
|
||||
customer_filter: function(doc) {
|
||||
if(!doc.customer) {
|
||||
wn.throw(wn._("Please specify a") + " " +
|
||||
@@ -44,7 +44,7 @@ $.extend(erpnext.queries, {
|
||||
|
||||
return { filters: { customer: doc.customer } };
|
||||
},
|
||||
|
||||
|
||||
supplier_filter: function(doc) {
|
||||
if(!doc.supplier) {
|
||||
wn.throw(wn._("Please specify a") + " " +
|
||||
@@ -53,9 +53,17 @@ $.extend(erpnext.queries, {
|
||||
|
||||
return { filters: { supplier: doc.supplier } };
|
||||
},
|
||||
|
||||
|
||||
lead_filter: function(doc) {
|
||||
if(!doc.lead) {
|
||||
wn.throw(wn._("Please specify a") + " " +
|
||||
wn._(wn.meta.get_label(doc.doctype, "lead", doc.name)));
|
||||
}
|
||||
|
||||
return { filters: { lead: doc.lead } };
|
||||
},
|
||||
|
||||
not_a_group_filter: function() {
|
||||
return { filters: { is_group: "No" } };
|
||||
},
|
||||
|
||||
});
|
||||
@@ -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",
|
||||
|
||||
@@ -18,7 +18,7 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) {
|
||||
cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
|
||||
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
cur_frm.cscript.setup_dashboard(doc);
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
@@ -107,21 +107,21 @@ cur_frm.cscript.make_contact = function() {
|
||||
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['customer_group'].get_query = function(doc,dt,dn) {
|
||||
cur_frm.fields_dict['customer_group'].get_query = function(doc, dt, dn) {
|
||||
return{
|
||||
filters:{'is_group': 'No'}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_frm.fields_dict.lead_name.get_query = function(doc,cdt,cdn) {
|
||||
cur_frm.fields_dict.lead_name.get_query = function(doc, cdt, cdn) {
|
||||
return{
|
||||
query:"controllers.queries.lead_query"
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['default_price_list'].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}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ erpnext.selling.Opportunity = wn.ui.form.Controller.extend({
|
||||
if(!this.frm.doc.enquiry_from)
|
||||
hide_field(['customer', 'customer_address', 'contact_person', 'customer_name','lead', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
|
||||
if(!this.frm.doc.status)
|
||||
set_multiple(cdt,cdn,{status:'Draft'});
|
||||
set_multiple(cdt, cdn, { status:'Draft' });
|
||||
if(!this.frm.doc.date)
|
||||
this.frm.doc.transaction_date = date.obj_to_str(new Date());
|
||||
if(!this.frm.doc.company && wn.defaults.get_default("company"))
|
||||
set_multiple(cdt,cdn,{company:wn.defaults.get_default("company")});
|
||||
if(!this.frm.doc.fiscal_year && sys_defaults.fiscal_year)
|
||||
set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
|
||||
set_multiple(cdt, cdn, { company:wn.defaults.get_default("company") });
|
||||
if(!this.frm.doc.fiscal_year && sys_defaults.fiscal_year)
|
||||
set_multiple(cdt, cdn, { fiscal_year:sys_defaults.fiscal_year });
|
||||
|
||||
if(this.frm.doc.enquiry_from) {
|
||||
if(this.frm.doc.enquiry_from == 'Customer') {
|
||||
@@ -99,15 +99,15 @@ erpnext.selling.Opportunity = wn.ui.form.Controller.extend({
|
||||
|
||||
$.extend(cur_frm.cscript, new erpnext.selling.Opportunity({frm: cur_frm}));
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn){
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
erpnext.hide_naming_series();
|
||||
cur_frm.clear_custom_buttons();
|
||||
|
||||
if(doc.docstatus === 1 && doc.status!=="Lost") {
|
||||
cur_frm.add_custom_button(wn._('Create Quotation'), cur_frm.cscript.create_quotation);
|
||||
if(doc.status!=="Quotation") {
|
||||
if(doc.status!=="Quotation")
|
||||
cur_frm.add_custom_button(wn._('Opportunity Lost'), cur_frm.cscript['Declare Opportunity Lost']);
|
||||
}
|
||||
|
||||
cur_frm.add_custom_button(wn._('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone");
|
||||
}
|
||||
|
||||
@@ -116,31 +116,29 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn){
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
||||
if(doc.enquiry_from == 'Lead' && doc.lead) {
|
||||
cur_frm.cscript.lead(doc,cdt,cdn);
|
||||
}
|
||||
if(doc.enquiry_from == 'Lead' && doc.lead)
|
||||
cur_frm.cscript.lead(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.item_code = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.item_code) {
|
||||
return get_server_fields('get_item_details',d.item_code, 'enquiry_details',doc, cdt,cdn,1);
|
||||
}
|
||||
if (d.item_code)
|
||||
return get_server_fields('get_item_details', d.item_code, 'enquiry_details', doc, cdt, cdn, 1);
|
||||
}
|
||||
|
||||
// hide - unhide fields on basis of enquiry_from lead or customer
|
||||
cur_frm.cscript.enquiry_from = function(doc,cdt,cdn){
|
||||
cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
|
||||
cur_frm.cscript.enquiry_from = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.lead_cust_show(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
// hide - unhide fields based on lead or customer
|
||||
cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
|
||||
if(doc.enquiry_from == 'Lead'){
|
||||
cur_frm.cscript.lead_cust_show = function(doc, cdt, cdn) {
|
||||
if(doc.enquiry_from == 'Lead') {
|
||||
unhide_field(['lead']);
|
||||
hide_field(['customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
|
||||
doc.lead = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
|
||||
}
|
||||
else if(doc.enquiry_from == 'Customer'){
|
||||
else if(doc.enquiry_from == 'Customer') {
|
||||
unhide_field(['customer']);
|
||||
hide_field(['lead', 'address_display', 'contact_display', 'contact_mobile',
|
||||
'contact_email', 'territory', 'customer_group']);
|
||||
@@ -164,15 +162,13 @@ cur_frm.cscript.lead = function(doc, cdt, cdn) {
|
||||
wn.model.map_current_doc({
|
||||
method: "selling.doctype.lead.lead.make_opportunity",
|
||||
source_name: cur_frm.doc.lead
|
||||
})
|
||||
});
|
||||
|
||||
unhide_field(['customer_name', 'address_display','contact_mobile', 'customer_address',
|
||||
'contact_email', 'territory']);
|
||||
'contact_email', 'territory']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
cur_frm.cscript['Declare Opportunity Lost'] = function(){
|
||||
cur_frm.cscript['Declare Opportunity Lost'] = function() {
|
||||
var dialog = new wn.ui.Dialog({
|
||||
title: wn._("Set as Lost"),
|
||||
fields: [
|
||||
@@ -200,5 +196,4 @@ cur_frm.cscript['Declare Opportunity Lost'] = function(){
|
||||
})
|
||||
});
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
@@ -15,12 +15,21 @@ wn.require('app/accounts/doctype/sales_invoice/pos.js');
|
||||
|
||||
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
onload: function(doc, dt, dn) {
|
||||
var me = this;
|
||||
this._super(doc, dt, dn);
|
||||
if(doc.customer && !doc.quotation_to)
|
||||
doc.quotation_to = "Customer";
|
||||
else if(doc.lead && !doc.quotation_to)
|
||||
doc.quotation_to = "Lead";
|
||||
|
||||
|
||||
// to overwrite the customer_filter trigger from queries.js
|
||||
if (doc.lead) {
|
||||
$.each(["customer_address", "shipping_address_name"],
|
||||
function(i, opts) {
|
||||
me.frm.set_query(opts, erpnext.queries["lead_filter"]);
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
refresh: function(doc, dt, dn) {
|
||||
this._super(doc, dt, dn);
|
||||
@@ -68,6 +77,12 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
quotation_to: function() {
|
||||
this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead");
|
||||
this.frm.toggle_reqd("customer", this.frm.doc.quotation_to == "Customer");
|
||||
if (this.frm.doc.quotation_to == "Lead") {
|
||||
this.frm.set_value("customer", null);
|
||||
this.frm.set_value("contact_person", null);
|
||||
}
|
||||
else if (this.frm.doc.quotation_to == "Customer")
|
||||
this.frm.set_value("lead", null);
|
||||
},
|
||||
|
||||
tc_name: function() {
|
||||
@@ -89,7 +104,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
|
||||
cur_frm.script_manager.make(erpnext.selling.QuotationController);
|
||||
|
||||
cur_frm.fields_dict.lead.get_query = function(doc,cdt,cdn) {
|
||||
cur_frm.fields_dict.lead.get_query = function(doc, cdt, cdn) {
|
||||
return{ query:"controllers.queries.lead_query" } }
|
||||
|
||||
cur_frm.cscript.lead = function(doc, cdt, cdn) {
|
||||
@@ -152,7 +167,6 @@ cur_frm.cscript['Declare Order Lost'] = function(){
|
||||
}
|
||||
|
||||
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||
if(cint(wn.boot.notification_settings.quotation)) {
|
||||
if(cint(wn.boot.notification_settings.quotation))
|
||||
cur_frm.email_doc(wn.boot.notification_settings.quotation_message);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,10 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import _, msgprint
|
||||
|
||||
|
||||
|
||||
from controllers.selling_controller import SellingController
|
||||
|
||||
class DocType(SellingController):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:08",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-12-14 17:25:46",
|
||||
"modified": "2014-01-29 19:42:32",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -665,6 +665,7 @@
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.customer",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "contact_person",
|
||||
"fieldtype": "Link",
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -10,11 +10,12 @@ no_cache = True
|
||||
def get_context():
|
||||
from portal.utils import get_transaction_context
|
||||
context = get_transaction_context("Sales Order", webnotes.form_dict.name)
|
||||
modify_status(context.get("doc"))
|
||||
context.update({
|
||||
"parent_link": "orders",
|
||||
"parent_title": "My Orders"
|
||||
})
|
||||
if context.get("doc").get("name") != "Not Allowed":
|
||||
modify_status(context.get("doc"))
|
||||
context.update({
|
||||
"parent_link": "orders",
|
||||
"parent_title": "My Orders"
|
||||
})
|
||||
return context
|
||||
|
||||
def modify_status(doc):
|
||||
|
||||
@@ -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 } };
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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 \
|
||||
@@ -146,8 +150,10 @@ def _get_basic_details(args, item_bean, warehouse_fieldname):
|
||||
return out
|
||||
|
||||
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'""",
|
||||
ref_rate = webnotes.conn.sql("""select ip.ref_rate from
|
||||
`tabItem Price` ip, `tabPrice List` pl
|
||||
where ip.price_list=pl.name and ip.price_list=%s and
|
||||
ip.item_code=%s and ip.selling=1 and pl.enabled=1""",
|
||||
(args.selling_price_list, args.item_code), as_dict=1)
|
||||
|
||||
if not ref_rate:
|
||||
|
||||
@@ -282,7 +282,7 @@ def apply_cart_settings(party=None, quotation=None):
|
||||
party = get_lead_or_customer()
|
||||
if not quotation:
|
||||
quotation = _get_cart_quotation(party)
|
||||
|
||||
|
||||
cart_settings = webnotes.get_obj("Shopping Cart Settings")
|
||||
|
||||
billing_territory = get_address_territory(quotation.doc.customer_address) or \
|
||||
@@ -310,7 +310,8 @@ def set_price_list_and_rate(quotation, cart_settings, billing_territory):
|
||||
quotation.run_method("set_price_list_and_item_details")
|
||||
|
||||
# set it in cookies for using in product page
|
||||
webnotes.local._response.set_cookie("selling_price_list", quotation.doc.selling_price_list)
|
||||
if quotation.doc.selling_price_list:
|
||||
webnotes.local._response.set_cookie("selling_price_list", quotation.doc.selling_price_list)
|
||||
|
||||
def set_taxes(quotation, cart_settings, billing_territory):
|
||||
"""set taxes based on billing territory"""
|
||||
|
||||
@@ -27,8 +27,9 @@ def get_product_info(item_code):
|
||||
else:
|
||||
in_stock = -1
|
||||
|
||||
price = price_list and webnotes.conn.sql("""select ref_rate, currency from
|
||||
`tabItem Price` where item_code=%s and price_list=%s""",
|
||||
price = price_list and webnotes.conn.sql("""select ip.ref_rate, ip.currency from
|
||||
`tabItem Price` ip, `tabPrice List` pl where ip.price_list=pl.name and
|
||||
ip.item_code=%s and ip.price_list=%s and pl.enabled=1""",
|
||||
(item_code, price_list), as_dict=1) or []
|
||||
|
||||
price = price and price[0] or None
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
@@ -98,7 +98,9 @@ def create_price_lists(args):
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "Standard " + pl_type,
|
||||
"buying_or_selling": pl_type,
|
||||
"enabled": 1,
|
||||
"buying": 1 if pl_type == "Buying" else 0,
|
||||
"selling": 1 if pl_type == "Selling" else 0,
|
||||
"currency": args["currency"]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _, msgprint
|
||||
from webnotes import _, msgprint, throw
|
||||
import json
|
||||
|
||||
def get_company_currency(company):
|
||||
@@ -11,8 +11,8 @@ def get_company_currency(company):
|
||||
if not currency:
|
||||
currency = webnotes.conn.get_default("currency")
|
||||
if not currency:
|
||||
msgprint(_('Please specify Default Currency in Company Master \
|
||||
and Global Defaults'), raise_exception=True)
|
||||
throw(_('Please specify Default Currency in Company Master \
|
||||
and Global Defaults'))
|
||||
|
||||
return currency
|
||||
|
||||
@@ -32,5 +32,14 @@ def get_ancestors_of(doctype, name):
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_price_list_currency(price_list):
|
||||
return {"price_list_currency": webnotes.conn.get_value("Price List", price_list,
|
||||
"currency")}
|
||||
price_list_currency = webnotes.conn.get_value("Price List", {"name": price_list,
|
||||
"enabled": 1}, "currency")
|
||||
|
||||
if not price_list_currency:
|
||||
throw("{message}: {price_list} {disabled}".format(**{
|
||||
"message": _("Price List"),
|
||||
"price_list": price_list,
|
||||
"disabled": _("is disabled.")
|
||||
}))
|
||||
else:
|
||||
return {"price_list_currency": price_list_currency}
|
||||
@@ -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')
|
||||
|
||||
|
||||
@@ -53,6 +53,10 @@ def execute_daily():
|
||||
# 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)
|
||||
|
||||
def execute_weekly():
|
||||
from setup.doctype.backup_manager.backup_manager import take_backups_weekly
|
||||
|
||||
@@ -29,10 +29,7 @@ cur_frm.cscript.make_dashboard = function() {
|
||||
|
||||
cur_frm.cscript.edit_prices_button = function() {
|
||||
cur_frm.add_custom_button("Add / Edit Prices", function() {
|
||||
wn.route_options = {
|
||||
"item_code": cur_frm.doc.name
|
||||
};
|
||||
wn.set_route("Report", "Item Price");
|
||||
wn.set_route("Report", "Item Price", {"item_code": cur_frm.doc.name});
|
||||
}, "icon-money");
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ test_records = [
|
||||
"stock_uom": "_Test UOM",
|
||||
"default_income_account": "Sales - _TC",
|
||||
"default_warehouse": "_Test Warehouse - _TC",
|
||||
"purchase_account": "_Test Account Cost for Goods Sold - _TC"
|
||||
}, {
|
||||
"doctype": "Item Reorder",
|
||||
"parentfield": "item_reorder",
|
||||
@@ -64,6 +65,7 @@ test_records = [
|
||||
"stock_uom": "_Test UOM",
|
||||
"default_income_account": "Sales - _TC",
|
||||
"default_warehouse": "_Test Warehouse - _TC",
|
||||
"purchase_account": "_Test Account Cost for Goods Sold - _TC"
|
||||
}],
|
||||
[{
|
||||
"doctype": "Item",
|
||||
@@ -73,6 +75,7 @@ test_records = [
|
||||
"item_group": "_Test Item Group Desktops",
|
||||
"default_warehouse": "_Test Warehouse - _TC",
|
||||
"default_income_account": "Sales - _TC",
|
||||
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"is_stock_item": "Yes",
|
||||
"is_asset_item": "No",
|
||||
"has_batch_no": "No",
|
||||
@@ -99,6 +102,7 @@ test_records = [
|
||||
"item_group": "_Test Item Group Desktops",
|
||||
"default_warehouse": "_Test Warehouse - _TC",
|
||||
"default_income_account": "Sales - _TC",
|
||||
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"is_stock_item": "Yes",
|
||||
"is_asset_item": "No",
|
||||
"has_batch_no": "No",
|
||||
@@ -119,6 +123,7 @@ test_records = [
|
||||
"description": "_Test Sales BOM Item",
|
||||
"item_group": "_Test Item Group Desktops",
|
||||
"default_income_account": "Sales - _TC",
|
||||
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"is_stock_item": "No",
|
||||
"is_asset_item": "No",
|
||||
"has_batch_no": "No",
|
||||
@@ -140,6 +145,7 @@ test_records = [
|
||||
"is_stock_item": "Yes",
|
||||
"default_warehouse": "_Test Warehouse - _TC",
|
||||
"default_income_account": "Sales - _TC",
|
||||
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"is_asset_item": "No",
|
||||
"has_batch_no": "No",
|
||||
"has_serial_no": "No",
|
||||
@@ -216,6 +222,7 @@ test_records = [
|
||||
"item_group": "_Test Item Group Desktops",
|
||||
"default_warehouse": "_Test Warehouse - _TC",
|
||||
"default_income_account": "Sales - _TC",
|
||||
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"is_stock_item": "Yes",
|
||||
"is_asset_item": "No",
|
||||
"has_batch_no": "No",
|
||||
@@ -238,6 +245,7 @@ test_records = [
|
||||
"is_stock_item": "Yes",
|
||||
"default_warehouse": "_Test Warehouse - _TC",
|
||||
"default_income_account": "Sales - _TC",
|
||||
"purchase_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"is_asset_item": "No",
|
||||
"has_batch_no": "No",
|
||||
"has_serial_no": "No",
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
$.extend(cur_frm.cscript, {
|
||||
|
||||
onload: function () {
|
||||
|
||||
// Fetch price list details
|
||||
cur_frm.add_fetch("price_list", "buying_or_selling", "buying_or_selling");
|
||||
cur_frm.add_fetch("price_list", "buying", "buying");
|
||||
cur_frm.add_fetch("price_list", "selling", "selling");
|
||||
cur_frm.add_fetch("price_list", "currency", "currency");
|
||||
|
||||
// Fetch item details
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# MIT License. See license.txt
|
||||
|
||||
# For license information, please see license.txt
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
from webnotes import throw, _
|
||||
|
||||
class ItemPriceDuplicateItem(webnotes.ValidationError): pass
|
||||
|
||||
@@ -14,26 +12,36 @@ class DocType:
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def validate(self):
|
||||
self.validate_price_list()
|
||||
self.check_duplicate_item()
|
||||
self.update_price_list_details()
|
||||
self.update_item_details()
|
||||
|
||||
def update_price_list_details(self):
|
||||
self.doc.buying_or_selling, self.doc.currency = webnotes.conn.get_value("Price List",
|
||||
self.doc.price_list, ["buying_or_selling", "currency"])
|
||||
|
||||
def update_item_details(self):
|
||||
self.doc.item_name, self.doc.item_description = webnotes.conn.get_value("Item",
|
||||
self.doc.item_code, ["item_name", "description"])
|
||||
def validate_price_list(self):
|
||||
enabled = webnotes.conn.get_value("Price List", self.doc.price_list, "enabled")
|
||||
if not enabled:
|
||||
throw("{message}: {price_list} {disabled}".format(**{
|
||||
"message": _("Price List"),
|
||||
"price_list": self.doc.price_list,
|
||||
"disabled": _("is disabled.")
|
||||
}))
|
||||
|
||||
def check_duplicate_item(self):
|
||||
if webnotes.conn.sql("""select name from `tabItem Price`
|
||||
where item_code=%s and price_list=%s and name!=%s""",
|
||||
(self.doc.item_code, self.doc.price_list, self.doc.name)):
|
||||
webnotes.throw("{duplicate_item}: {item_code}, {already}: {price_list}".format(**{
|
||||
throw("{duplicate_item}: {item_code}, {already}: {price_list}".format(**{
|
||||
"duplicate_item": _("Duplicate Item"),
|
||||
"item_code": self.doc.item_code,
|
||||
"already": _("already available in Price List"),
|
||||
"price_list": self.doc.price_list
|
||||
}), ItemPriceDuplicateItem)
|
||||
|
||||
def update_price_list_details(self):
|
||||
self.doc.buying, self.doc.selling, self.doc.currency = webnotes.conn.get_value("Price List",
|
||||
{"name": self.doc.price_list, "enabled": 1}, ["buying", "selling", "currency"])
|
||||
|
||||
def update_item_details(self):
|
||||
self.doc.item_name, self.doc.item_description = webnotes.conn.get_value("Item",
|
||||
self.doc.item_code, ["item_name", "description"])
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-02 16:29:48",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-10-31 12:59:02",
|
||||
"modified": "2014-01-07 19:16:49",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -43,6 +43,13 @@
|
||||
"doctype": "DocType",
|
||||
"name": "Item Price"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_list_details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Price List",
|
||||
"options": "icon-tags"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_list",
|
||||
@@ -52,6 +59,29 @@
|
||||
"options": "Price List",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "buying",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Buying",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "selling",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Selling",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Item",
|
||||
"options": "icon-tag"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_code",
|
||||
@@ -83,16 +113,6 @@
|
||||
"fieldname": "col_br_1",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "buying_or_selling",
|
||||
"fieldtype": "Select",
|
||||
"in_filter": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "Valid for Buying or Selling?",
|
||||
"options": "Selling\nBuying",
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_name",
|
||||
|
||||
@@ -125,6 +125,7 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
from stock.doctype.material_request.material_request import make_purchase_order
|
||||
po_doclist = make_purchase_order(mr.doc.name)
|
||||
po_doclist[0].supplier = "_Test Supplier"
|
||||
po_doclist[0].transaction_date = "2013-07-07"
|
||||
po_doclist[1].qty = 27.0
|
||||
po_doclist[2].qty = 1.5
|
||||
po_doclist[1].schedule_date = "2013-07-09"
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
.table-grid tbody tr {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.table-grid thead tr {
|
||||
height: 50px;
|
||||
}
|
||||
@@ -3,16 +3,15 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _
|
||||
from webnotes.utils import comma_or, cint
|
||||
from webnotes import msgprint, _, throw
|
||||
from webnotes.utils import cint
|
||||
from webnotes.model.controller import DocListController
|
||||
import webnotes.defaults
|
||||
|
||||
class DocType(DocListController):
|
||||
def validate(self):
|
||||
if self.doc.buying_or_selling not in ["Buying", "Selling"]:
|
||||
msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " +
|
||||
comma_or(["Buying", "Selling"]), raise_exception=True)
|
||||
if not cint(self.doc.buying) and not cint(self.doc.selling):
|
||||
throw(_("Price List must be applicable for Buying or Selling"))
|
||||
|
||||
if not self.doclist.get({"parentfield": "valid_for_territories"}):
|
||||
# if no territory, set default territory
|
||||
@@ -25,24 +24,24 @@ class DocType(DocListController):
|
||||
else:
|
||||
# at least one territory
|
||||
self.validate_table_has_rows("valid_for_territories")
|
||||
|
||||
|
||||
def on_update(self):
|
||||
self.set_default_if_missing()
|
||||
self.update_item_price()
|
||||
cart_settings = webnotes.get_obj("Shopping Cart Settings")
|
||||
if cint(cart_settings.doc.enabled):
|
||||
cart_settings.validate_price_lists()
|
||||
|
||||
|
||||
def set_default_if_missing(self):
|
||||
if self.doc.buying_or_selling=="Selling":
|
||||
if cint(self.doc.selling):
|
||||
if not webnotes.conn.get_value("Selling Settings", None, "selling_price_list"):
|
||||
webnotes.set_value("Selling Settings", "Selling Settings", "selling_price_list", self.doc.name)
|
||||
|
||||
elif self.doc.buying_or_selling=="Buying":
|
||||
elif cint(self.doc.buying):
|
||||
if not webnotes.conn.get_value("Buying Settings", None, "buying_price_list"):
|
||||
webnotes.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.doc.name)
|
||||
|
||||
def update_item_price(self):
|
||||
webnotes.conn.sql("""update `tabItem Price` set currency=%s,
|
||||
buying_or_selling=%s, modified=NOW() where price_list=%s""",
|
||||
(self.doc.currency, self.doc.buying_or_selling, self.doc.name))
|
||||
buying=%s, selling=%s, modified=NOW() where price_list=%s""",
|
||||
(self.doc.currency, cint(self.doc.buying), cint(self.doc.selling), self.doc.name))
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-01-25 11:35:09",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-10-31 19:24:33",
|
||||
"modified": "2014-01-27 11:11:08",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -11,6 +11,7 @@
|
||||
"allow_copy": 0,
|
||||
"allow_email": 1,
|
||||
"allow_print": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:price_list_name",
|
||||
"description": "Price List Master",
|
||||
"doctype": "DocType",
|
||||
@@ -42,6 +43,18 @@
|
||||
"doctype": "DocType",
|
||||
"name": "Price List"
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "enabled",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enabled"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sb_1",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_list_name",
|
||||
@@ -61,14 +74,19 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"default": "Selling",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "buying_or_selling",
|
||||
"fieldtype": "Select",
|
||||
"fieldname": "buying",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Valid for Buying or Selling?",
|
||||
"options": "Buying\nSelling",
|
||||
"reqd": 1
|
||||
"label": "Buying"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "selling",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Selling",
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
|
||||
@@ -11,8 +11,9 @@ test_records = [
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List",
|
||||
"enabled": 1,
|
||||
"currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
"selling": 1
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
@@ -24,8 +25,9 @@ test_records = [
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List 2",
|
||||
"enabled": 1,
|
||||
"currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
"selling": 1
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
@@ -37,8 +39,9 @@ test_records = [
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List India",
|
||||
"enabled": 1,
|
||||
"currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
"selling": 1
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
@@ -50,8 +53,9 @@ test_records = [
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List Rest of the World",
|
||||
"enabled": 1,
|
||||
"currency": "USD",
|
||||
"buying_or_selling": "Selling"
|
||||
"selling": 1
|
||||
},
|
||||
{
|
||||
"doctype": "Applicable Territory",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:10",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-12-18 10:38:39",
|
||||
"modified": "2014-01-15 16:00:44",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -334,6 +334,16 @@
|
||||
"report_hide": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"default": ":Company",
|
||||
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cost_center",
|
||||
"fieldtype": "Link",
|
||||
"label": "Cost Center",
|
||||
"options": "Cost Center",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "project_name",
|
||||
|
||||
@@ -87,6 +87,8 @@ class DocType(StockController):
|
||||
self.doc.status = "Sales Returned"
|
||||
else:
|
||||
self.doc.status = "Available"
|
||||
if not self.doc.warehouse:
|
||||
self.doc.warehouse = last_sle.warehouse
|
||||
else:
|
||||
if document_type == "Purchase Return":
|
||||
self.doc.status = "Purchase Returned"
|
||||
@@ -94,6 +96,8 @@ class DocType(StockController):
|
||||
self.doc.status = "Delivered"
|
||||
else:
|
||||
self.doc.status = "Not Available"
|
||||
else:
|
||||
self.doc.status = "Not Available"
|
||||
|
||||
def set_purchase_details(self, purchase_sle):
|
||||
if purchase_sle:
|
||||
@@ -185,10 +189,9 @@ class DocType(StockController):
|
||||
def on_stock_ledger_entry(self):
|
||||
if self.via_stock_ledger and not self.doc.fields.get("__islocal"):
|
||||
last_sle = self.get_last_sle()
|
||||
if last_sle:
|
||||
self.set_status(last_sle.get("last_sle"))
|
||||
self.set_purchase_details(last_sle.get("purchase_sle"))
|
||||
self.set_sales_details(last_sle.get("delivery_sle"))
|
||||
self.set_status(last_sle.get("last_sle"))
|
||||
self.set_purchase_details(last_sle.get("purchase_sle"))
|
||||
self.set_sales_details(last_sle.get("delivery_sle"))
|
||||
|
||||
def on_communication(self):
|
||||
return
|
||||
|
||||
@@ -346,7 +346,8 @@ class DocType(StockController):
|
||||
pro_bean = webnotes.bean("Production Order", self.doc.production_order)
|
||||
_validate_production_order(pro_bean)
|
||||
self.update_produced_qty(pro_bean)
|
||||
self.update_planned_qty(pro_bean)
|
||||
if self.doc.purpose == "Manufacture/Repack":
|
||||
self.update_planned_qty(pro_bean)
|
||||
|
||||
def update_produced_qty(self, pro_bean):
|
||||
if self.doc.purpose == "Manufacture/Repack":
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-03-29 18:22:12",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-08 16:15:44",
|
||||
"modified": "2014-01-15 16:08:45",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -165,7 +165,7 @@
|
||||
"read_only": 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",
|
||||
@@ -175,7 +175,7 @@
|
||||
},
|
||||
{
|
||||
"default": ":Company",
|
||||
"depends_on": "eval:sys_defaults.auto_accounting_for_stock",
|
||||
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cost_center",
|
||||
"fieldtype": "Link",
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
|
||||
# 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 import msgprint
|
||||
from webnotes.utils import flt, getdate
|
||||
from webnotes.utils import flt, getdate, add_days
|
||||
from webnotes.model.controller import DocListController
|
||||
from datetime import date
|
||||
|
||||
class StockFreezeError(webnotes.ValidationError): pass
|
||||
|
||||
class DocType(DocListController):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@@ -19,30 +23,30 @@ class DocType(DocListController):
|
||||
validate_warehouse_user(self.doc.warehouse)
|
||||
validate_warehouse_company(self.doc.warehouse, self.doc.company)
|
||||
self.scrub_posting_time()
|
||||
|
||||
|
||||
from accounts.utils import validate_fiscal_year
|
||||
validate_fiscal_year(self.doc.posting_date, self.doc.fiscal_year, self.meta.get_label("posting_date"))
|
||||
|
||||
|
||||
def on_submit(self):
|
||||
self.check_stock_frozen_date()
|
||||
self.actual_amt_check()
|
||||
|
||||
|
||||
from stock.doctype.serial_no.serial_no import process_serial_no
|
||||
process_serial_no(self.doc)
|
||||
|
||||
|
||||
#check for item quantity available in stock
|
||||
def actual_amt_check(self):
|
||||
if self.doc.batch_no:
|
||||
batch_bal_after_transaction = flt(webnotes.conn.sql("""select sum(actual_qty)
|
||||
from `tabStock Ledger Entry`
|
||||
where warehouse=%s and item_code=%s and batch_no=%s""",
|
||||
batch_bal_after_transaction = flt(webnotes.conn.sql("""select sum(actual_qty)
|
||||
from `tabStock Ledger Entry`
|
||||
where warehouse=%s and item_code=%s and batch_no=%s""",
|
||||
(self.doc.warehouse, self.doc.item_code, self.doc.batch_no))[0][0])
|
||||
|
||||
|
||||
if batch_bal_after_transaction < 0:
|
||||
self.doc.fields.update({
|
||||
'batch_bal': batch_bal_after_transaction - self.doc.actual_qty
|
||||
})
|
||||
|
||||
|
||||
webnotes.throw("""Not enough quantity (requested: %(actual_qty)s, \
|
||||
current: %(batch_bal)s in Batch <b>%(batch_no)s</b> for Item \
|
||||
<b>%(item_code)s</b> at Warehouse <b>%(warehouse)s</b> \
|
||||
@@ -60,41 +64,49 @@ class DocType(DocListController):
|
||||
msgprint("Warehouse: '%s' does not exist in the system. Please check." % self.doc.fields.get(k), raise_exception = 1)
|
||||
|
||||
def validate_item(self):
|
||||
item_det = webnotes.conn.sql("""select name, has_batch_no, docstatus,
|
||||
is_stock_item, has_serial_no, serial_no_series
|
||||
from tabItem where name=%s""",
|
||||
item_det = webnotes.conn.sql("""select name, has_batch_no, docstatus,
|
||||
is_stock_item, has_serial_no, serial_no_series
|
||||
from tabItem where name=%s""",
|
||||
self.doc.item_code, as_dict=True)[0]
|
||||
|
||||
if item_det.is_stock_item != 'Yes':
|
||||
webnotes.throw("""Item: "%s" is not a Stock Item.""" % self.doc.item_code)
|
||||
|
||||
|
||||
# check if batch number is required
|
||||
if item_det.has_batch_no =='Yes' and self.doc.voucher_type != 'Stock Reconciliation':
|
||||
if not self.doc.batch_no:
|
||||
webnotes.throw("Batch number is mandatory for Item '%s'" % self.doc.item_code)
|
||||
|
||||
|
||||
# check if batch belongs to item
|
||||
if not webnotes.conn.sql("""select name from `tabBatch`
|
||||
if not webnotes.conn.sql("""select name from `tabBatch`
|
||||
where item='%s' and name ='%s' and docstatus != 2""" % (self.doc.item_code, self.doc.batch_no)):
|
||||
webnotes.throw("'%s' is not a valid Batch Number for Item '%s'" % (self.doc.batch_no, self.doc.item_code))
|
||||
|
||||
|
||||
if not self.doc.stock_uom:
|
||||
self.doc.stock_uom = item_det.stock_uom
|
||||
|
||||
|
||||
def check_stock_frozen_date(self):
|
||||
stock_frozen_upto = webnotes.conn.get_value('Stock Settings', None, 'stock_frozen_upto') or ''
|
||||
if stock_frozen_upto:
|
||||
stock_auth_role = webnotes.conn.get_value('Stock Settings', None,'stock_auth_role')
|
||||
if getdate(self.doc.posting_date) <= getdate(stock_frozen_upto) and not stock_auth_role in webnotes.user.get_roles():
|
||||
msgprint("You are not authorized to do / modify back dated stock entries before %s" % getdate(stock_frozen_upto).strftime('%d-%m-%Y'), raise_exception=1)
|
||||
msgprint("You are not authorized to do / modify back dated stock entries before %s" % getdate(stock_frozen_upto).strftime('%d-%m-%Y'), raise_exception=StockFreezeError)
|
||||
|
||||
stock_frozen_upto_days = int(webnotes.conn.get_value('Stock Settings', None, 'stock_frozen_upto_days') or 0)
|
||||
if stock_frozen_upto_days:
|
||||
stock_auth_role = webnotes.conn.get_value('Stock Settings', None,'stock_auth_role')
|
||||
older_than_x_days_ago = (add_days(getdate(self.doc.posting_date), stock_frozen_upto_days) <= date.today())
|
||||
if older_than_x_days_ago and not stock_auth_role in webnotes.user.get_roles():
|
||||
msgprint("You are not authorized to do / modify back dated stock entries older than %d days ago" %stock_frozen_upto_days, raise_exception=StockFreezeError)
|
||||
|
||||
|
||||
def scrub_posting_time(self):
|
||||
if not self.doc.posting_time or self.doc.posting_time == '00:0':
|
||||
self.doc.posting_time = '00:00'
|
||||
|
||||
def on_doctype_update():
|
||||
if not webnotes.conn.sql("""show index from `tabStock Ledger Entry`
|
||||
if not webnotes.conn.sql("""show index from `tabStock Ledger Entry`
|
||||
where Key_name="posting_sort_index" """):
|
||||
webnotes.conn.commit()
|
||||
webnotes.conn.sql("""alter table `tabStock Ledger Entry`
|
||||
webnotes.conn.sql("""alter table `tabStock Ledger Entry`
|
||||
add index posting_sort_index(posting_date, posting_time, name)""")
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-03-28 10:35:31",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-09-24 15:35:12",
|
||||
"modified": "2014-01-15 15:45:07",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -102,7 +102,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",
|
||||
@@ -110,6 +110,7 @@
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cost_center",
|
||||
"fieldtype": "Link",
|
||||
|
||||
@@ -5,18 +5,23 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes import _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
|
||||
def validate(self):
|
||||
for key in ["item_naming_by", "item_group", "stock_uom",
|
||||
for key in ["item_naming_by", "item_group", "stock_uom",
|
||||
"allow_negative_stock"]:
|
||||
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
||||
|
||||
|
||||
from setup.doctype.naming_series.naming_series import set_by_naming_series
|
||||
set_by_naming_series("Item", "item_code",
|
||||
set_by_naming_series("Item", "item_code",
|
||||
self.doc.get("item_naming_by")=="Naming Series", hide_name_field=True)
|
||||
|
||||
|
||||
stock_frozen_limit = 356
|
||||
submitted_stock_frozen = self.doc.stock_frozen_upto_days
|
||||
if submitted_stock_frozen > stock_frozen_limit:
|
||||
self.doc.stock_frozen_upto_days = stock_frozen_limit
|
||||
webnotes.msgprint (_("`Freeze Stocks Older Than` should be smaller than %d days.") %stock_frozen_limit)
|
||||
|
||||
@@ -1,128 +1,134 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-06-24 16:37:54",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-11-02 19:41:56",
|
||||
"modified_by": "Administrator",
|
||||
"creation": "2013-06-24 16:37:54",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-01-27 20:00:56",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
},
|
||||
{
|
||||
"description": "Settings",
|
||||
"doctype": "DocType",
|
||||
"icon": "icon-cog",
|
||||
"issingle": 1,
|
||||
"module": "Stock",
|
||||
"description": "Settings",
|
||||
"doctype": "DocType",
|
||||
"icon": "icon-cog",
|
||||
"issingle": 1,
|
||||
"module": "Stock",
|
||||
"name": "__common__"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Stock Settings",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Stock Settings",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Stock Settings",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Material Manager",
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Stock Settings",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Material Manager",
|
||||
"write": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"doctype": "DocType",
|
||||
"name": "Stock Settings"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_naming_by",
|
||||
"fieldtype": "Select",
|
||||
"label": "Item Naming By",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_naming_by",
|
||||
"fieldtype": "Select",
|
||||
"label": "Item Naming By",
|
||||
"options": "Item Code\nNaming Series"
|
||||
},
|
||||
},
|
||||
{
|
||||
"description": "<a href=\"#Sales Browser/Item Group\">Add / Edit</a>",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_group",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Item Group",
|
||||
"description": "<a href=\"#Sales Browser/Item Group\">Add / Edit</a>",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_group",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Item Group",
|
||||
"options": "Item Group"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_uom",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Stock UOM",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_uom",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Stock UOM",
|
||||
"options": "UOM"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_4",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_4",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "allow_negative_stock",
|
||||
"fieldtype": "Check",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "allow_negative_stock",
|
||||
"fieldtype": "Check",
|
||||
"label": "Allow Negative Stock"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "valuation_method",
|
||||
"fieldtype": "Select",
|
||||
"label": "Default Valuation Method",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "valuation_method",
|
||||
"fieldtype": "Select",
|
||||
"label": "Default Valuation Method",
|
||||
"options": "FIFO\nMoving Average"
|
||||
},
|
||||
},
|
||||
{
|
||||
"description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "tolerance",
|
||||
"fieldtype": "Float",
|
||||
"description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "tolerance",
|
||||
"fieldtype": "Float",
|
||||
"label": "Allowance Percent"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "auto_material_request",
|
||||
"fieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "auto_material_request",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Auto Material Request"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "auto_indent",
|
||||
"fieldtype": "Check",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "auto_indent",
|
||||
"fieldtype": "Check",
|
||||
"label": "Raise Material Request when stock reaches re-order level"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "reorder_email_notify",
|
||||
"fieldtype": "Check",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "reorder_email_notify",
|
||||
"fieldtype": "Check",
|
||||
"label": "Notify by Email on creation of automatic Material Request"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "freeze_stock_entries",
|
||||
"fieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "freeze_stock_entries",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Freeze Stock Entries"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_frozen_upto",
|
||||
"fieldtype": "Date",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_frozen_upto",
|
||||
"fieldtype": "Date",
|
||||
"label": "Stock Frozen Upto"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_auth_role",
|
||||
"fieldtype": "Link",
|
||||
"label": "Role Allowed to edit frozen stock",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_frozen_upto_days",
|
||||
"fieldtype": "Int",
|
||||
"label": "Freeze Stocks Older Than [Days]"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_auth_role",
|
||||
"fieldtype": "Link",
|
||||
"label": "Role Allowed to edit frozen stock",
|
||||
"options": "Role"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cint, validate_email_add
|
||||
from webnotes import msgprint, _
|
||||
from webnotes import throw, msgprint, _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@@ -18,7 +18,7 @@ class DocType:
|
||||
|
||||
def validate(self):
|
||||
if self.doc.email_id and not validate_email_add(self.doc.email_id):
|
||||
msgprint("Please enter valid Email Id", raise_exception=1)
|
||||
throw(_("Please enter valid Email Id"))
|
||||
|
||||
self.update_parent_account()
|
||||
|
||||
@@ -76,8 +76,8 @@ class DocType:
|
||||
for d in bins:
|
||||
if d['actual_qty'] or d['reserved_qty'] or d['ordered_qty'] or \
|
||||
d['indented_qty'] or d['projected_qty'] or d['planned_qty']:
|
||||
msgprint("""Warehouse: %s can not be deleted as qty exists for item: %s"""
|
||||
% (self.doc.name, d['item_code']), raise_exception=1)
|
||||
throw("""Warehouse: %s can not be deleted as qty exists for item: %s"""
|
||||
% (self.doc.name, d['item_code']))
|
||||
else:
|
||||
webnotes.conn.sql("delete from `tabBin` where name = %s", d['name'])
|
||||
|
||||
@@ -88,27 +88,23 @@ class DocType:
|
||||
|
||||
if webnotes.conn.sql("""select name from `tabStock Ledger Entry`
|
||||
where warehouse = %s""", self.doc.name):
|
||||
msgprint("""Warehouse can not be deleted as stock ledger entry
|
||||
exists for this warehouse.""", raise_exception=1)
|
||||
throw(_("""Warehouse can not be deleted as stock ledger entry
|
||||
exists for this warehouse."""))
|
||||
|
||||
def before_rename(self, olddn, newdn, merge=False):
|
||||
# Add company abbr if not provided
|
||||
from setup.doctype.company.company import get_name_with_abbr
|
||||
new_warehouse = get_name_with_abbr(newdn, self.doc.company)
|
||||
|
||||
if merge:
|
||||
if not webnotes.conn.exists("Warehouse", newdn):
|
||||
webnotes.throw(_("Warehouse ") + newdn +_(" does not exists"))
|
||||
|
||||
if self.doc.company != webnotes.conn.get_value("Warehouse", new_warehouse, "company"):
|
||||
if self.doc.company != webnotes.conn.get_value("Warehouse", newdn, "company"):
|
||||
webnotes.throw(_("Both Warehouse must belong to same Company"))
|
||||
|
||||
webnotes.conn.sql("delete from `tabBin` where warehouse=%s", olddn)
|
||||
|
||||
from accounts.utils import rename_account_for
|
||||
rename_account_for("Warehouse", olddn, new_warehouse, merge)
|
||||
rename_account_for("Warehouse", olddn, newdn, merge)
|
||||
|
||||
return new_warehouse
|
||||
return newdn
|
||||
|
||||
def after_rename(self, olddn, newdn, merge=False):
|
||||
if merge:
|
||||
|
||||
@@ -15,8 +15,8 @@ def execute(filters=None):
|
||||
bom_rate = get_item_bom_rate()
|
||||
val_rate_map = get_valuation_rate()
|
||||
|
||||
precision = get_currency_precision or 2
|
||||
|
||||
from accounts.utils import get_currency_precision
|
||||
precision = get_currency_precision() or 2
|
||||
data = []
|
||||
for item in sorted(item_map):
|
||||
data.append([item, item_map[item]["item_name"],
|
||||
@@ -30,14 +30,6 @@ def execute(filters=None):
|
||||
])
|
||||
|
||||
return columns, data
|
||||
|
||||
def get_currency_precision():
|
||||
company_currency = webnotes.conn.get_value("Company",
|
||||
webnotes.conn.get_default("company"), "default_currency")
|
||||
currency_format = webnotes.conn.get_value("Currency", company_currency, "number_format")
|
||||
|
||||
from webnotes.utils import get_number_format_info
|
||||
return get_number_format_info(currency_format)[2]
|
||||
|
||||
def get_columns(filters):
|
||||
"""return columns based on filters"""
|
||||
@@ -65,13 +57,14 @@ def get_price_list():
|
||||
|
||||
rate = {}
|
||||
|
||||
price_list = webnotes.conn.sql("""select item_code, buying_or_selling,
|
||||
concat(price_list, " - ", currency, " ", ref_rate) as price
|
||||
from `tabItem Price`""", as_dict=1)
|
||||
price_list = webnotes.conn.sql("""select ip.item_code, ip.buying, ip.selling,
|
||||
concat(ip.price_list, " - ", ip.currency, " ", ip.ref_rate) as price
|
||||
from `tabItem Price` ip, `tabPrice List` pl
|
||||
where ip.price_list=pl.name and pl.enabled=1""", as_dict=1)
|
||||
|
||||
for j in price_list:
|
||||
if j.price:
|
||||
rate.setdefault(j.item_code, {}).setdefault(j.buying_or_selling, []).append(j.price)
|
||||
rate.setdefault(j.item_code, {}).setdefault("Buying" if j.buying else "Selling", []).append(j.price)
|
||||
item_rate_map = {}
|
||||
|
||||
for item in rate:
|
||||
|
||||
0
stock/report/item_wise_price_list_rate/__init__.py
Normal file
0
stock/report/item_wise_price_list_rate/__init__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-09-25 10:21:15",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-01-07 18:35:22",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"json": "{\"filters\":[[\"Item Price\",\"price_list\",\"like\",\"%\"],[\"Item Price\",\"item_code\",\"like\",\"%\"]],\"columns\":[[\"name\",\"Item Price\"],[\"price_list\",\"Item Price\"],[\"item_code\",\"Item Price\"],[\"item_name\",\"Item Price\"],[\"item_description\",\"Item Price\"],[\"ref_rate\",\"Item Price\"],[\"buying\",\"Item Price\"],[\"selling\",\"Item Price\"],[\"currency\",\"Item Price\"]],\"sort_by\":\"Item Price.modified\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Price List",
|
||||
"report_name": "Item-wise Price List Rate",
|
||||
"report_type": "Report Builder"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"name": "Item-wise Price List Rate"
|
||||
}
|
||||
]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user