本文整理汇总了Python中autonomie.models.tva.Tva.by_value方法的典型用法代码示例。如果您正苦于以下问题:Python Tva.by_value方法的具体用法?Python Tva.by_value怎么用?Python Tva.by_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autonomie.models.tva.Tva
的用法示例。
在下文中一共展示了Tva.by_value方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pre_paid_process
# 需要导入模块: from autonomie.models.tva import Tva [as 别名]
# 或者: from autonomie.models.tva.Tva import by_value [as 别名]
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: submit_success
# 需要导入模块: from autonomie.models.tva import Tva [as 别名]
# 或者: from autonomie.models.tva.Tva import by_value [as 别名]
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: before
# 需要导入模块: from autonomie.models.tva import Tva [as 别名]
# 或者: from autonomie.models.tva.Tva import by_value [as 别名]
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: _paid_form
# 需要导入模块: from autonomie.models.tva import Tva [as 别名]
# 或者: from autonomie.models.tva.Tva import by_value [as 别名]
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: deferred_tva_id_validator
# 需要导入模块: from autonomie.models.tva import Tva [as 别名]
# 或者: from autonomie.models.tva.Tva import by_value [as 别名]
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