def get_amount_in_words(self):
     for payment in self:
         if payment.currency_id.name == 'AED':
             payment.amount_in_words = amount_to_text_ae(
                 payment.amount_total)
         elif payment.currency_id.name == 'EUR':
             payment.amount_in_words = amount_to_text_en.amount_to_text(
                 payment.amount_total, lang='en', currency='euro')
         else:
             payment.amount_in_words = amount_to_text_en.amount_to_text(
                 payment.amount_total, lang='en', currency='')
Ejemplo n.º 2
0
 def amount_to_text(self, amount, currency='AED'):
     convert_amount_in_words = amount_to_text_en.amount_to_text(amount,
                                                                lang='en',
                                                                currency='')
     convert_amount_in_words = convert_amount_in_words.replace(
         ' and Zero Cent', ' Only ')
     return convert_amount_in_words
Ejemplo n.º 3
0
    def _get_payment_total(self, rec):
        subtotal = 0.0
        less_total = 0.0
        total = 0.0
        for line in rec.invoice_payment_id:
            subtotal += line.payment_amount

        for line in rec.payment_line_ids:
            if rec.partner_type == 'customer' and line.type == 'dr':
                less_total += line.amount
            elif rec.partner_type == 'supplier' and line.type == 'cr':
                less_total += line.amount
        total = subtotal - less_total
        amount_word = amount_to_text_en.amount_to_text(math.floor(total),
                                                       lang='en',
                                                       currency='')
        amount_word_new = amount_word.replace('Cent', '')
        if 'and Zero' in amount_word_new:
            new_amount_word = amount_word_new.replace('and Zero', '')
        else:
            new_amount_word = amount_word_new
        res = {
            'subtotal': subtotal,
            'less_total': less_total,
            'total': total,
            'amount_word': new_amount_word
        }
        return res
Ejemplo n.º 4
0
 def get_amt_inwords(self, invoice, total,ttype,currency_id):
     if ttype == 'words':
         amt_in_words = amount_to_text(total,'en',currency_id.name)
         if currency_id.name == 'INR':
             amt_in_words = amt_in_words.replace('INR','Rupees').replace('Cents','Paisa').replace('Cent','Paisa')
             return amt_in_words
     else:
         return total
Ejemplo n.º 5
0
 def amount_to_text(self, amount, currency=''):
     amount_in_words = amount_to_text_en.amount_to_text(amount, lang='en', currency=currency)
     if currency == 'INR':
         amount_in_words = str(amount_in_words).replace('INR', 'rupees')
         amount_in_words = str(amount_in_words).replace('Cents', 'paise')
         amount_in_words = str(amount_in_words).replace('Cent', 'paise')
     amount_in_words += '\tonly'
     return amount_in_words
Ejemplo n.º 6
0
 def _get_check_amount_in_words(self, amount):
     # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(amount), lang='en', currency='')
     check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh
     decimals = amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100') % str(int(round(float_round(decimals*100, precision_rounding=1))))
     return check_amount_in_words
Ejemplo n.º 7
0
    def amount_to_text(self, amount, currency='AED'):
        amount_to_text = amount_to_text_en.amount_to_text(amount, lang='en', currency='USD')
        amount_to_text = amount_to_text.replace(' and Zero Cent', ' Only')
        amount_to_text = amount_to_text.replace(' USD', '')
        amount_to_text = amount_to_text.replace(' Cents', ' fils Only')
        amount_to_text = amount_to_text.replace(' Cent', ' fils Only')

        return amount_to_text
Ejemplo n.º 8
0
 def _get_check_amount_in_words(self, amount):
     # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(amount), lang='en', currency='')
     check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh
     decimals = amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100') % str(int(round(float_round(decimals*100, precision_rounding=1))))
     return check_amount_in_words
Ejemplo n.º 9
0
 def _onchange_amount(self):
     if hasattr(super(AccountPayment, self), '_onchange_amount'):
         super(AccountPayment, self)._onchange_amount()
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='')
     check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh
     decimals = self.amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100') % str(int(round(float_round(decimals*100, precision_rounding=1))))
     self.check_amount_in_words = check_amount_in_words
Ejemplo n.º 10
0
 def _get_amount_in_word(self, doc):
     amount_word = amount_to_text_en.amount_to_text(
         doc.amount, lang='en', currency=doc.journal_id.currency_id)
     # amount_word_new = amount_word.replace('Cent', '')
     if 'and Zero' in amount_word:
         new_amount_word = amount_word.replace('and Zero', '')
     else:
         new_amount_word = amount_word
     return new_amount_word
Ejemplo n.º 11
0
 def amount_to_text(self, amount, currency):
     convert_amount_in_words = amount_to_text_en.amount_to_text(amount,
                                                                lang='en',
                                                                currency='')
     convert_amount_in_words = convert_amount_in_words.replace(',', ' ')
     convert_amount_in_words = convert_amount_in_words.replace(
         ' and Zero', ' ')
     convert_amount_in_words += 'Rupiah'
     return convert_amount_in_words
def AmountToTextFractional(amountInt):
    amount_word = amount_to_text_en.amount_to_text(
        math.floor(amountInt), lang='en', currency='')
    amount_word = amount_word.replace(' and Zero Cent', '')
    decimals = amountInt % 1
    if decimals >= 10**-2:
        amount_word += _(' and %s/100') % str(int(round(
            float_round(decimals*100, precision_rounding=1))))
    return amount_word
Ejemplo n.º 13
0
 def _get_check_amount_in_words2(self):
     check_amount_in_words = amount_to_text_en.amount_to_text(self.amount,
                                                              lang='en',
                                                              currency='')
     print("====check_amount_in_words=====", check_amount_in_words)
     check_amount_in_words = check_amount_in_words.replace(
         ' and Zero Cent', '')  # Ugh
     print("====check_amount_in_words====2=", check_amount_in_words)
     self.check_amount_in_words = check_amount_in_words
Ejemplo n.º 14
0
 def get_amount_in_word(self, amount):
     check_amount_in_words = amount_to_text_en.amount_to_text(
         math.floor(amount), lang='en', currency='')
     check_amount_in_words = check_amount_in_words.replace(
         ' and Zero Cent', '')  # Ugh
     decimals = amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' And Cents %s Only') % str(
             int(round(float_round(decimals * 100, precision_rounding=1))))
     return check_amount_in_words
Ejemplo n.º 15
0
def AmountToTextFractional(amountInt):
    amount_word = amount_to_text_en.amount_to_text(math.floor(amountInt),
                                                   lang='en',
                                                   currency='')
    amount_word = amount_word.replace(' and Zero Cent', '')
    decimals = amountInt % 1
    if decimals >= 10**-2:
        amount_word += _(' and %s/100') % str(
            int(round(float_round(decimals * 100, precision_rounding=1))))
    return amount_word
Ejemplo n.º 16
0
 def amount_to_text(self, amount, currency=''):
     amount_in_words = amount_to_text_en.amount_to_text(amount,
                                                        lang='en',
                                                        currency=currency)
     if currency == 'INR':
         amount_in_words = str(amount_in_words).replace('INR', 'rupees')
         amount_in_words = str(amount_in_words).replace('Cents', 'paise')
         amount_in_words = str(amount_in_words).replace('Cent', 'paise')
     amount_in_words += '\tonly'
     return amount_in_words
Ejemplo n.º 17
0
 def _onchange_amount(self):
     if hasattr(super(AccountRegisterPayments, self), '_onchange_amount'):
         super(AccountRegisterPayments, self)._onchange_amount()
     # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='')
     check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh
     decimals = self.amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100') % str(int(round(float_round(decimals*100, precision_rounding=1))))
     self.check_amount_in_words = check_amount_in_words
    def get_check_amount_in_words(self, amount):
        # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes
        check_amount_in_words = amount_to_text_en.amount_to_text(amount,
                                                                 lang='en',
                                                                 currency='')
        check_amount_in_words = check_amount_in_words.replace(
            'Cents', ' Only')  # Ugh
        check_amount_in_words = check_amount_in_words.replace('Cent', ' Only')
        decimals = amount % 1

        return check_amount_in_words
Ejemplo n.º 19
0
 def _get_check_amount_in_words(self, amount):
     # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes
     check_amount_in_words = amount_to_text_en.amount_to_text(
         amount, lang='en', currency='usd')
     if check_amount_in_words.find('usd') >= 1:
         check_amount_in_words = check_amount_in_words.replace(
             'usd', 'Dollars')
     check_amount_in_words = check_amount_in_words.replace(
         ' and Zero Cent', '')  # Ugh
     #decimals = amount % 1
     #if decimals >= 10**-2:
     #    check_amount_in_words += _(' and %s Cents') % str(int(round(float_round(decimals*100, precision_rounding=1))))
     return check_amount_in_words
Ejemplo n.º 20
0
 def _onchange_amount(self):
     if hasattr(super(AccountPayment, self), '_onchange_amount'):
         super(AccountPayment, self)._onchange_amount()
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(
         self.amount),
                                                              lang='en',
                                                              currency='')
     check_amount_in_words = check_amount_in_words.replace(
         ' and Zero Cent', '')  # Ugh
     decimals = self.amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100') % str(
             int(round(float_round(decimals * 100, precision_rounding=1))))
     self.check_amount_in_words = check_amount_in_words
Ejemplo n.º 21
0
 def get_check_amount(self):
     se_ids = self.env['account.payment'].search([])
     for amount in se_ids:
         if amount.amount:
             check_amount_in_words = amount_to_text_en.amount_to_text(
                 math.floor(amount.amount), lang='en', currency='')
             check_amount_in_words = check_amount_in_words.replace(
                 ' and Zero Cent', '')  # Ugh
             decimals = amount.amount % 1
             if decimals >= 10**-2:
                 a = str(
                     int(
                         round(
                             float_round(decimals * 100,
                                         precision_rounding=1))))
                 print(">>>>>>", a)
                 b = amount_to_text_en.amount_to_text(math.floor(float(a)),
                                                      lang='en',
                                                      currency='')
                 b = b.replace(' and Zero Cent', '')
                 cent_amount = _(' and %s Cents') % b
                 check_amount_in_words += cent_amount
                 amount.check_amount_in_words = check_amount_in_words
     return True
Ejemplo n.º 22
0
 def _onchange_amount(self):
     if hasattr(super(AccountRegisterPayments, self), '_onchange_amount'):
         super(AccountRegisterPayments, self)._onchange_amount()
     # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(
         self.amount),
                                                              lang='en',
                                                              currency='')
     check_amount_in_words = check_amount_in_words.replace(
         ' and Zero Cent', '')  # Ugh
     decimals = self.amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100') % str(
             int(round(float_round(decimals * 100, precision_rounding=1))))
     self.check_amount_in_words = check_amount_in_words
Ejemplo n.º 23
0
 def _amount_in_words(self):
     if self.partner_id.lang == 'fr_FR':
         self.amount_to_text = amount_to_text_fr(self.amount_total,
                                                 currency='euro')
     elif self.partner_id.lang == 'nl_NL':
         self.amount_to_text = amount_to_text_nl(self.amount_total,
                                                 currency='euro')
     elif self.partner_id.lang == 'ar_SY':
         self.amount_to_text = amount_to_text_ar.amount_to_text_ar(
             self.amount_total, currency='درهم‎‎')
     elif self.partner_id.lang == 'de_DE':
         self.amount_to_text = amount_to_text_de.amount_to_text_de(
             self.amount_total, currency='euro')
     else:
         self.amount_to_text = amount_to_text_en.amount_to_text(
             nbr=self.amount_total, currency=self.currency_id.name)
Ejemplo n.º 24
0
 def _amount_to_text(self):
     for record in self:
         record.amount_to_text = amount_to_text_en.amount_to_text(
             record.amount_total, 'id', record.currency_id.name)
Ejemplo n.º 25
0
    def numToWords(self, num, join=True, currency='VND'):
        '''words = {} convert an integer number into words'''
        # num2words(num, to='currency', lang='vi_VN')

        amount_in_words = amount_to_text_en.amount_to_text(
            num, lang='en', currency=self.company_id.currency_id.name)
        vn = Num2Word_VN_Currency()
        amount = vn.number_to_text(num, currency)
        return amount

        units = [
            '',
            _('one'),
            _('two'),
            _('three'),
            _('four'),
            _('five'),
            _('six'),
            _('seven'),
            _('eight'),
            _('nine')
        ]
        teens = [
            '',
            _('eleven'),
            _('twelve'),
            _('thirteen'),
            _('fourteen'),
            _('fifteen'),
            _('sixteen'),
            _('seventeen'),
            _('eighteen'),
            _('nineteen')
        ]
        tens = [
            '',
            _('ten'),
            _('twenty'),
            _('thirty'),
            _('forty'),
            _('fifty'),
            _('sixty'),
            _('seventy'),
            _('eighty'),
            _('ninety')
        ]
        thousands = [
            '',
            _('thousand'),
            _('million'),
            _('billion'),
            _('trillion'),
            _('quadrillion'),
            _('quintillion'),
            _('sextillion'),
            _('septillion'),
            _('octillion'),
            _('nonillion'),
            _('decillion'),
            _('undecillion'),
            _('duodecillion'),
            _('tredecillion'),
            _('quattuordecillion'),
            _('sexdecillion'),
            _('septendecillion'),
            _('octodecillion'),
            _('novemdecillion'),
            _('vigintillion')
        ]
        words = []
        if num == 0:
            words.append(_('zero'))
        else:
            numStr = '%d' % num
            numStrLen = len(numStr)
            groups = (numStrLen + 2) / 3
            numStr = numStr.zfill(groups * 3)
            for i in range(0, groups * 3, 3):
                h, t, u = int(numStr[i]), int(numStr[i + 1]), int(numStr[i +
                                                                         2])
                g = groups - (i / 3 + 1)
                if h >= 1:
                    words.append(units[h])
                    words.append(_('hundred'))
                if t > 1:
                    words.append(tens[t])
                    if u >= 1: words.append(units[u])
                elif t == 1:
                    if u >= 1:
                        words.append(teens[u])
                    else:
                        words.append(tens[t])
                else:
                    if u >= 1: words.append(units[u])
                if (g >= 1) and ((h + t + u) > 0):
                    words.append(thousands[g] + ',')
        if join: return ' '.join(words)
        return words
Ejemplo n.º 26
0
	def convert(self, amount, cur):
		return amount_to_text_en.amount_to_text(amount, 'en', cur);
Ejemplo n.º 27
0
 def get_amount_in_word(self, amount):
     amount = amount_to_text_en.amount_to_text(
         amount, 'en', self.env.user.company_id.currency_id.name)
     # amount.replace('SGD', 'Dollars')
     return amount.replace('SGD', 'Dollars')
Ejemplo n.º 28
0
 def set_amt_in_worlds(self):
     amount_in_words = amount_to_text_en.amount_to_text(self.amount_total, lang='en', currency=self.currency_id.name)
     amount_in_words += '\tOnly'
     self.amt_in_words = amount_in_words
Ejemplo n.º 29
0
 def amount_to_text(self, amount, currency):
     convert_amount_in_words = amount_to_text_en.amount_to_text(
         amount, lang='np', currency='Rupees')
     convert_amount_in_words = convert_amount_in_words.replace(
         ' and Zero Paisa', 'Only')  # Ugh
     return convert_amount_in_words
Ejemplo n.º 30
0
 def convert(self, amount, cur):
     amount_in_words = amount_to_text_en.amount_to_text(amount, 'en', cur)
     words = amount_in_words.upper()
     return words
Ejemplo n.º 31
0
    def split_products_all(self, stock_line_pool_ids, num_of_bags):

        bags = int(num_of_bags)

        final_dict = {
            "product_id_list": [],
            "product_name_list": [],
            "product_gross_list": [],
            "product_qnt_list": [],
            "price_unit_list": [],
            "price_subtotal_list": [],
            "num_of_bag_list": [],
            "total_qnt": [],
            "total_gross": [],
            "total_pri": [],
            "total_pri_word": [],
            "total_bags": []
        }

        test_dict = dict()
        p_key_list = list()
        for stock_line in stock_line_pool_ids:
            prod_id = stock_line.product_id.id
            prod_name = stock_line.product_id.name
            prod_qnt = stock_line.qty_done
            prod_gross = stock_line.qty_done * 1.04
            prod_unit_price = stock_line.product_id.list_price
            prod_sub_total = stock_line.product_id.list_price * stock_line.qty_done
            prod_num_of_bags = stock_line.qty_done / bags

            key_name = str(prod_name)
            if key_name in test_dict:
                test_dict[key_name][1] = test_dict[str(
                    prod_name)][1] + prod_qnt
                test_dict[key_name][2] = test_dict[str(
                    prod_name)][2] + prod_gross
                test_dict[key_name][4] = test_dict[str(
                    prod_name)][4] + prod_sub_total
                test_dict[key_name][5] = test_dict[str(
                    prod_name)][5] + prod_num_of_bags
            else:
                p_key_list.append(key_name)
                f_list = list()
                f_list.append(prod_id)
                f_list.append(prod_qnt)
                f_list.append(prod_gross)
                f_list.append(prod_unit_price)
                f_list.append(prod_sub_total)
                f_list.append(prod_num_of_bags)
                test_dict.update({key_name: f_list})

        product_qnt_total = 0
        product_gross_total = 0
        product_sub_total = 0
        product_num_of_bags_total = 0
        for keys in p_key_list:
            product_id = test_dict[keys][0]
            final_dict["product_id_list"].append(product_id)
            product_name = keys
            final_dict["product_name_list"].append(product_name)
            product_gross = test_dict[keys][2]
            final_dict["product_gross_list"].append(product_gross)
            product_qnt = test_dict[keys][1]
            final_dict["product_qnt_list"].append(product_qnt)
            price_subtotal = test_dict[keys][4]
            final_dict["price_subtotal_list"].append(price_subtotal)
            price_unit = test_dict[keys][3]
            final_dict["price_unit_list"].append(price_unit)
            num_of_bag = test_dict[keys][5]
            final_dict["num_of_bag_list"].append(num_of_bag)

            product_qnt_total += test_dict[keys][1]
            product_gross_total += test_dict[keys][2]
            product_sub_total += test_dict[keys][4]
            product_num_of_bags_total += test_dict[keys][5]

        final_dict["total_qnt"].append(product_qnt_total)
        final_dict["total_gross"].append(product_gross_total)
        final_dict["total_pri"].append(product_sub_total)
        words = amount_to_text_en.amount_to_text(product_sub_total, 'en',
                                                 'Dollars')
        final_dict["total_pri_word"].append(words)
        final_dict["total_bags"].append(product_num_of_bags_total)

        return final_dict
Ejemplo n.º 32
0
 def get_amount(self, amt, row, bow):
     amount_in_word = amount_to_text_en.amount_to_text(amt, row, bow)
     return amount_in_word
Ejemplo n.º 33
0
 def onchange_amount(self,amount):
     text_amount = amount_to_text_en.amount_to_text(amount, 'en', 'Dirham')
     return {'value': {'text_amount': text_amount}}
 def _computeInWords(self):
     self.in_words = amount_to_text_en.amount_to_text(self.amount_total,
                                                      currency='Dollars')
Ejemplo n.º 35
0
 def _compute_text(self):
     self.to_text = amount_to_text_en.amount_to_text(math.floor(
         self.get_total_special),
                                                     lang='en',
                                                     currency='')
Ejemplo n.º 36
0
 def convert(self, amount, cur):
     return amount_to_text_en.amount_to_text(amount, 'en', cur)