示例#1
0
    def submit_success(self, appstruct):
        """
            fired on submit success, set Tvas
        """
        # First we disable the elements that are no longer part of the
        # configuration
        self.disable_elements(Product, self.get_remaining_prod_ids(appstruct))
        self.disable_elements(Tva, self.get_remaining_tva_ids(appstruct))
        self.dbsession.flush()

        for data in appstruct['tvas']:
            products = data.pop('products')
            if 'id' in data:
                tva = Tva.get(data['id'])
                merge_session_with_post(tva, data)
                tva = self.dbsession.merge(tva)
            else:
                tva = Tva()
                merge_session_with_post(tva, data)
                self.dbsession.add(tva)

            for prod in products:
                if 'id' in prod:
                    product = Product.get(prod['id'])
                    product.tva = tva
                    merge_session_with_post(product, prod)
                    self.dbsession.merge(product)
                else:
                    product = Product()
                    merge_session_with_post(product, prod)
                    product.tva = tva
                    self.dbsession.add(product)
        self.request.session.flash(self.validation_msg)
        return HTTPFound(self.request.route_path("admin_tva"))
示例#2
0
    def submit_success(self, appstruct):
        """
            fired on submit success, set Tvas
        """
        # First we disable the elements that are no longer part of the
        # configuration
        self.disable_elements(Product, self.get_remaining_prod_ids(appstruct))
        self.disable_elements(Tva, self.get_remaining_tva_ids(appstruct))
        self.dbsession.flush()

        for data in appstruct['tvas']:
            products = data.pop('products')
            if 'id' in data:
                tva = Tva.get(data['id'])
                merge_session_with_post(tva, data)
                tva = self.dbsession.merge(tva)
            else:
                tva = Tva()
                merge_session_with_post(tva, data)
                self.dbsession.add(tva)

            for prod in products:
                if 'id' in prod:
                    product = Product.get(prod['id'])
                    product.tva = tva
                    merge_session_with_post(product, prod)
                    self.dbsession.merge(product)
                else:
                    product = Product()
                    merge_session_with_post(product, prod)
                    product.tva = tva
                    self.dbsession.add(product)
        self.request.session.flash(self.validation_msg)
        return HTTPFound(self.request.route_path("admin_tva"))
示例#3
0
    def validate_amount_by_tva(values):
        tva_id = values.get('tva_id')
        tva = Tva.get(tva_id)
        if tva is None:
            return u"Tva inconnue"
        amount = values.get('amount')
        if amount > tva_parts[tva.value]:
            return u"Le montant de l'encaissement doit être inférieur à la \
part de cette Tva dans la facture"
        return True
示例#4
0
    def validate_amount_by_tva(values):
        tva_id = values.get('tva_id')
        tva = Tva.get(tva_id)
        if tva is None:
            return u"Tva inconnue"
        amount = values.get('amount')
        if amount > tva_parts[tva.value]:
            return u"Le montant de l'encaissement doit être inférieur à la \
part de cette Tva dans la facture"

        return True
示例#5
0
    def validate_amount_by_tva(values):
        tva_id = values.get('tva_id')
        tva = Tva.get(tva_id)
        if tva is None:
            return u"Tva inconnue"
        amount = values.get('amount')
        # Fix #433 : encaissement et tva multiples
        # Add a tolerance for 5 € of difference
        if amount > tva_parts[tva.value] + PAYMENT_EPSILON:
            return u"Le montant de l'encaissement doit être inférieur à la \
part de cette Tva dans la facture"
        return True
示例#6
0
def tva_product_validator(node, value):
    product_id = value.get('product_id')
    if product_id is not None:
        tva_id = value.get('tva_id')
        if tva_id is not None:
            tva = Tva.get(tva_id)
            if product_id not in [p.id for p in tva.products]:
                exc = colander.Invalid(
                    node, u"Ce produit ne correspond pas à la TVA configurée")
                exc['product_id'] = u"Le code produit doit correspondre à la \
                    TVA configurée pour cette prestation"

                raise exc
示例#7
0
    def validate_amount_by_tva(values):
        tva_id = values.get('tva_id')
        tva = Tva.get(tva_id)
        if tva is None:
            return u"Tva inconnue"
        amount = values.get('amount')
        # Fix #433 : encaissement et tva multiples
        # Add a tolerance for 5 € of difference
        if amount > tva_parts[tva.value] + PAYMENT_EPSILON:
            return u"Le montant de l'encaissement doit être inférieur à la \
part de cette Tva dans la facture"

        return True
示例#8
0
def tva_product_validator(node, value):
    """
    Validator checking that tva and product_id matches
    """
    product_id = value.get('product_id')
    if product_id is not None:
        tva_id = value.get('tva_id')
        if tva_id is not None:
            tva = Tva.get(tva_id)
            if product_id not in [p.id for p in tva.products]:
                exc = colander.Invalid(
                    node,
                    u"Ce produit ne correspond pas à la TVA configurée"
                )
                exc['product_id'] = u"Le code produit doit correspondre à la \
                    TVA configurée pour cette prestation"
                raise exc