Ejemplo n.º 1
0
    def gen_cancelinvoice(self, user):
        """
            Return a cancel invoice with self's informations
        """
        cancelinvoice = CancelInvoice(
            user=user,
            company=self.company,
            project=self.project,
            customer=self.customer,
            phase_id=self.phase_id,
            address=self.address,
            workplace=self.workplace,
            description=self.description,
            invoice=self,
            expenses_ht=-1 * self.expenses_ht,
            financial_year=self.financial_year,
            display_units=self.display_units,
            business_type_id=self.business_type_id,
            business_id=self.business_id,
        )

        cancelinvoice.line_groups = []
        for group in self.line_groups:
            cancelinvoice.line_groups.append(
                group.gen_cancelinvoice_group()
            )
        order = self.get_next_row_index()

        for discount in self.discounts:
            discount_line = TaskLine(
                cost=discount.amount,
                tva=discount.tva,
                quantity=1,
                description=discount.description,
                order=order,
                unity='',
            )
            discount_line.product_id = Product.first_by_tva_value(discount.tva)
            order += 1
            cancelinvoice.default_line_group.lines.append(discount_line)

        for index, payment in enumerate(self.payments):
            paid_line = TaskLine(
                cost=math_utils.reverse_tva(
                    payment.amount,
                    payment.tva.value,
                    False,
                ),
                tva=payment.tva.value,
                quantity=1,
                description=u"Paiement {0}".format(index + 1),
                order=order,
                unity='NONE',
            )
            paid_line.product_id = Product.first_by_tva_value(payment.tva.value)
            order += 1
            cancelinvoice.default_line_group.lines.append(paid_line)
        cancelinvoice.mentions = self.mentions
        cancelinvoice.payment_conditions = u"Réglé"
        return cancelinvoice
Ejemplo n.º 2
0
    def gen_cancelinvoice(self, user):
        """
            Return a cancel invoice with self's informations
        """
        cancelinvoice = CancelInvoice(
            user=user,
            company=self.company,
            project=self.project,
            customer=self.customer,
            phase_id=self.phase_id,
            address=self.address,
            workplace=self.workplace,
            description=self.description,
            invoice=self,
            expenses_ht=-1 * self.expenses_ht,
            financial_year=self.financial_year,
            display_units=self.display_units,
            business_type_id=self.business_type_id,
            business_id=self.business_id,
        )

        cancelinvoice.line_groups = []
        for group in self.line_groups:
            cancelinvoice.line_groups.append(
                group.gen_cancelinvoice_group()
            )
        order = self.get_next_row_index()

        for discount in self.discounts:
            discount_line = TaskLine(
                cost=discount.amount,
                tva=discount.tva,
                quantity=1,
                description=discount.description,
                order=order,
                unity='',
            )
            discount_line.product_id = Product.first_by_tva_value(discount.tva)
            order += 1
            cancelinvoice.default_line_group.lines.append(discount_line)

        for index, payment in enumerate(self.payments):
            paid_line = TaskLine(
                cost=math_utils.reverse_tva(
                    payment.amount,
                    payment.tva.value,
                    False,
                ),
                tva=payment.tva.value,
                quantity=1,
                description=u"Paiement {0}".format(index + 1),
                order=order,
                unity='NONE',
            )
            paid_line.product_id = Product.first_by_tva_value(payment.tva.value)
            order += 1
            cancelinvoice.default_line_group.lines.append(paid_line)
        cancelinvoice.mentions = self.mentions
        cancelinvoice.payment_conditions = u"Réglé"
        return cancelinvoice
Ejemplo n.º 3
0
 def _account_invoiceline(self, amount, description, tva=1960):
     """
         Return an account invoiceline
     """
     line = TaskLine(cost=amount, description=description, tva=tva)
     line.product_id = Product.first_by_tva_value(tva)
     return line
Ejemplo n.º 4
0
 def _get_task_line(cls, cost, description, tva):
     from autonomie.models.task.task import TaskLine
     from autonomie.models.tva import Product
     line = TaskLine(cost=cost,
                     description=description,
                     tva=tva,
                     quantity=1)
     line.product_id = Product.first_by_tva_value(tva)
     return line
Ejemplo n.º 5
0
    def post_format(self, entry, edit, attributes):
        """
        Associate a newly created element to the parent group
        """
        if not edit:
            entry.group = self.context

        if 'tva' in attributes and 'product_id' not in attributes and \
                entry.tva is not None:
            entry.product_id = Product.first_by_tva_value(entry.tva)
        return entry
Ejemplo n.º 6
0
    def post_format(self, entry, edit, attributes):
        """
        Associate a newly created element to the parent group
        """
        if not edit:
            entry.group = self.context

        if 'tva' in attributes and 'product_id' not in attributes and \
                entry.tva is not None:
            entry.product_id = Product.first_by_tva_value(entry.tva)
        return entry
Ejemplo n.º 7
0
 def _get_task_line(cls, cost, description, tva):
     from autonomie.models.task.task import TaskLine
     from autonomie.models.tva import Product
     line = TaskLine(cost=cost, description=description, tva=tva, quantity=1)
     line.product_id = Product.first_by_tva_value(tva)
     return line