def validate(self): self.validate_fiscal_year() self.validate_order_type() self.validate_mandatory() self.validate_proj_cust() self.validate_po() #self.validate_reference_value() self.validate_for_items() sales_com_obj = get_obj(dt='Sales Common') 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 = TransactionBase().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 SO status self.doc.status = 'Draft' if not self.doc.billing_status: self.doc.billing_status = 'Not Billed' if not self.doc.delivery_status: self.doc.delivery_status = 'Not Delivered'
def check_conversion_rate(self, obj): default_currency = TransactionBase().get_company_currency( obj.doc.company) if not default_currency: msgprint( 'Message: Please enter default currency in Company Master') raise Exception if (obj.doc.currency == default_currency and flt(obj.doc.conversion_rate) != 1.00 ) or not obj.doc.conversion_rate or ( obj.doc.currency != default_currency and flt(obj.doc.conversion_rate) == 1.00): msgprint( "Please Enter Appropriate Conversion Rate for Customer's Currency to Base Currency (%s --> %s)" % (obj.doc.currency, default_currency), raise_exception=1) if (obj.doc.price_list_currency == default_currency and flt(obj.doc.plc_conversion_rate) != 1.00 ) or not obj.doc.plc_conversion_rate or ( obj.doc.price_list_currency != default_currency and flt(obj.doc.plc_conversion_rate) == 1.00): msgprint( "Please Enter Appropriate Conversion Rate for Price List Currency to Base Currency ( (%s --> %s)" % (obj.doc.price_list_currency, default_currency), raise_exception=1)
def validate(self): self.po_required() self.validate_fiscal_year() set(self.doc, 'status', 'Draft') # set status as "Draft" self.validate_accepted_rejected_qty() self.validate_inspection() # Validate Inspection get_obj('Stock Ledger').validate_serial_no(self, 'purchase_receipt_details') self.validate_challan_no() pc_obj = get_obj(dt='Purchase Common') pc_obj.validate_for_items(self) pc_obj.validate_mandatory(self) pc_obj.validate_conversion_rate(self) pc_obj.get_prevdoc_date(self) pc_obj.validate_reference_value(self) self.check_for_stopped_status(pc_obj) # get total in words dcc = TransactionBase().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()
def validate(self): self.so_required() self.validate_fiscal_year() self.validate_proj_cust() sales_com_obj = get_obj(dt = 'Sales Common') sales_com_obj.check_stop_sales_order(self) sales_com_obj.check_active_sales_items(self) sales_com_obj.get_prevdoc_date(self) self.validate_mandatory() #self.validate_prevdoc_details() 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.check_conversion_rate(self) # ::::::: Get total in Words :::::::: dcc = TransactionBase().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() # :::::: set DN status ::::::: self.doc.status = 'Draft' if not self.doc.billing_status: self.doc.billing_status = 'Not Billed' if not self.doc.installation_status: self.doc.installation_status = 'Not Installed'
def get_appr_user_role(self, det, doctype_name, total, based_on, condition, item, company): amt_list, appr_users, appr_roles = [], [], [] users, roles = '','' if det: for x in det: amt_list.append(flt(x[0])) max_amount = max(amt_list) app_dtl = sql("select approving_user, approving_role from `tabAuthorization Rule` where transaction = %s and (value = %s or value > %s) and docstatus != 2 and based_on = %s and company = %s %s" % ('%s', '%s', '%s', '%s', '%s', condition), (doctype_name, flt(max_amount), total, based_on, company)) if not app_dtl: app_dtl = sql("select approving_user, approving_role from `tabAuthorization Rule` where transaction = %s and (value = %s or value > %s) and docstatus != 2 and based_on = %s and ifnull(company,'') = '' %s" % ('%s', '%s', '%s', '%s', condition), (doctype_name, flt(max_amount), total, based_on)) for d in app_dtl: if(d[0]): appr_users.append(d[0]) if(d[1]): appr_roles.append(d[1]) if not has_common(appr_roles, webnotes.user.get_roles()) and not has_common(appr_users, session['user']): msg, add_msg = '','' if max_amount: dcc = TransactionBase().get_company_currency(self.doc.company) if based_on == 'Grand Total': msg = "since Grand Total exceeds %s. %s" % (dcc, flt(max_amount)) elif based_on == 'Itemwise Discount': msg = "since Discount exceeds %s for Item Code : %s" % (cstr(max_amount)+'%', item) elif based_on == 'Average Discount' or based_on == 'Customerwise Discount': msg = "since Discount exceeds %s" % (cstr(max_amount)+'%') if appr_users: add_msg = "Users : "+cstr(appr_users) if appr_roles: add_msg = "Roles : "+cstr(appr_roles) if appr_users and appr_roles: add_msg = "Users : "+cstr(appr_users)+" or "+"Roles : "+cstr(appr_roles) msgprint("You do not have an authority to submit this %s %s. Please send for approval to %s" % (doctype_name, msg, add_msg)) raise Exception
def validate(self): self.validate_fiscal_year() # Step 1:=> set status as "Draft" set(self.doc, 'status', 'Draft') # Step 2:=> get Purchase Common Obj pc_obj = get_obj(dt='Purchase Common') # Step 3:=> validate mandatory pc_obj.validate_mandatory(self) # Step 4:=> validate for items pc_obj.validate_for_items(self) # Step 5:=> validate conversion rate pc_obj.validate_conversion_rate(self) # Get po date pc_obj.get_prevdoc_date(self) # validate_doc self.validate_doc(pc_obj) # Check for stopped status self.check_for_stopped_status(pc_obj) # get total in words dcc = TransactionBase().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 set_in_words(self): pc = get_obj('Purchase Common') company_currency = TransactionBase().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)
def check_conversion_rate(self): default_currency = TransactionBase().get_company_currency(self.doc.company) if not default_currency: msgprint('Message: Please enter default currency in Company Master') raise Exception if (self.doc.currency == default_currency and flt(self.doc.conversion_rate) != 1.00) or not self.doc.conversion_rate or (self.doc.currency != default_currency and flt(self.doc.conversion_rate) == 1.00): msgprint("Message: Please Enter Appropriate Conversion Rate.") raise Exception
def validate(self): tot=0.0 for d in getlist(self.doclist,'form_16A_tax_details'): tot=flt(tot)+flt(d.total_tax_deposited) dcc = TransactionBase().get_company_currency(self.doc.company) self.doc.total_amount = flt(tot) self.doc.in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.total_amount)
def validate(self): self.po_required() self.pr_required() self.check_active_purchase_items() self.check_conversion_rate() self.validate_bill_no_date() self.validate_bill_no() self.validate_reference_value() self.clear_advances() self.validate_credit_acc() self.check_for_acc_head_of_supplier() self.check_for_stopped_status() self.po_list, self.pr_list = [], [] for d in getlist(self.doclist, 'entries'): self.validate_supplier(d) self.validate_po_pr(d) if not d.purchase_order in self.po_list: self.po_list.append(d.purchase_order) if not d.purhcase_receipt in self.pr_list: self.pr_list.append(d.purchase_receipt) # tds get_obj('TDS Control').validate_first_entry(self) if not flt(self.doc.ded_amount): self.get_tds() self.doc.save() 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() #FY validation get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year, 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 = TransactionBase().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 set_print_format_fields(self): for d in getlist(self.doclist, 'entries'): #msgprint(self.doc.company) chk_type = sql("select master_type, account_type from `tabAccount` where name='%s'" % d.account) master_type, acc_type = chk_type and cstr(chk_type[0][0]) or '', chk_type and cstr(chk_type[0][1]) or '' if master_type in ['Supplier', 'Customer']: if not self.doc.pay_to_recd_from: self.doc.pay_to_recd_from = 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 = TransactionBase().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))
def validate(self): self.validate_fiscal_year() self.validate_mandatory() self.set_last_contact_date() self.validate_order_type() 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.check_conversion_rate(self) # Get total in words dcc = TransactionBase().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 validate_conversion_rate(self, obj): default_currency = TransactionBase().get_company_currency(obj.doc.company) if not default_currency: msgprint('Message: Please enter default currency in Company Master') raise Exception if obj.doc.conversion_rate == 0: msgprint('Conversion Rate cannot be 0', raise_exception=1) elif not obj.doc.conversion_rate: msgprint('Please specify Conversion Rate', raise_exception=1) elif obj.doc.currency == default_currency and \ flt(obj.doc.conversion_rate) != 1.00: msgprint("""Conversion Rate should be equal to 1.00, \ since the specified Currency and the company's currency \ are same""", raise_exception=1) elif obj.doc.currency != default_currency and \ flt(obj.doc.conversion_rate) == 1.00: msgprint("""Conversion Rate should not be equal to 1.00, \ since the specified Currency and the company's currency \ are different""", raise_exception=1)
def set_in_words(self): dcc = TransactionBase().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 validate(self): self.check_existing() dcc = TransactionBase().get_company_currency(self.doc.company) self.doc.total_in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.rounded_total)
def get_company_currency(self, arg=''): dcc = TransactionBase().get_company_currency(arg) return dcc