Exemple #1
0
    def format(self, include_receiver=True, include_doc=True):
        txt = '%s                       [#%s]\n' % (gmTools.bool2subst(
            (self._payload[self._idx['close_date']] is None), _('Open bill'),
            _('Closed bill')), self._payload[self._idx['pk_bill']])
        txt += _(' Invoice ID: %s\n') % self._payload[self._idx['invoice_id']]

        if self._payload[self._idx['close_date']] is not None:
            txt += _(' Closed: %s\n') % gmDateTime.pydt_strftime(
                self._payload[self._idx['close_date']],
                '%Y %b %d',
                accuracy=gmDateTime.acc_days)

        if self._payload[self._idx['comment']] is not None:
            txt += _(' Comment: %s\n') % self._payload[self._idx['comment']]

        txt += _(' Bill value: %(curr)s%(val)s\n') % {
            'curr': self._payload[self._idx['currency']],
            'val': self._payload[self._idx['total_amount']]
        }

        if self._payload[self._idx['apply_vat']] is None:
            txt += _(' VAT: undecided\n')
        elif self._payload[self._idx['apply_vat']] is True:
            txt += _(' VAT: %(perc_vat)s%% %(equals)s %(curr)s%(vat)s\n') % {
                'perc_vat': self._payload[self._idx['percent_vat']],
                'equals': gmTools.u_corresponds_to,
                'curr': self._payload[self._idx['currency']],
                'vat': self._payload[self._idx['total_vat']]
            }
            txt += _(' Value + VAT: %(curr)s%(val)s\n') % {
                'curr': self._payload[self._idx['currency']],
                'val': self._payload[self._idx['total_amount_with_vat']]
            }
        else:
            txt += _(' VAT: does not apply\n')

        if self._payload[self._idx['pk_bill_items']] is None:
            txt += _(' Items billed: 0\n')
        else:
            txt += _(' Items billed: %s\n') % len(
                self._payload[self._idx['pk_bill_items']])
        if include_doc:
            txt += _(' Invoice: %s\n') % (gmTools.bool2subst(
                self._payload[self._idx['pk_doc']] is None, _('not available'),
                '#%s' % self._payload[self._idx['pk_doc']]))
        txt += _(' Patient: #%s\n') % self._payload[self._idx['pk_patient']]
        if include_receiver:
            txt += gmTools.coalesce(
                self._payload[self._idx['pk_receiver_identity']], '',
                _(' Receiver: #%s\n'))
            if self._payload[self._idx['pk_receiver_address']] is not None:
                txt += '\n '.join(
                    gmDemographicRecord.get_patient_address(
                        pk_patient_address=self._payload[
                            self._idx['pk_receiver_address']]).format())

        return txt
Exemple #2
0
	def format(self, include_receiver=True, include_doc=True):
		txt = '%s                       [#%s]\n' % (
			gmTools.bool2subst (
				(self._payload[self._idx['close_date']] is None),
				_('Open bill'),
				_('Closed bill')
			),
			self._payload[self._idx['pk_bill']]
		)
		txt += _(' Invoice ID: %s\n') % self._payload[self._idx['invoice_id']]

		if self._payload[self._idx['close_date']] is not None:
			txt += _(' Closed: %s\n') % gmDateTime.pydt_strftime (
				self._payload[self._idx['close_date']],
				'%Y %b %d',
				accuracy = gmDateTime.acc_days
			)

		if self._payload[self._idx['comment']] is not None:
			txt += _(' Comment: %s\n') % self._payload[self._idx['comment']]

		txt += _(' Bill value: %(curr)s%(val)s\n') % {
			'curr': self._payload[self._idx['currency']],
			'val': self._payload[self._idx['total_amount']]
		}

		if self._payload[self._idx['apply_vat']] is None:
			txt += _(' VAT: undecided\n')
		elif self._payload[self._idx['apply_vat']] is True:
			txt += _(' VAT: %(perc_vat)s%% %(equals)s %(curr)s%(vat)s\n') % {
				'perc_vat': self._payload[self._idx['percent_vat']],
				'equals': gmTools.u_corresponds_to,
				'curr': self._payload[self._idx['currency']],
				'vat': self._payload[self._idx['total_vat']]
			}
			txt += _(' Value + VAT: %(curr)s%(val)s\n') % {
				'curr': self._payload[self._idx['currency']],
				'val': self._payload[self._idx['total_amount_with_vat']]
			}
		else:
			txt += _(' VAT: does not apply\n')

		if self._payload[self._idx['pk_bill_items']] is None:
			txt += _(' Items billed: 0\n')
		else:
			txt += _(' Items billed: %s\n') % len(self._payload[self._idx['pk_bill_items']])
		if include_doc:
			txt += _(' Invoice: %s\n') % (
				gmTools.bool2subst (
					self._payload[self._idx['pk_doc']] is None,
					_('not available'),
					'#%s' % self._payload[self._idx['pk_doc']]
				)
			)
		txt += _(' Patient: #%s\n') % self._payload[self._idx['pk_patient']]
		if include_receiver:
			txt += gmTools.coalesce (
				self._payload[self._idx['pk_receiver_identity']],
				'',
				_(' Receiver: #%s\n')
			)
			if self._payload[self._idx['pk_receiver_address']] is not None:
				txt += '\n '.join(gmDemographicRecord.get_patient_address(pk_patient_address = self._payload[self._idx['pk_receiver_address']]).format())

		return txt