Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta 2013-01-22 12:13:18 +05:30
commit fad6746ca1
19 changed files with 103 additions and 118 deletions

View File

@ -237,11 +237,12 @@ class DocType:
self.doc.pay_to_recd_from = webnotes.conn.get_value(master_type, ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name')
if acc_type == 'Bank or Cash':
dcc = get_company_currency(self.doc.company)
amt = cint(d.debit) and d.debit or d.credit
self.doc.total_amount = dcc +' '+ cstr(amt)
self.doc.total_amount_in_words = get_obj('Sales Common').get_total_in_words(dcc, cstr(amt))
company_currency = get_company_currency(self.doc.company)
amt = flt(d.debit) and d.debit or d.credit
self.doc.total_amount = company_currency +' '+ cstr(amt)
from webnotes.utils import money_in_words
self.doc.total_amount_in_words = money_in_words(amt, company_currency)
def get_values(self):
cond = (flt(self.doc.write_off_amount) > 0) and ' and outstanding_amount <= '+self.doc.write_off_amount or ''
if self.doc.write_off_based_on == 'Accounts Receivable':

View File

@ -366,15 +366,6 @@ class DocType(BuyingController):
self.doc.posting_date,'Posting Date')
self.validate_write_off_account()
#get Purchase Common Obj
pc_obj = get_obj(dt='Purchase Common')
# get total in words
dcc = get_company_currency(self.doc.company)
self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency,
self.doc.grand_total_import)
def check_prev_docstatus(self):
for d in getlist(self.doclist,'entries'):

View File

@ -17,25 +17,21 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, cint, cstr, date_diff, flt, getTraceback, getdate, now, nowdate, sendmail, validate_email_add
from webnotes.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, sendmail
from webnotes.utils import comma_and
from webnotes import _
from webnotes.model import db_exists
from webnotes.model.doc import make_autoname
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import session, form, msgprint
from setup.utils import get_company_currency
from webnotes import _, msgprint
session = webnotes.session
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
from utilities.transaction_base import TransactionBase
from controllers.selling_controller import SellingController
class DocType(TransactionBase):
class DocType(SellingController):
def __init__(self,d,dl):
self.doc, self.doclist = d, dl
self.log = []
@ -46,6 +42,8 @@ class DocType(TransactionBase):
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
def validate(self):
super(DocType, self).validate()
self.so_dn_required()
self.validate_proj_cust()
sales_com_obj = get_obj('Sales Common')
@ -70,7 +68,6 @@ class DocType(TransactionBase):
self.validate_item_code()
self.update_current_stock()
self.validate_delivery_note()
self.set_in_words()
if not self.doc.is_opening:
self.doc.is_opening = 'No'
self.set_aging_date()
@ -253,11 +250,14 @@ class DocType(TransactionBase):
ret = get_obj('Sales Common').get_item_details(args, self)
return self.get_pos_details(args, ret)
else:
obj = get_obj('Sales Common')
for doc in self.doclist:
if doc.fields.get('item_code'):
arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'),
'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
arg = {
'item_code':doc.fields.get('item_code'),
'income_account':doc.fields.get('income_account'),
'cost_center': doc.fields.get('cost_center'),
'warehouse': doc.fields.get('warehouse')
};
ret = self.get_pos_details(arg)
for r in ret:
@ -411,13 +411,6 @@ class DocType(TransactionBase):
msgprint("Please select income head with account type 'Fixed Asset Account' as Item %s is an asset item" % d.item_code)
raise Exception
def set_in_words(self):
dcc = get_company_currency(self.doc.company)
self.doc.in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.rounded_total)
self.doc.in_words_export = get_obj('Sales Common').get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
def clear_advances(self):
get_obj('GL Control').clear_advances(self, 'Sales Invoice Advance','advance_adjustment_details')
@ -744,7 +737,7 @@ def manage_recurring_invoices(next_date=None):
new_invoice_wrapper = make_new_invoice(ref_wrapper, next_date)
send_notification(new_invoice_wrapper)
webnotes.conn.commit()
except Exception, e:
except:
webnotes.conn.rollback()
webnotes.conn.begin()

View File

@ -449,16 +449,9 @@ class DocType(BuyingController):
arg = eval(arg)
rate = sql("select account_type, tax_rate from `tabAccount` where name = '%s'" %(arg['account_head']), as_dict=1)
ret = {
'rate' : rate and (rate[0]['account_type'] == 'Tax' and not arg['charge_type'] == 'Actual') and flt(rate[0]['tax_rate']) or 0
}
#msgprint(ret)
return ret
def get_total_in_words(self, currency, amount):
from webnotes.utils import money_in_words
return money_in_words(amount, currency)
return {'rate': rate and (rate[0]['account_type'] == 'Tax' \
and not arg['charge_type'] == 'Actual') and flt(rate[0]['tax_rate']) or 0 }
def get_prevdoc_date(self, obj):
for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname:

View File

@ -67,10 +67,6 @@ class DocType(BuyingController):
# Check for stopped status
self.check_for_stopped_status(pc_obj)
# get total in words
dcc = get_company_currency(self.doc.company)
self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
def get_default_schedule_date(self):
get_obj(dt = 'Purchase Common').get_default_schedule_date(self)

View File

@ -37,7 +37,6 @@ class DocType(BuyingController):
self.validate_fiscal_year()
self.validate_common()
self.set_in_words()
def on_submit(self):
purchase_controller = webnotes.get_obj("Purchase Common")
@ -79,10 +78,4 @@ class DocType(BuyingController):
pc.validate_mandatory(self)
pc.validate_for_items(self)
pc.get_prevdoc_date(self)
pc.validate_reference_value(self)
def set_in_words(self):
pc = get_obj('Purchase Common')
company_currency = get_company_currency(self.doc.company)
self.doc.in_words = pc.get_total_in_words(company_currency, self.doc.grand_total)
self.doc.in_words_import = pc.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
pc.validate_reference_value(self)

View File

@ -31,6 +31,9 @@ class BuyingController(TransactionBase):
if self.doc.price_list_name and self.doc.price_list_currency:
self.validate_conversion_rate("price_list_currency", "plc_conversion_rate")
# set total in words
self.set_total_in_words()
def update_item_details(self):
for item in self.doclist.get({"parentfield": self.fname}):
@ -68,3 +71,12 @@ class BuyingController(TransactionBase):
msgprint(_('Please enter valid ') + conversion_rate_label + (': ')
+ ("1 %s = [?] %s" % (currency, self.company_currency)),
raise_exception=True)
def set_total_in_words(self):
from webnotes.utils import money_in_words
company_currency = get_company_currency(self.doc.company)
if self.meta.get_field("in_words"):
self.doc.in_words = money_in_words(self.doc.grand_total, company_currency)
if self.meta.get_field("in_words_import"):
self.doc.in_words_import = money_in_words(self.doc.grand_total_import,
self.doc.currency)

View File

@ -0,0 +1,33 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from setup.utils import get_company_currency
from utilities.transaction_base import TransactionBase
class SellingController(TransactionBase):
def validate(self):
self.set_total_in_words()
def set_total_in_words(self):
from webnotes.utils import money_in_words
company_currency = get_company_currency(self.doc.company)
if self.meta.get_field("in_words"):
self.doc.in_words = money_in_words(self.doc.rounded_total, company_currency)
if self.meta.get_field("in_words_export"):
self.doc.in_words_export = money_in_words(self.doc.rounded_total_export,
self.doc.currency)

View File

@ -136,9 +136,10 @@ class DocType(TransactionBase):
def validate(self):
from webnotes.utils import money_in_words
self.check_existing()
dcc = get_company_currency(self.doc.company)
self.doc.total_in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.rounded_total)
company_currency = get_company_currency(self.doc.company)
self.doc.total_in_words = money_in_words(self.doc.rounded_total, company_currency)
def calculate_earning_total(self):

View File

@ -0,0 +1,3 @@
def execute():
import webnotes
webnotes.conn.sql("""update `tabCurrency` set fraction = 'Cent' where fraction = 'Cent[D]'""")

View File

@ -154,4 +154,5 @@ patch_list = [
"patches.january_2013.update_number_format",
"patches.january_2013.purchase_price_list",
"execute:webnotes.reload_doc('accounts','Print Format','Payment Receipt Voucher')",
"patches.january_2013.update_fraction_for_usd",
]

View File

@ -23,9 +23,9 @@ from webnotes import session, msgprint
sql = webnotes.conn.sql
from utilities.transaction_base import TransactionBase
from controllers.selling_controller import SellingController
class DocType(TransactionBase):
class DocType(SellingController):
def __init__(self, doc, doclist):
self.doc = doc
self.doclist = doclist

View File

@ -198,7 +198,7 @@ cur_frm.cscript.pull_enquiry_detail = function(doc,cdt,cdn){
cur_frm.cscript['Declare Order Lost'] = function(){
var qtn_lost_dialog;
set_qtn_lost_dialog = function(doc,cdt,cdn){
set_qtn_lost_dialog = function(){
qtn_lost_dialog = new Dialog(400,400,'Add Quotation Lost Reason');
qtn_lost_dialog.make_body([
['HTML', 'Message', '<div class="comment">Please add quotation lost reason</div>'],
@ -238,7 +238,7 @@ cur_frm.cscript['Declare Order Lost'] = function(){
}
if(!qtn_lost_dialog){
set_qtn_lost_dialog(doc,cdt,cdn);
set_qtn_lost_dialog();
}
qtn_lost_dialog.show();
}

View File

@ -21,14 +21,13 @@ from webnotes.utils import cstr, getdate
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from setup.utils import get_company_currency
sql = webnotes.conn.sql
from utilities.transaction_base import TransactionBase
from controllers.selling_controller import SellingController
class DocType(TransactionBase):
class DocType(SellingController):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
@ -172,12 +171,10 @@ class DocType(TransactionBase):
else:
msgprint("Contact Date Cannot be before Last Contact Date")
raise Exception
#webnotes.conn.set(self.doc, 'contact_date_ref',self.doc.contact_date)
# Validate
# --------
def validate(self):
super(DocType, self).validate()
import utilities
utilities.validate_status(self.doc.status, ["Draft", "Submitted",
"Order Confirmed", "Order Lost", "Cancelled"])
@ -189,13 +186,9 @@ class DocType(TransactionBase):
self.validate_for_items()
sales_com_obj = get_obj('Sales Common')
sales_com_obj.check_active_sales_items(self)
sales_com_obj.validate_max_discount(self,'quotation_details') #verify whether rate is not greater than max_discount
sales_com_obj.validate_max_discount(self,'quotation_details')
sales_com_obj.check_conversion_rate(self)
# Get total in words
dcc = get_company_currency(self.doc.company)
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
def on_update(self):
# Set Quotation Status

View File

@ -17,12 +17,11 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, cint, cstr, default_fields, flt, getdate, now, nowdate, formatdate
from webnotes.model import db_exists
from webnotes.utils import cint, cstr, flt, getdate, nowdate, formatdate
from webnotes.model.doc import addchild
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import form, msgprint, _
from webnotes import msgprint, _
from setup.utils import get_company_currency
get_value = webnotes.conn.get_value
@ -546,17 +545,10 @@ class DocType(TransactionBase):
tuple(delete_list))
return obj.doclist
# Get total in words
# ==================================================================
def get_total_in_words(self, currency, amount):
from webnotes.utils import money_in_words
return money_in_words(amount, currency)
# Get month based on date (required in sales person and sales partner)
# ========================================================================
def get_month(self,date):
"""Get month based on date (required in sales person and sales partner)"""
month_list = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
month_idx = cint(cstr(date).split('-')[1])-1
return month_list[month_idx]
@ -616,10 +608,7 @@ class DocType(TransactionBase):
"fiscal_year": fiscal_year
}, raise_exception=1)
# get against document date self.prevdoc_date_field
#-----------------------------
def get_prevdoc_date(self, obj):
import datetime
for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname:
if d.prevdoc_doctype == 'Sales Invoice':

View File

@ -21,14 +21,13 @@ from webnotes.utils import cstr, flt, getdate
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from setup.utils import get_company_currency
sql = webnotes.conn.sql
from utilities.transaction_base import TransactionBase
from controllers.selling_controller import SellingController
class DocType(TransactionBase):
class DocType(SellingController):
def __init__(self, doc, doclist=None):
self.doc = doc
if not doclist: doclist = []
@ -204,6 +203,8 @@ class DocType(TransactionBase):
raise Exception
def validate(self):
super(DocType, self).validate()
self.validate_fiscal_year()
self.validate_order_type()
self.validate_mandatory()
@ -215,16 +216,9 @@ class DocType(TransactionBase):
sales_com_obj.check_active_sales_items(self)
sales_com_obj.check_conversion_rate(self)
# verify whether rate is not greater than max_discount
sales_com_obj.validate_max_discount(self,'sales_order_details')
# this is to verify that the allocated % of sales persons is 100%
sales_com_obj.get_allocated_sum(self)
self.doclist = sales_com_obj.make_packing_list(self,'sales_order_details')
# get total in words
dcc = get_company_currency(self.doc.company)
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
if not self.doc.status:
self.doc.status = "Draft"
@ -268,7 +262,8 @@ class DocType(TransactionBase):
self.check_prev_docstatus()
self.update_stock_ledger(update_stock = 1)
# update customer's last sales order no.
update_customer = sql("update `tabCustomer` set last_sales_order = '%s', modified = '%s' where name = '%s'" %(self.doc.name, self.doc.modified, self.doc.customer))
sql("""update `tabCustomer` set last_sales_order = '%s', modified = '%s'
where name = '%s'""" % (self.doc.name, self.doc.modified, self.doc.customer))
get_obj('Sales Common').check_credit(self,self.doc.grand_total)
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.grand_total, self)

View File

@ -46,4 +46,4 @@ def get_price_list_currency(args):
if result and len(result)==1:
return {"price_list_currency": result[0][0]}
else:
return {}
return {}

View File

@ -21,14 +21,13 @@ from webnotes.utils import cstr, flt, getdate
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from setup.utils import get_company_currency
sql = webnotes.conn.sql
from utilities.transaction_base import TransactionBase
from controllers.selling_controller import SellingController
class DocType(TransactionBase):
class DocType(SellingController):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
@ -131,6 +130,8 @@ class DocType(TransactionBase):
def validate(self):
super(DocType, self).validate()
import utilities
utilities.validate_status(self.doc.status, ["Draft", "submitted", "Cancelled"])
@ -144,14 +145,9 @@ class DocType(TransactionBase):
self.validate_mandatory()
self.validate_reference_value()
self.validate_for_items()
sales_com_obj.validate_max_discount(self, 'delivery_note_details') #verify whether rate is not greater than max discount
sales_com_obj.get_allocated_sum(self) # this is to verify that the allocated % of sales persons is 100%
sales_com_obj.validate_max_discount(self, 'delivery_note_details')
sales_com_obj.get_allocated_sum(self)
sales_com_obj.check_conversion_rate(self)
# Get total in Words
dcc = get_company_currency(self.doc.company)
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
# Set actual qty for each item in selected warehouse
self.update_current_stock()

View File

@ -17,12 +17,11 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, get_defaults, getdate
from webnotes.utils import cstr, flt, get_defaults
from webnotes.model.doc import addchild
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from setup.utils import get_company_currency
sql = webnotes.conn.sql
@ -136,10 +135,6 @@ class DocType(BuyingController):
pc_obj.validate_reference_value(self)
self.check_for_stopped_status(pc_obj)
# get total in words
dcc = get_company_currency(self.doc.company)
self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
# update valuation rate
self.update_valuation_rate()