Пример #1
0
    def _compute_l10n_ch_isr_optical_line(self):
        """ The optical reading line of the ISR looks like this :
                left>isr_ref+ bank_ref>

           Where:
           - left is composed of two ciphers indicating the currency (01 for CHF,
           03 for EUR), followed by ten characters containing the total of the
           invoice (with the dot between units and cents removed, everything being
           right-aligned and empty places filled with zeros). After the total,
           left contains a last cipher, which is the result of a recursive modulo
           10 function ran over the rest of it.

            - isr_ref is the ISR reference number

            - bank_ref is the full postal bank code (aka clearing number) of the
            bank supporting the ISR (including the zeros).
        """
        for record in self:
            if record.l10n_ch_isr_number and record.l10n_ch_isr_postal and record.currency_id.name:
                #Left part
                currency_code = None
                if record.currency_id.name == 'CHF':
                    currency_code = '01'
                elif record.currency_id.name == 'EUR':
                    currency_code = '03'
                units, cents = float_split_str(record.amount_total, 2)
                amount_to_display = units + cents
                amount_ref = amount_to_display.zfill(10)
                left = currency_code + amount_ref
                left = mod10r(left)
                #Final assembly (the space after the '+' is no typo, it stands in the specs.)
                record.l10n_ch_isr_optical_line = left + '>' + record.l10n_ch_isr_number + '+ ' + record.l10n_ch_isr_postal + '>'
Пример #2
0
    def split_total_amount(self):
        """ Splits the total amount of this invoice in two parts, using the dot as
       a separator, and taking two precision digits (always displayed).
       These two parts are returned as the two elements of a tuple, as strings
       to print in the report.

       This function is needed on the model, as it must be called in the report
       template, which cannot reference static functions
       """
        return float_split_str(self.amount_total, 2)
Пример #3
0
 def _get_l10n_ch_isr_optical_amount(self):
     """Prepare amount string for ISR optical line"""
     self.ensure_one()
     currency_code = None
     if self.currency_id.name == 'CHF':
         currency_code = '01'
     elif self.currency_id.name == 'EUR':
         currency_code = '03'
     units, cents = float_split_str(self.amount_residual, 2)
     amount_to_display = units + cents
     amount_ref = amount_to_display.zfill(10)
     optical_amount = currency_code + amount_ref
     optical_amount = mod10r(optical_amount)
     return optical_amount