コード例 #1
0
 def convert(self, amount, currency):
     cur = currency.encode('ascii','ignore')
     if cur == 'IDR':
         amt_ind = amount_to_text_ind.amount_to_text(amount, 'en', 'Rupiah')
         return amt_ind
     elif cur == 'USD':
         amt_en = amount_to_text_en.amount_to_text(amount, 'en', 'Dolar')
         return amt_en
コード例 #2
0
 def get_amount_in_words(self, data):
     amount = self.pool.get('sms.transportfee.challan.book').browse(
         self.cr, self.uid, data).total_payables
     user_id = self.pool.get('res.users').browse(self.cr, self.uid,
                                                 [self.uid])[0]
     cur = user_id.company_id.currency_id.name
     amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur)
     return_value = str(amt_en).replace('Cent', 'Paisa')
     return return_value
コード例 #3
0
 def onchange_amount(self, cr, uid, ids, amount, context={}):
     if not context:
         context = {}
     result = {}
     currency_format =  self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_format
     if currency_format=='us':
             amount_in_words = amount_to_words(amount)
     else: amount_in_words = amount_to_text(amount)
     result['amount_in_word']=amount_in_words
     return {'value':result}
コード例 #4
0
 def onchange_amount(self, cr, uid, ids, amount, context={}):
     """
     On change function of amount to update amount in word.
  
     @return: Dictionary of amount and amount in word
     """
     company = self.pool.get('res.users').browse(cr, uid, uid).company_id
     currency_format =  company.currency_format 
     amount_in_word = ''
     if currency_format=='ar':
         currency = self.pool.get('res.currency').read(cr, uid, company.currency_id.id, ['units_name','cents_name'], context=context)
         amount_in_word = amount_to_text_ar(amount, currency_format, currency['units_name'], currency['cents_name'])
     else: 
         amount_in_word = amount_to_text(amount)
     return {'value': {'amount':amount,'amount_in_word': amount_in_word}}
コード例 #5
0
    def onchange_amount(self, cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=None):
        """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """
        if not context:
            context = {}
        default = super(account_voucher, self).onchange_amount(cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=context)
        if 'value' in default:
            amount = 'amount' in default['value'] and default['value']['amount'] or amount

            #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
            #amount_in_word = amount_to_text(amount, context=context)
            amount_in_word = amount_to_text(amount)
            default['value'].update({'amount_in_word':amount_in_word})
            if journal_id:
                allow_check_writing = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context).allow_check_writing
                default['value'].update({'allow_check':allow_check_writing})
        return default
コード例 #6
0
 def convert(self, cr, uid, ids, amount, company_id, context=None):
     company_obj = self.pool.get('res.company')
     amt_en = amount
     if company_id:
         company = company_obj.browse(cr, uid, company_id, context=context)
         currency = company.currency_id and company.currency_id or False
         if currency:
             if currency.name == 'USD':
                 currency_name = 'Dollars'
             else:
                 currency_name = currency.name
             amt_en = amount_to_text_en.amount_to_text(amount, 'en', currency_name)
             if amt_en.endswith('Cents'):
                 amt_en = amt_en.replace('Cents', currency.sub_currency and currency.sub_currency or 'Cents')
             else:
                 amt_en = amt_en.replace('Cent', currency.sub_currency and currency.sub_currency or 'Cent')
     return amt_en
コード例 #7
0
    def write(self, cr, uid, ids,vals, context=None):
        """
        Override to force amount in word update

        @return: True
        """
        super(purchase_letter_of_credit, self).write(cr, uid, ids, vals, context)
        amount = vals.get('amount',False)
        company = self.pool.get('res.users').browse(cr, uid, uid).company_id
        currency_format =  company.currency_format 
        amount_in_word = ''
        if currency_format=='ar':
            currency = self.pool.get('res.currency').read(cr, uid, company.currency_id.id, ['units_name','cents_name'], context=context)
            amount_in_word = amount_to_text_ar(amount, currency_format, currency['units_name'], currency['cents_name'])
        else: 
            amount_in_word = amount_to_text(amount)
        vals.update({'amount':amount,'amount_in_word': amount_in_word})   
        return True
コード例 #8
0
    def onchange_amount(self,
                        cr,
                        uid,
                        ids,
                        amount,
                        rate,
                        partner_id,
                        journal_id,
                        currency_id,
                        ttype,
                        date,
                        payment_rate_currency_id,
                        company_id,
                        context=None):
        """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """
        if not context:
            context = {}
        default = super(account_voucher,
                        self).onchange_amount(cr,
                                              uid,
                                              ids,
                                              amount,
                                              rate,
                                              partner_id,
                                              journal_id,
                                              currency_id,
                                              ttype,
                                              date,
                                              payment_rate_currency_id,
                                              company_id,
                                              context=context)
        if 'value' in default:
            amount = 'amount' in default['value'] and default['value'][
                'amount'] or amount

            #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
            #amount_in_word = amount_to_text(amount, context=context)
            amount_in_word = amount_to_text(amount)
            default['value'].update({'amount_in_word': amount_in_word})
            if journal_id:
                allow_check_writing = self.pool.get('account.journal').browse(
                    cr, uid, journal_id, context=context).allow_check_writing
                default['value'].update({'allow_check': allow_check_writing})
        return default
コード例 #9
0
    def create(self, cr, user, vals, context=None):
        """ 
        Override to edit the name field by a new sequence 
        and recalculate the amount_in_word value. 

        @return: new object id 
        """
        created_id = super(purchase_letter_of_credit, self).create(cr, user, vals)
        amount = vals.get('amount',False)
        if ('name' not in vals) or (vals.get('name')=='/'):  
            vals['name'] = self.pool.get('ir.sequence').get(cr, user, 'purchase.letter.of.credit')
        company = self.pool.get('res.users').browse(cr, user, user).company_id
        currency_format =  company.currency_format 
        amount_in_word = ''
        if currency_format=='ar':
            currency = self.pool.get('res.currency').read(cr, user, company.currency_id.id, ['units_name','cents_name'], context=context)
            amount_in_word = amount_to_text_ar(amount, currency_format, currency['units_name'], currency['cents_name'])
        else: 
            amount_in_word = amount_to_text(amount)
        vals.update({'amount':amount,'amount_in_word': amount_in_word})
        self.write(cr, user, created_id, vals, context)
        return created_id
コード例 #10
0
    def get_challans(self, data):
        #currentlty this parser is set to call for whole class challans orinting
        #both transport and acadmics
        #later on this will be set to call this parser for single students also, both academics challans and transprot challans (3-10-2017)

        challan_list = []
        ###########print challan at the time of admission for paying fee (it is before admitting student)
        if data['model'] == 'student.admission.register':
            tlt_amount = 0
            rec = self.pool.get('student.admission.register').browse(
                self.cr, self.uid, data['active_ids'])
            info_dict = {
                'name': rec.name,
                'father_name': rec.father_name,
                'Class': rec.student_class.name,
                'semester': ''
            }
            fee_res = []
            challan_dict = {
                'challan_number': '',
                'candidate_info': '',
                'on_accounts': '',
                'total_amount': '',
                'amount_in_words': ''
            }
            for fee in rec.fee_ids:
                fee_name = str(fee.name.name) + "  " + str(fee.fee_month.name)
                dict = {'head_name': fee_name, 'head_amount': fee.amount}
                fee_res.append(dict)
                tlt_amount = tlt_amount + fee.amount
            challan_dict['challan_number'] = rec.registration_no
            challan_dict['candidate_info'] = [info_dict]
            challan_dict['on_accounts'] = fee_res
            challan_dict['total_amount'] = tlt_amount
            #*******************convert the amount in text form****************************
            user_id = self.pool.get('res.users').browse(
                self.cr, self.uid, [self.uid])[0]
            cur = user_id.company_id.currency_id.name
            amt_en = amount_to_text_en.amount_to_text(tlt_amount, 'en', cur)
            return_value = str(amt_en).replace('Cent', 'Paisa')
            #*******************************************************************************
            challan_dict['amount_in_words'] = return_value
            challan_list.append(challan_dict)
        else:
            #check if printed via student form
            if 'student_id' in self.datas['form']:

                #challan is being printed via student form, canlcel all other challans of this sutdent
                challan_ids = self.pool.get('smsfee.receiptbook').search(
                    self.cr, self.uid,
                    [('challan_cat', '=', self.datas['form']['category']),
                     ('student_id', '=', self.datas['form']['student_id'][0]),
                     ('state', '=', 'fee_calculated')])
            else:
                challan_ids = self.pool.get('smsfee.receiptbook').search(
                    self.cr, self.uid,
                    [('challan_cat', '=', self.datas['form']['category']),
                     ('student_class_id', '=',
                      self.datas['form']['class_id'][0]),
                     ('state', '=', 'fee_calculated')])
        if challan_ids:
            rec_challan_ids = self.pool.get('smsfee.receiptbook').browse(
                self.cr, self.uid, challan_ids)
            for challan in rec_challan_ids:

                challan_dict = {
                    'challan_number': '',
                    'candidate_info': '',
                    'on_accounts': '',
                    'vertical_lines': '',
                    'total_amount': '',
                    'amount_in_words': '',
                    'amount_after_due_date': '',
                    'dbid': '',
                    'grand_total': '',
                    'grand_lable': '',
                    'partial_lable': '',
                    'Table_1': '',
                    'vechil_no': '',
                    'driver_name': '',
                    'vechil_name': ''
                }
                challan_dict['challan_number'] = self.get_challan_number(
                    challan.id)
                challan_dict['candidate_info'] = self.get_candidate_info(
                    challan.student_id.id)
                challan_dict['on_accounts'] = self.get_on_accounts(challan.id)
                challan_dict['vertical_lines'] = self.get_vertical_lines_total(
                    challan.id)
                challan_dict['total_amount'] = self.get_total_amount(
                    challan.id)
                challan_dict['amount_in_words'] = self.get_amount_in_words(
                    challan.id)
                challan_dict['dbid'] = self.print_challan_dbid(challan.id)
                challan_dict['total_amount'] = self.get_total_amount(
                    challan.id)
                #adding vechil No phase no and driver number to transport challans this will work for Individual
                #as well as class wise challans
                if self.datas['form']['category'] == 'Transport':
                    query = """ select vehcile_no,name,driver from  sms_transport_vehcile
                                       where id =(select vehcile_reg_students_id from sms_student where id=""" \
                            + str(challan.student_id.id) + """)"""
                    self.cr.execute(query)
                    _result1 = self.cr.fetchall()
                    if len(_result1) > 0:
                        _result2 = _result1[0]
                        veh_reg_obj = self.pool.get('res.partner').browse(
                            self.cr, self.uid, _result2[2])
                        challan_dict['vechil_no'] = "Vehcile No:" + str(
                            _result2[0])
                        challan_dict['vechil_name'] = "Vehcile Name: " + str(
                            _result2[1])
                        challan_dict['driver_name'] = "Driver Name: " + str(
                            veh_reg_obj.name)
                    else:
                        challan_dict['vechil_no'] = '--'
                        challan_dict['vechil_name'] = '--'
                        challan_dict['driver_name'] = '--'

                    if 'fee_receiving_type' in self.datas['form']:
                        if self.datas['form'][
                                'fee_receiving_type'] == "Partial":
                            grand_amt = self.pool.get(
                                'sms.student').total_outstanding_dues(
                                    self.cr, self.uid,
                                    self.datas['form']['student_id'][0],
                                    self.datas['form']['category'],
                                    'fee_unpaid')
                            total_amt = self.get_total_amount(challan.id)
                            dues = int(grand_amt) - int(total_amt)
                            challan_dict['Table_1'] = "Table_1"
                            challan_dict['grand_lable'] = "Dues:"
                            challan_dict['grand_total'] = " G.T (" + str(
                                grand_amt) + ") - P.T (" + str(
                                    total_amt) + ") =" + str(dues)
                            challan_dict['partial_lable'] = 'Partial Challan'
                    # color  #D4D4D4 [record['partial_lable']challan_dict['partial_lable']='Partial Challan'

                if self.datas['form']['amount_after_due_date']:
                    challan_dict['amount_after_due_date'] = challan_dict[
                        'total_amount'] + self.datas['form'][
                            'amount_after_due_date']
                else:
                    challan_dict['amount_after_due_date'] = data['form'][
                        'amount_after_due_date']
                challan_list.append(challan_dict)
        return challan_list
コード例 #11
0
 def convert(self, amount):
     amt_en = amount_to_text_en.amount_to_text(amount, 'en', "INR")
     return amt_en
コード例 #12
0
    def get_challans(self, data):

        challan_list = []
        print "this is unpaid_fee_challan_parser301........................."
        if data['model'] == 'student.admission.register':
            tlt_amount = 0
            rec = self.pool.get('student.admission.register').browse(
                self.cr, self.uid, data['active_ids'])
            info_dict = {
                'name': rec.name,
                'father_name': rec.father_name,
                'Class': rec.student_class.name,
                'semester': ''
            }

            fee_res = []
            challan_dict = {
                'banks_1': '',
                'challan_number_1': '',
                'candidate_info_1': '',
                'on_accounts_1': '',
                'total_amount_1': '',
                'amount_in_words_1': '',
                'banks_2': '',
                'challan_number_2': '',
                'candidate_info_2': '',
                'on_accounts_2': '',
                'total_amount_2': '',
                'amount_in_words_2': ''
            }
            i = 0
            for fee in rec.fee_ids:
                if (i % 2) == 0:
                    index = 2
                else:
                    index = (i % 2)
                print("index................  ", index)

                fee_name = str(fee.name.name) + "  " + str(fee.fee_month.name)
                dict = {'head_name': fee_name, 'head_amount': fee.amount}
                fee_res.append(dict)
                tlt_amount = tlt_amount + fee.amount

                challan_dict['challan_number_' +
                             str(index)] = rec.registration_no
                challan_dict['candidate_info_' + str(index)] = [info_dict]
                challan_dict['on_accounts_' + str(index)] = fee_res
                challan_dict['total_amount_' + str(index)] = tlt_amount

                if i % 2 == 0:
                    challan_list.append(challan_dict)
                    challan_dict = {
                        'banks_1': '',
                        'challan_number_1': '',
                        'candidate_info_1': '',
                        'on_accounts_1': '',
                        'total_amount_1': '',
                        'amount_in_words_1': '',
                        'banks_2': '',
                        'challan_number_2': '',
                        'candidate_info_2': '',
                        'on_accounts_2': '',
                        'total_amount_2': '',
                        'amount_in_words_2': ''
                    }
                i = i + 1

            if (i - 1) % 2 != 0:
                challan_list.append(challan_dict)

            #*******************convert the amount in text form****************************
            user_id = self.pool.get('res.users').browse(
                self.cr, self.uid, [self.uid])[0]
            cur = user_id.company_id.currency_id.name
            amt_en = amount_to_text_en.amount_to_text(tlt_amount, 'en', cur)
            return_value = str(amt_en).replace('Cent', 'Paisa')
            #*******************************************************************************

            challan_dict['amount_in_words'] = return_value
            challan_list.append(challan_dict)
        else:

            cls_id = self.datas['form']['class_id'][0]
            challan_ids = self.pool.get('smsfee.receiptbook').search(
                self.cr, self.uid, [('student_class_id', '=', cls_id),
                                    ('state', '=', 'fee_calculated')])
            if challan_ids:
                i = 1
                challan_dict = {
                    'challan_number_1': '',
                    'candidate_info_1': '',
                    'vertical_lines_1': '',
                    'on_accounts_1': '',
                    'total_amount_1': '',
                    'amount_in_words_1': '',
                    'amount_after_due_date_1': '',
                    'challan_number_2': '',
                    'candidate_info_2': '',
                    'vertical_lines_2': '',
                    'on_accounts_2': '',
                    'total_amount_2': '',
                    'amount_in_words_2': '',
                    'amount_after_due_date_2': ''
                }

                rec_challan_ids = self.pool.get('smsfee.receiptbook').browse(
                    self.cr, self.uid, challan_ids)
                for challan in rec_challan_ids:
                    if (i % 2) == 0:
                        index = 2
                    else:
                        index = (i % 2)
                    print("0000000000index................  ", index)
                    challan_dict['challan_number_' +
                                 str(index)] = self.get_challan_number(
                                     challan.id)
                    challan_dict['candidate_info_' +
                                 str(index)] = self.get_candidate_info(
                                     challan.student_id.id)
                    challan_dict['on_accounts_' +
                                 str(index)] = self.get_on_accounts(challan.id)
                    challan_dict['vertical_lines_' +
                                 str(index)] = self.get_vertical_lines_total(
                                     challan.id)
                    challan_dict['total_amount_' +
                                 str(index)] = self.get_total_amount(
                                     challan.id)
                    challan_dict['amount_in_words_' +
                                 str(index)] = self.get_amount_in_words(
                                     challan.id)
                    if self.datas['form']['amount_after_due_date']:
                        challan_dict['amount_after_due_date_' +
                                     str(index)] = challan_dict[
                                         'total_amount_' +
                                         str(index)] + self.datas['form'][
                                             'amount_after_due_date']
                    else:
                        challan_dict[
                            'amount_after_due_date_' +
                            str(index)] = data['form']['amount_after_due_date']
                    if i % 2 == 0:
                        challan_list.append(challan_dict)
                        challan_dict = {
                            'challan_number_1': '',
                            'candidate_info_1': '',
                            'vertical_lines_1': '',
                            'on_accounts_1': '',
                            'total_amount_1': '',
                            'amount_in_words_1': '',
                            'amount_after_due_date_1': '',
                            'challan_number_2': '',
                            'candidate_info_2': '',
                            'vertical_lines_2': '',
                            'on_accounts_2': '',
                            'total_amount_2': '',
                            'amount_in_words_2': '',
                            'amount_after_due_date_2': ''
                        }
                    i = i + 1

                if (i - 1) % 2 != 0:
                    challan_list.append(challan_dict)
        return challan_list
コード例 #13
0
 def convert(self, amount):
     amt_en = amount_to_text_en.amount_to_text(amount, 'en', 'Dolar')
     return amt_en
コード例 #14
0
 def convert(self,amount, cur):
     cur=cur.name
     amt_en = amount_to_text_en.amount_to_text(amount,'en',cur);
     return amt_en
コード例 #15
0
ファイル: invoice.py プロジェクト: mohammedmansour/odoo-india
 def amount_to_text(self, amount):
     amount_in_word = amount_to_text(amount)
     amount_in_word = amount_in_word.replace("euro", "Rupees").replace("Cents", "Paise").replace("Cent", "Paise")
     return amount_in_word
コード例 #16
0
 def convert(self,amount, cur):
     amt_en = amount_to_text_en.amount_to_text(amount,'en',cur)
     return amt_en
コード例 #17
0
 def convert(self, amount):
     user_id = self.pool.get('res.users').browse(self.cr, self.user,
                                                 [self.user])[0]
     return amount_to_text_en.amount_to_text(
         amount, 'en', user_id.company_id.currency_id.name)
コード例 #18
0
 def convert(self, amount):
     amt_en = amount_to_text_en.amount_to_text(amount, 'en', 'CLP')
     return amt_en