mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 21:49:18 +00:00
commonified in_words function and introduced selling_controller
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user