コード例 #1
0
 def fill_line_items_summary(self):
     """
     Fills line items summary table  
     Should start with a spacer
     """
     self.spacer()
     rows = [[
         _('TOTAL (excl. tax)'),
         currency_format(self.invoice_base.sub_total,
                         self.invoice_base.current_revision.currency.symbol)
     ]]
     for tax in self.invoice_base.taxes_amounts:
         rows.append([
             '%(tax_name)s (%(tax_rate)s)' % {
                 'tax_name': tax.get('name'),
                 'tax_rate': '{0:.2%}'.format(tax.get('rate'))
             },
             currency_format(
                 tax.get('amount'),
                 self.invoice_base.current_revision.currency.symbol)
         ])
     rows.append([
         _('TOTAL (incl. tax)'),
         currency_format(self.invoice_base.amount,
                         self.invoice_base.current_revision.currency.symbol)
     ])
     col_widths = (None, self.settings.page_size.scaled_width(25 * mm))
     self.start_keeptogether()
     self.table(rows,
                col_widths,
                hAlign='RIGHT',
                style=self.style['InvoiceBaseSummaryTable'])
     self.end_keeptogether()
コード例 #2
0
 def fill_line_items_summary(self):  
     """
     Fills line items summary table  
     Should start with a spacer
     """
     self.spacer()
     rows = [[
         _('TOTAL (excl. tax)'),
         currency_format(self.invoice_base.sub_total, self.invoice_base.current_revision.currency.symbol)
     ]]
     for tax in self.invoice_base.taxes_amounts:
         rows.append([
             '%(tax_name)s (%(tax_rate)s)' % {
                 'tax_name': tax.get('name'),
                 'tax_rate': '{0:.2%}'.format(tax.get('rate'))
             },
             currency_format(tax.get('amount'), self.invoice_base.current_revision.currency.symbol)
         ])
     rows.append([
         _('TOTAL (incl. tax)'),
         currency_format(self.invoice_base.amount, self.invoice_base.current_revision.currency.symbol)
     ])
     col_widths = (None, self.settings.page_size.scaled_width(25*mm))
     self.start_keeptogether()
     self.table(rows, col_widths, hAlign='RIGHT', style=self.style['InvoiceBaseSummaryTable'])
     self.end_keeptogether()
コード例 #3
0
 def fill_line_items(self):
     """
     Fills line items table  
     Should start with a spacer
     """
     self.spacer()
     rows = [[
         pgettext('table-headers', 'Description'),
         pgettext('table-headers', 'Qty'),
         pgettext('table-headers', 'Unit price (excl. tax)'),
         pgettext('table-headers', 'Tax'),
         pgettext('table-headers', 'Total (excl. tax)')
     ]]
     for item in self.invoice_base.current_revision.line_items:
         rows.append([
             item.description,
             floatformat(item.quantity, -2),
             currency_format(item.unit_price),
             '{0:.2%}'.format(item.tax.rate),
             currency_format(
                 item.total_price,
                 self.invoice_base.current_revision.currency.symbol)
         ])
     col_widths = self.settings.page_size.scaled_width(
         (85 * mm, 20 * mm, 20 * mm, 20 * mm, 25 * mm))
     self.table(rows,
                col_widths,
                repeatRows=1,
                style=self.style['InvoiceBaseItemsTable'])
コード例 #4
0
 def fill_line_items(self):
     """
     Fills line items table  
     Should start with a spacer
     """
     self.spacer()
     rows = [[
         pgettext('table-headers', 'Description'),
         pgettext('table-headers', 'Qty'),
         pgettext('table-headers', 'Unit price (excl. tax)'),
         pgettext('table-headers', 'Tax'),
         pgettext('table-headers', 'Total (excl. tax)')
     ]]
     for item in self.invoice_base.current_revision.line_items:
         rows.append([
             item.description,
             floatformat(item.quantity, -2),
             currency_format(item.unit_price),
             '{0:.2%}'.format(item.tax.rate),
             currency_format(item.total_price, self.invoice_base.current_revision.currency.symbol)
         ])
     col_widths = self.settings.page_size.scaled_width((85*mm, 20*mm, 20*mm, 20*mm, 25*mm))
     self.table(rows, col_widths, repeatRows=1, style=self.style['InvoiceBaseItemsTable'])
コード例 #5
0
ファイル: default.py プロジェクト: peicheng/vosae-app
    def fill(self):
        from django.template.defaultfilters import date as format_date, floatformat
        from reportlab.platypus.flowables import Image
        from core.pdf.utils import Paragraph
        from invoicing import currency_format

        # Sender frame
        # Sender identity
        sender_paragraphs = []
        if self.invoice_base.current_revision.sender:
            sender_paragraphs.append(Paragraph(self.invoice_base.current_revision.sender, self.style['Small']))
        sender_paragraphs.append(Paragraph(self.invoice_base.tenant.name, self.style['Small']))
        if self.invoice_base.current_revision.sender_address:
            sender_paragraphs.append(Paragraph(u'\n'.join(self.invoice_base.current_revision.sender_address.get_formatted()), self.style['Small']))
        # Add layout table if logo or paragraphs
        if self.invoice_base.tenant.logo_cache:
            logo = Image(self.invoice_base.tenant.logo_cache)
            logo_width, logo_height = logo._restrictSize(50 * mm, 20 * mm)
            self.table(
                [[logo, sender_paragraphs]],
                (logo_width + 4 * mm, None),
                self.style['LayoutTable'],
                rowHeights=(20 * mm,)
            )
        else:
            for paragraph in sender_paragraphs:
                self.append(paragraph)

        # Billing address frame
        self.next_frame()
        if self.invoice_base.current_revision.contact:
            self.p(self.invoice_base.current_revision.contact.get_full_name(upper_name=True), style=self.style['Address'])
        if self.invoice_base.current_revision.organization:
            self.p(self.invoice_base.current_revision.organization.corporate_name, style=self.style['Address'])
        if self.invoice_base.current_revision.billing_address:
            self.p(u'\n'.join(self.invoice_base.current_revision.billing_address.get_formatted()), style=self.style['Address'])

        # Delivery address frame
        self.next_frame()
        if self.invoice_base.current_revision.contact:
            self.p(self.invoice_base.current_revision.contact.get_full_name(upper_name=True), style=self.style['Address'])
        if self.invoice_base.current_revision.organization:
            self.p(self.invoice_base.current_revision.organization.corporate_name, style=self.style['Address'])
        if self.invoice_base.current_revision.delivery_address:
            self.p(u'\n'.join(self.invoice_base.current_revision.delivery_address.get_formatted()), style=self.style['Address'])

        # Rest of the report
        self.next_frame()
        invoice_reference = pgettext('date', 'Undefined') if getattr(self.invoice_base, 'has_temporary_reference', None) else self.invoice_base.reference
        self.table([[
            ' '.join([unicode(self.invoice_base.RECORD_NAME).upper(), invoice_reference]),
            format_date(self.invoice_base.current_revision.invoicing_date, 'DATE_FORMAT')
        ]], (12 * cm, 5 * cm), style=self.style['InvoiceBaseReferencesTable'])

        self.spacer()
        rows = [[
            pgettext('table-headers', 'Description'),
            pgettext('table-headers', 'Qty'),
            pgettext('table-headers', 'Unit price (excl. tax)'),
            pgettext('table-headers', 'Tax'),
            pgettext('table-headers', 'Total (excl. tax)')
        ]]
        for item in self.invoice_base.current_revision.line_items:
            rows.append([
                item.description,
                floatformat(item.quantity, -2),
                currency_format(item.unit_price),
                '{0:.2%}'.format(item.tax.rate),
                currency_format(item.total_price, self.invoice_base.current_revision.currency.symbol)
            ])
        col_widths = (85 * mm, 20 * mm, 20 * mm, 20 * mm, 25 * mm)
        self.table(rows, col_widths, repeatRows=1, style=self.style['InvoiceBaseItemsTable'])

        self.spacer()
        rows = [[
            _('TOTAL (excl. tax)'),
            currency_format(self.invoice_base.sub_total, self.invoice_base.current_revision.currency.symbol)
        ]]
        for tax in self.invoice_base.taxes_amounts:
            rows.append([
                '%(tax_name)s (%(tax_rate)s)' % {
                    'tax_name': tax.get('name'),
                    'tax_rate': '{0:.2%}'.format(tax.get('rate'))
                },
                currency_format(tax.get('amount'), self.invoice_base.current_revision.currency.symbol)
            ])
        rows.append([
            _('TOTAL (incl. tax)'),
            currency_format(self.invoice_base.amount, self.invoice_base.current_revision.currency.symbol)
        ])
        col_widths = (None, 25 * mm)
        self.start_keeptogether()
        self.table(rows, col_widths, hAlign='RIGHT', style=self.style['InvoiceBaseSummaryTable'])
        self.end_keeptogether()

        # Legal notices
        self.spacer()
        self.start_keeptogether()
        if self.invoice_base.is_quotation():
            self.p(_("Valid until %(quotation_validity)s") % {
                'quotation_validity': format_date(self.invoice_base.current_revision.quotation_validity, 'DATE_FORMAT')
            })
        elif self.invoice_base.is_purchase_order():
            if self.invoice_base.group.quotation:
                self.p(_("Refers to quotation %(quotation_reference)s") % {
                    'quotation_reference': self.invoice_base.group.quotation.reference
                })
            else:
                self.p('')
        elif self.invoice_base.is_invoice() or self.invoice_base.is_down_payment_invoice():
            if self.invoice_base.current_revision.custom_payment_conditions:
                self.p(_("Payment conditions: %(custom_payment_conditions)s") % {
                    'custom_payment_conditions': self.invoice_base.current_revision.custom_payment_conditions
                })
            else:
                self.p(_("Payment due date on %(due_date)s") % {
                    'due_date': format_date(self.invoice_base.current_revision.due_date, 'DATE_FORMAT')
                })
            pt_dict = dict(PAYMENT_TYPES)
            invoicing_settings = self.invoice_base.tenant.tenant_settings.invoicing
            self.p(_("Accepted payment methods: %(accepted_payment_methods)s") % {
                'accepted_payment_methods': u', '.join([unicode(pt_dict.get(pt, pt)).lower() for pt in invoicing_settings.accepted_payment_types])
            })
            if invoicing_settings.late_fee_rate:
                self.p(_("Late fee rate: %(late_fee_rate)s") % {
                    'late_fee_rate': u'{0:.2%}'.format(invoicing_settings.late_fee_rate)
                })
            else:
                self.p(_("Late fee at the legal rate"))
        elif self.invoice_base.is_credit_note():
            self.p(_("Refers to invoice %(invoice_reference)s") % {
                'invoice_reference': self.invoice_base.group.invoice.reference
            })
        else:
            self.p('')
        self.end_keeptogether()

        # Registration information
        self.next_frame()
        registration_info_parts = [self.invoice_base.tenant.name] + self.invoice_base.tenant.registration_info.get_list()
        self.p(u' - '.join(registration_info_parts), style=self.style['Smaller'])

        # Metadata
        if self.invoice_base.issuer:
            self.doc.author = self.invoice_base.issuer.get_full_name()
        if self.invoice_base.reference:
            document_name = ' '.join([
                unicode(self.invoice_base.RECORD_NAME).upper(),
                self.invoice_base.reference
            ])
            self.doc.title = document_name
            self.doc.subject = document_name
        self.doc.creator = self.invoice_base.tenant.name
        self.doc.keywords = self.invoice_base.keywords
コード例 #6
0
ファイル: payment.py プロジェクト: tcpr1/vosae-app
 def __unicode__(self):
     if self.date and self.amount and self.currency:
         return u'%s: %s' % (self.date, currency_format(self.amount, self.currency.symbol, True))
     return '%s object' % self.__class__.__name__
コード例 #7
0
ファイル: default.py プロジェクト: peicheng/vosae-app
    def fill(self):
        from django.template.defaultfilters import date as format_date, floatformat
        from reportlab.platypus.flowables import Image
        from core.pdf.utils import Paragraph
        from invoicing import currency_format

        # Sender frame
        # Sender identity
        sender_paragraphs = []
        if self.invoice_base.current_revision.sender:
            sender_paragraphs.append(
                Paragraph(self.invoice_base.current_revision.sender,
                          self.style['Small']))
        sender_paragraphs.append(
            Paragraph(self.invoice_base.tenant.name, self.style['Small']))
        if self.invoice_base.current_revision.sender_address:
            sender_paragraphs.append(
                Paragraph(
                    u'\n'.join(self.invoice_base.current_revision.
                               sender_address.get_formatted()),
                    self.style['Small']))
        # Add layout table if logo or paragraphs
        if self.invoice_base.tenant.logo_cache:
            logo = Image(self.invoice_base.tenant.logo_cache)
            logo_width, logo_height = logo._restrictSize(50 * mm, 20 * mm)
            self.table([[logo, sender_paragraphs]],
                       (logo_width + 4 * mm, None),
                       self.style['LayoutTable'],
                       rowHeights=(20 * mm, ))
        else:
            for paragraph in sender_paragraphs:
                self.append(paragraph)

        # Billing address frame
        self.next_frame()
        if self.invoice_base.current_revision.contact:
            self.p(self.invoice_base.current_revision.contact.get_full_name(
                upper_name=True),
                   style=self.style['Address'])
        if self.invoice_base.current_revision.organization:
            self.p(
                self.invoice_base.current_revision.organization.corporate_name,
                style=self.style['Address'])
        if self.invoice_base.current_revision.billing_address:
            self.p(u'\n'.join(self.invoice_base.current_revision.
                              billing_address.get_formatted()),
                   style=self.style['Address'])

        # Delivery address frame
        self.next_frame()
        if self.invoice_base.current_revision.contact:
            self.p(self.invoice_base.current_revision.contact.get_full_name(
                upper_name=True),
                   style=self.style['Address'])
        if self.invoice_base.current_revision.organization:
            self.p(
                self.invoice_base.current_revision.organization.corporate_name,
                style=self.style['Address'])
        if self.invoice_base.current_revision.delivery_address:
            self.p(u'\n'.join(self.invoice_base.current_revision.
                              delivery_address.get_formatted()),
                   style=self.style['Address'])

        # Rest of the report
        self.next_frame()
        invoice_reference = pgettext('date', 'Undefined') if getattr(
            self.invoice_base, 'has_temporary_reference',
            None) else self.invoice_base.reference
        self.table([[
            ' '.join([
                unicode(self.invoice_base.RECORD_NAME).upper(),
                invoice_reference
            ]),
            format_date(self.invoice_base.current_revision.invoicing_date,
                        'DATE_FORMAT')
        ]], (12 * cm, 5 * cm),
                   style=self.style['InvoiceBaseReferencesTable'])

        self.spacer()
        rows = [[
            pgettext('table-headers', 'Description'),
            pgettext('table-headers', 'Qty'),
            pgettext('table-headers', 'Unit price (excl. tax)'),
            pgettext('table-headers', 'Tax'),
            pgettext('table-headers', 'Total (excl. tax)')
        ]]
        for item in self.invoice_base.current_revision.line_items:
            rows.append([
                item.description,
                floatformat(item.quantity, -2),
                currency_format(item.unit_price),
                '{0:.2%}'.format(item.tax.rate),
                currency_format(
                    item.total_price,
                    self.invoice_base.current_revision.currency.symbol)
            ])
        col_widths = (85 * mm, 20 * mm, 20 * mm, 20 * mm, 25 * mm)
        self.table(rows,
                   col_widths,
                   repeatRows=1,
                   style=self.style['InvoiceBaseItemsTable'])

        self.spacer()
        rows = [[
            _('TOTAL (excl. tax)'),
            currency_format(self.invoice_base.sub_total,
                            self.invoice_base.current_revision.currency.symbol)
        ]]
        for tax in self.invoice_base.taxes_amounts:
            rows.append([
                '%(tax_name)s (%(tax_rate)s)' % {
                    'tax_name': tax.get('name'),
                    'tax_rate': '{0:.2%}'.format(tax.get('rate'))
                },
                currency_format(
                    tax.get('amount'),
                    self.invoice_base.current_revision.currency.symbol)
            ])
        rows.append([
            _('TOTAL (incl. tax)'),
            currency_format(self.invoice_base.amount,
                            self.invoice_base.current_revision.currency.symbol)
        ])
        col_widths = (None, 25 * mm)
        self.start_keeptogether()
        self.table(rows,
                   col_widths,
                   hAlign='RIGHT',
                   style=self.style['InvoiceBaseSummaryTable'])
        self.end_keeptogether()

        # Legal notices
        self.spacer()
        self.start_keeptogether()
        if self.invoice_base.is_quotation():
            self.p(
                _("Valid until %(quotation_validity)s") % {
                    'quotation_validity':
                    format_date(
                        self.invoice_base.current_revision.quotation_validity,
                        'DATE_FORMAT')
                })
        elif self.invoice_base.is_purchase_order():
            if self.invoice_base.group.quotation:
                self.p(
                    _("Refers to quotation %(quotation_reference)s") % {
                        'quotation_reference':
                        self.invoice_base.group.quotation.reference
                    })
            else:
                self.p('')
        elif self.invoice_base.is_invoice(
        ) or self.invoice_base.is_down_payment_invoice():
            if self.invoice_base.current_revision.custom_payment_conditions:
                self.p(
                    _("Payment conditions: %(custom_payment_conditions)s") % {
                        'custom_payment_conditions':
                        self.invoice_base.current_revision.
                        custom_payment_conditions
                    })
            else:
                self.p(
                    _("Payment due date on %(due_date)s") % {
                        'due_date':
                        format_date(
                            self.invoice_base.current_revision.due_date,
                            'DATE_FORMAT')
                    })
            pt_dict = dict(PAYMENT_TYPES)
            invoicing_settings = self.invoice_base.tenant.tenant_settings.invoicing
            self.p(
                _("Accepted payment methods: %(accepted_payment_methods)s") % {
                    'accepted_payment_methods':
                    u', '.join([
                        unicode(pt_dict.get(pt, pt)).lower()
                        for pt in invoicing_settings.accepted_payment_types
                    ])
                })
            if invoicing_settings.late_fee_rate:
                self.p(
                    _("Late fee rate: %(late_fee_rate)s") % {
                        'late_fee_rate':
                        u'{0:.2%}'.format(invoicing_settings.late_fee_rate)
                    })
            else:
                self.p(_("Late fee at the legal rate"))
        elif self.invoice_base.is_credit_note():
            self.p(
                _("Refers to invoice %(invoice_reference)s") % {
                    'invoice_reference':
                    self.invoice_base.group.invoice.reference
                })
        else:
            self.p('')
        self.end_keeptogether()

        # Registration information
        self.next_frame()
        registration_info_parts = [
            self.invoice_base.tenant.name
        ] + self.invoice_base.tenant.registration_info.get_list()
        self.p(u' - '.join(registration_info_parts),
               style=self.style['Smaller'])

        # Metadata
        if self.invoice_base.issuer:
            self.doc.author = self.invoice_base.issuer.get_full_name()
        if self.invoice_base.reference:
            document_name = ' '.join([
                unicode(self.invoice_base.RECORD_NAME).upper(),
                self.invoice_base.reference
            ])
            self.doc.title = document_name
            self.doc.subject = document_name
        self.doc.creator = self.invoice_base.tenant.name
        self.doc.keywords = self.invoice_base.keywords
コード例 #8
0
ファイル: snapshot_currency.py プロジェクト: tcpr1/vosae-app
 def currency_format(*args, **kwargs):
     return currency_format(*args, **kwargs)
コード例 #9
0
 def currency_format(*args, **kwargs):
     return currency_format(*args, **kwargs)