Esempio n. 1
0
 def contract_amountPaid(self):
     if self.amountPaid:
         return ContractValue(
             dict(
                 amount=self.amountPaid.amount,
                 amountNet=self.amountPaid.amountNet,
                 currency=self.value.currency,
                 valueAddedTaxIncluded=self.value.valueAddedTaxIncluded,
             ))
def validate_update_contracting_value_identical(request):
    value = request.validated["data"].get("value")
    paid = request.validated["json_data"].get("amountPaid")
    if has_requested_fields_changes(request, ("amountPaid",)):
        for attr in ("valueAddedTaxIncluded", "currency"):
            if paid.get(attr) is not None and value.get(attr) != ContractValue().convert(paid).get(attr):
                raise_operation_error(
                    request,
                    "{} of {} should be identical to {} of value of contract".format(attr, "amountPaid", attr),
                    name="amountPaid",
                )
def validate_update_contracting_value_identical(request, **kwargs):
    if requested_fields_changes(request, ("amountPaid",)):
        value = request.validated["data"].get("value")
        paid_data = request.validated["json_data"].get("amountPaid")
        for attr in ("valueAddedTaxIncluded", "currency"):
            if value and paid_data and paid_data.get(attr) is not None:
                paid = ContractValue(paid_data)
                if value.get(attr) != paid.get(attr):
                    raise_operation_error(
                        request,
                        "{} of {} should be identical to {} of value of contract".format(attr, "amountPaid", attr),
                        name="amountPaid",
                    )