示例#1
0
    def pre_paid_process(self, task, status, params):
        """
            Validate a payment form's data
        """
        form = get_paid_form(self.request)
        # We don't try except on the data validation, since this is done in the
        # original wrapping call (see taskaction set_status)
        appstruct = form.validate(params.items())

        if 'amount' in appstruct:
            # Les lignes de facture ne conservent pas le lien avec les objets
            # Tva, ici on en a une seule, on récupère l'objet et on le set sur
            # le amount
            appstruct['tva_id'] = Tva.by_value(
                self.context.get_tvas().keys()[0]
            ).id

        elif 'tvas' in appstruct:
            # Ce champ ne servait que pour tester las somme des valeurs saisies
            appstruct.pop('payment_amount')
            # si on a plusieurs tva :
            for tva_payment in appstruct['tvas']:
                remittance_amount = appstruct['remittance_amount']
                tva_payment['remittance_amount'] = remittance_amount
                tva_payment['date'] = appstruct['date']
                tva_payment['mode'] = appstruct['mode']
                tva_payment['bank_id'] = appstruct.get('bank_id')
                tva_payment['resulted'] = appstruct.get('resulted', False)
        else:
            raise Exception(u"On a rien à faire ici")

        logger.debug(u"In pre paid process")
        logger.debug(u"Returning : {0}".format(appstruct))
        return appstruct
示例#2
0
    def submit_success(self, appstruct):
        if 'amount' in appstruct:
            appstruct['tva_id'] = Tva.by_value(
                self.context.get_tvas().keys()[0]
            ).id
            self.context.record_payment(
                user_id=self.request.user.id,
                **appstruct
            )
        elif 'tvas' in appstruct:
            appstruct.pop('payment_amount')
            # si on a plusieurs tva :
            for tva_payment in appstruct['tvas']:
                bank_remittance_id = appstruct['bank_remittance_id']
                tva_payment['bank_remittance_id'] = bank_remittance_id
                tva_payment['date'] = appstruct['date']
                tva_payment['mode'] = appstruct['mode']
                tva_payment['bank_id'] = appstruct.get('bank_id')
                tva_payment['resulted'] = appstruct.get('resulted', False)
                self.context.record_payment(
                    user_id=self.request.user.id,
                    **tva_payment
                )

        self.request.dbsession.merge(self.context)
        self.notify()
        return self.redirect()
示例#3
0
    def before(self, form):
        BaseFormView.before(self, form)
        self.request.actionmenu.add(
            ViewLink(
                label=u"Revenir à la facture",
                path="/invoices/{id}.html",
                id=self.context.id,
                _anchor="payment",
            )
        )

        appstruct = []
        for tva_value, value in self.context.topay_by_tvas().items():
            tva = Tva.by_value(tva_value)
            appstruct.append(
                {
                    'tva_id': tva.id,
                    'amount': floor_to_precision(
                        value,
                        precision=2,
                        dialect_precision=5
                    )
                }
            )

        if len(appstruct) == 1:
            form.set_appstruct(appstruct[0])
        else:
            form.set_appstruct({'tvas': appstruct})
示例#4
0
    def _paid_form(self):
        """
            return the form for payment registration
        """
        form = get_paid_form(self.request, self.formcounter)
        appstruct = []
        for tva_value, value in self.context.topay_by_tvas().items():
            tva = Tva.by_value(tva_value)
            appstruct.append({'tva_id': tva.id, 'amount': value})
            form.set_appstruct({'tvas': appstruct})

        self.formcounter = form.counter
        return form
示例#5
0
def deferred_tva_id_validator(node, kw):
    ctx = kw['request'].context
    if isinstance(ctx, Payment):
        invoice = ctx.parent
    else:
        invoice = ctx
    values = []
    for tva_value in invoice.topay_by_tvas().keys():
        values.append(Tva.by_value(tva_value))

    def validator(node, value):
        if value not in [v.id for v in values]:
            raise colander.Invalid(
                node,
                u"Ce taux de tva n'est pas utilisé dans la facture",
            )

    return validator
示例#6
0
文件: invoice.py 项目: lluc/autonomie
    def before(self, form):
        BaseFormView.before(self, form)
        self.request.actionmenu.add(
            ViewLink(
                label=u"Revenir à la facture",
                path="/invoices/{id}.html",
                id=self.context.id,
                _anchor="payment",
            ))

        appstruct = []
        for tva_value, value in self.context.topay_by_tvas().items():
            tva = Tva.by_value(tva_value)
            appstruct.append({
                'tva_id':
                tva.id,
                'amount':
                floor_to_precision(value, precision=2, dialect_precision=5)
            })

        if len(appstruct) == 1:
            form.set_appstruct(appstruct[0])
        else:
            form.set_appstruct({'tvas': appstruct})