Beispiel #1
0
 def forwards(self, orm):
     from invoicing.models import InvoiceBaseGroup
     # Process quotations
     for quotation in Quotation.objects():
         group = InvoiceBaseGroup(tenant=quotation.tenant, quotation=quotation).save()
         if quotation._data.get('down_payments'):
             group.down_payment_invoices = dereference(quotation._data.get('down_payments'), DownPaymentInvoice)
             for down_payment_invoice in group.down_payment_invoices:
                 down_payment_invoice.update(set__group=group)
         if quotation._data.get('related_invoice'):
             group.invoice = dereference(quotation._data.get('related_invoice'), Invoice)
             group.invoice.update(set__group=group)
         if quotation._data.get('related_invoices_cancelled'):
             group.invoices_cancelled = dereference(quotation._data.get('related_invoices_cancelled'), Invoice)
             for invoice_cancelled in group.invoices_cancelled:
                 invoice_cancelled.update(set__group=group)
         group.save()
         quotation.update(set__group=group)
     
     # Process invoices and down-payment invoices
     for invoice in Invoice.objects():
         if not invoice.group.id:
             # Can only be an invoice: down-payment invoices are linked to quotations, so group is set
             group = InvoiceBaseGroup(tenant=quotation.tenant, invoice=invoice).save()
             invoice.update(set__group=group)
         else:
             group = invoice.group
         if invoice._data.get('related_credit_note'):
             group.credit_notes = [dereference(invoice._data.get('related_credit_note'), CreditNote)]
             for credit_note in group.credit_notes:
                 credit_note.update(set__group=group, set__related_to=invoice)
         group.save()
Beispiel #2
0
    def forwards(self, orm):
        # Quotation
        for quotation in Quotation.objects():
            quotation._changed_fields = [
                'tenant', 'issuer', 'organization', 'contact', 'attachments',
                'related_invoice', 'down_payments', 'subscribers'
            ]
            set_embedded_changed_fields(quotation)
            quotation.save()

        # Invoice
        for invoice in Invoice.objects():
            invoice._changed_fields = [
                'tenant', 'issuer', 'organization', 'contact', 'attachments',
                'related_quotation', 'payments', 'subscribers'
            ]
            set_embedded_changed_fields(invoice)
            invoice.save()

        # DownPaymentInvoice
        for down_payment_invoice in DownPaymentInvoice.objects():
            down_payment_invoice._changed_fields = [
                'tenant', 'issuer', 'organization', 'contact', 'attachments',
                'related_quotation', 'payments', 'tax_applied', 'subscribers'
            ]
            set_embedded_changed_fields(down_payment_invoice)
            down_payment_invoice.save()

        # CreditNote
        for credit_note in CreditNote.objects():
            credit_note._changed_fields = [
                'tenant', 'issuer', 'organization', 'contact', 'attachments',
                'related_invoice', 'subscribers'
            ]
            set_embedded_changed_fields(credit_note)
            credit_note.save()

        # Item
        for item in Item.objects():
            item._changed_fields = ['tenant', 'currency', 'tax']
            item.save()

        # Payment
        for payment in Payment.objects():
            payment._changed_fields = ['tenant', 'issuer', 'currency']
            payment.save()

        # Tax
        for tax in Tax.objects():
            tax._changed_fields = ['tenant']
            tax.save()
    def forwards(self, orm):
        # Quotation
        for quotation in Quotation.objects():
            quotation._changed_fields = ['tenant', 'issuer', 'organization', 'contact', 'attachments', 'related_invoice', 'down_payments', 'subscribers']
            set_embedded_changed_fields(quotation)
            quotation.save()

        # Invoice
        for invoice in Invoice.objects():
            invoice._changed_fields = ['tenant', 'issuer', 'organization', 'contact', 'attachments', 'related_quotation', 'payments', 'subscribers']
            set_embedded_changed_fields(invoice)
            invoice.save()

        # DownPaymentInvoice
        for down_payment_invoice in DownPaymentInvoice.objects():
            down_payment_invoice._changed_fields = ['tenant', 'issuer', 'organization', 'contact', 'attachments', 'related_quotation', 'payments', 'tax_applied', 'subscribers']
            set_embedded_changed_fields(down_payment_invoice)
            down_payment_invoice.save()

        # CreditNote
        for credit_note in CreditNote.objects():
            credit_note._changed_fields = ['tenant', 'issuer', 'organization', 'contact', 'attachments', 'related_invoice', 'subscribers']
            set_embedded_changed_fields(credit_note)
            credit_note.save()

        # Item
        for item in Item.objects():
            item._changed_fields = ['tenant', 'currency', 'tax']
            item.save()

        # Payment
        for payment in Payment.objects():
            payment._changed_fields = ['tenant', 'issuer', 'currency']
            payment.save()

        # Tax
        for tax in Tax.objects():
            tax._changed_fields = ['tenant']
            tax.save()