Exemplo n.º 1
0
 def cancel_invoice(self, invoice) :
     credit_note = models.Invoice()
     credit_note.amount = -1 * invoice.amount
     credit_note.currency = invoice.currency
     credit_note.header = invoice.header
     credit_note.office_address_street = invoice.office_address_street
     credit_note.office_address_complement = invoice.office_address_complement
     credit_note.office_address_zipcode = invoice.office_address_zipcode
     credit_note.office_address_city = invoice.office_address_city
     credit_note.office_phone = invoice.office_phone
     credit_note.office_siret = invoice.office_siret
     credit_note.paiment_mode = invoice.paiment_mode
     credit_note.therapeut_name = invoice.therapeut_name
     credit_note.therapeut_first_name = invoice.therapeut_first_name
     credit_note.therapeut_id = invoice.therapeut_id
     credit_note.quality = invoice.quality
     credit_note.adeli = invoice.adeli
     credit_note.location = invoice.location
     credit_note.patient_family_name = invoice.patient_family_name
     credit_note.patient_original_name = invoice.patient_original_name
     credit_note.patient_first_name = invoice.patient_first_name
     credit_note.patient_address_street = invoice.patient_address_street
     credit_note.patient_address_complement = invoice.patient_address_complement
     credit_note.patient_address_zipcode = invoice.patient_address_zipcode
     credit_note.patient_address_city = invoice.patient_address_city
     credit_note.content_invoice = invoice.content_invoice
     credit_note.footer = invoice.footer
     credit_note.date = datetime.today()
     credit_note.type = 'creditnote' if credit_note.amount < 0 else 'invoice'
     credit_note.number = self.get_invoice_number()
     credit_note.status = models.InvoiceStatus.INVOICED_PAID
     return credit_note
Exemplo n.º 2
0
    def generate_invoice(self, invoicingSerializerData):
        officesettings = models.OfficeSettings.objects.all()[0]
        therapeutsettings = models.TherapeutSettings.objects.filter(
            user=self.request.user)[0]

        invoice = models.Invoice()
        invoice.amount = invoicingSerializerData['amount']
        invoice.currency = officesettings.currency
        invoice.header = officesettings.invoice_office_header
        invoice.office_address_street = officesettings.office_address_street
        invoice.office_address_complement = officesettings.office_address_complement
        invoice.office_address_zipcode = officesettings.office_address_zipcode
        invoice.office_address_city = officesettings.office_address_city
        invoice.office_phone = officesettings.office_phone
        invoice.office_siret = officesettings.office_siret

        # Override the siret on the invoice with the therapeut siret if defined
        if therapeutsettings.siret is not None:
            invoice.office_siret = therapeutsettings.siret

        invoice.paiment_mode = invoicingSerializerData['paiment_mode']
        invoice.therapeut_name = self.request.user.last_name
        invoice.therapeut_first_name = self.request.user.first_name
        invoice.quality = therapeutsettings.quality
        invoice.adeli = therapeutsettings.adeli
        invoice.location = officesettings.office_address_city
        invoice.number = ""

        invoice.patient_family_name = self.get_object().patient.family_name
        invoice.patient_original_name = self.get_object().patient.original_name
        invoice.patient_first_name = self.get_object().patient.first_name
        invoice.patient_address_street = self.get_object(
        ).patient.address_street
        invoice.patient_address_complement = self.get_object(
        ).patient.address_complement
        invoice.patient_address_zipcode = self.get_object(
        ).patient.address_zipcode
        invoice.patient_address_city = self.get_object().patient.address_city
        invoice.content_invoice = officesettings.invoice_content
        invoice.footer = officesettings.invoice_footer

        # Override the footer on the invoice with the therapeut settings if defined
        if therapeutsettings.invoice_footer is not None:
            invoice.footer = therapeutsettings.invoice_footer
        invoice.date = datetime.today()
        invoice.save()
        invoice.number += unicode(10000 + invoice.id)
        invoice.save()
        return invoice
Exemplo n.º 3
0
    def generate_invoice(self, examination, serializer_data, request):
        invoice = models.Invoice()
        invoice.amount = serializer_data['amount']
        invoice.currency = self.office_settings.currency
        invoice.header = self.office_settings.invoice_office_header
        invoice.office_address_street = self.office_settings.office_address_street
        invoice.office_address_complement = self.office_settings.office_address_complement
        invoice.office_address_zipcode = self.office_settings.office_address_zipcode
        invoice.office_address_city = self.office_settings.office_address_city
        invoice.office_phone = self.office_settings.office_phone
        invoice.office_siret = self.office_settings.office_siret

        invoice.icon = self.office_settings.icon
        invoice.dateExamination = examination.date
        invoice.icon = self.office_settings.icon
        invoice.numDiplome = self.therapeut_settings.numDiplome
        invoice.codeAPE = self.therapeut_settings.codeAPE
        invoice.numSS = examination.patient.numSS
        invoice.numMut = examination.patient.numMut

        # Override the siret on the invoice with the therapeut siret if defined
        if self.therapeut_settings.siret is not None:
            invoice.office_siret = self.therapeut_settings.siret

        invoice.paiment_mode = serializer_data['paiment_mode']
        invoice.therapeut_name = request.user.last_name
        invoice.therapeut_first_name = request.user.first_name
        invoice.therapeut_id = request.user.id
        invoice.quality = self.therapeut_settings.quality
        invoice.adeli = self.therapeut_settings.adeli
        invoice.location = self.office_settings.office_address_city

        invoice.patient_family_name = examination.patient.family_name
        invoice.patient_original_name = examination.patient.original_name
        invoice.patient_first_name = examination.patient.first_name
        invoice.patient_address_street = examination.patient.address_street
        invoice.patient_address_complement = examination.patient.address_complement
        invoice.patient_address_zipcode = examination.patient.address_zipcode
        invoice.patient_address_city = examination.patient.address_city
        invoice.content_invoice = self.office_settings.invoice_content
        invoice.footer = self.office_settings.invoice_footer

        # Override the footer on the invoice with the therapeut settings if defined
        if self.therapeut_settings.invoice_footer is not None:
            invoice.footer = self.therapeut_settings.invoice_footer
        invoice.number = self.get_invoice_number()
        invoice.date = datetime.today()
        return invoice
Exemplo n.º 4
0
    def generate_invoice(self, examination, serializer_data, user_therapeut):
        invoice = models.Invoice()
        invoice.amount = serializer_data['amount']
        invoice.currency = self.office_settings.currency
        invoice.header = self.office_settings.invoice_office_header
        invoice.office_address_street = self.office_settings.office_address_street
        invoice.office_address_complement = self.office_settings.office_address_complement
        invoice.office_address_zipcode = self.office_settings.office_address_zipcode
        invoice.office_address_city = self.office_settings.office_address_city
        invoice.office_phone = self.office_settings.office_phone
        invoice.office_siret = self.office_settings.office_siret

        # Override the siret on the invoice with the therapeut siret if defined
        if self.therapeut_settings.siret is not None:
            invoice.office_siret = self.therapeut_settings.siret

        invoice.paiment_mode = serializer_data['paiment_mode']
        invoice.therapeut_name = user_therapeut.last_name
        invoice.therapeut_first_name = user_therapeut.first_name
        invoice.therapeut_id = user_therapeut.id
        invoice.quality = self.therapeut_settings.quality
        invoice.adeli = self.therapeut_settings.adeli
        invoice.location = self.office_settings.office_address_city

        invoice.patient_family_name = examination.patient.family_name
        invoice.patient_original_name = examination.patient.original_name
        invoice.patient_first_name = examination.patient.first_name
        invoice.patient_address_street = examination.patient.address_street
        invoice.patient_address_complement = examination.patient.address_complement
        invoice.patient_address_zipcode = examination.patient.address_zipcode
        invoice.patient_address_city = examination.patient.address_city
        invoice.content_invoice = self.office_settings.invoice_content
        invoice.footer = self.office_settings.invoice_footer

        # Override the footer on the invoice with the therapeut settings if defined
        if self.therapeut_settings.invoice_footer is not None:
            invoice.footer = self.therapeut_settings.invoice_footer
        invoice.number = self.get_invoice_number()
        invoice.date = timezone.now()
        invoice.officesettings_id = self.office_settings.id
        return invoice