Merge pull request #1329 from nabinhait/hotfix

Patch for updating billing status for old zero value order
This commit is contained in:
Nabin Hait 2014-01-17 01:41:40 -08:00
commit 2aecc5a717
5 changed files with 40 additions and 13 deletions

View File

@ -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());

View 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)

View File

@ -265,4 +265,5 @@ patch_list = [
"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",
]

View File

@ -244,8 +244,6 @@ class DocType:
webnotes.conn.set(self.doc, a, account_name)
_set_default_accounts({
"default_income_account": "Sales",
"default_expense_account": "Cost of Goods Sold",
"receivables_group": "Accounts Receivable",
"payables_group": "Accounts Payable",
"default_cash_account": "Cash"
@ -257,8 +255,6 @@ class DocType:
"stock_adjustment_account": "Stock Adjustment",
"expenses_included_in_valuation": "Expenses Included In Valuation"
})
def create_default_cost_center(self):
cc_list = [

View File

@ -78,8 +78,9 @@ class TransactionBase(StatusUpdater):
3. Clears existing Sales Team and fetches the one mentioned in Customer
"""
customer_defaults = self.get_customer_defaults()
customer_defaults["selling_price_list"] = self.get_user_default_price_list("Selling") or \
customer_defaults["selling_price_list"] = \
self.get_user_default_price_list("selling_price_list") or \
customer_defaults.get("price_list") or \
webnotes.conn.get_value("Customer Group", self.doc.customer_group,
"default_price_list") or self.doc.selling_price_list
@ -91,11 +92,11 @@ class TransactionBase(StatusUpdater):
if self.meta.get_field("sales_team") and self.doc.customer:
self.set_sales_team_for_customer()
def get_user_default_price_list(self, price_list_for):
from webnotes.defaults import get_user_default_as_list
user_default_price_list = get_user_default_as_list("selling_price_list"
if price_list_for=="Selling" else "buying_price_list")
return user_default_price_list[0] if len(user_default_price_list)==1 else ""
def get_user_default_price_list(self, price_list):
from webnotes.defaults import get_defaults_for
user_default_price_list = get_defaults_for(webnotes.session.user).get(price_list)
return cstr(user_default_price_list) \
if not isinstance(user_default_price_list, list) else ""
def set_sales_team_for_customer(self):
from webnotes.model import default_fields
@ -128,7 +129,7 @@ class TransactionBase(StatusUpdater):
if supplier.default_currency:
out["currency"] = supplier.default_currency
out["buying_price_list"] = self.get_user_default_price_list("Buying") or \
out["buying_price_list"] = self.get_user_default_price_list("buying_price_list") or \
supplier.default_price_list or self.doc.buying_price_list
return out