Coverage for apps/invoices/signals.py: 60%
18 statements
« prev ^ index » next coverage.py v6.4.4, created at 2024-05-23 06:56 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2024-05-23 06:56 -0600
1from django.db.models import signals
2from django.dispatch import receiver
4from .models import PractitionerInvoiceConfiguration
5from .utils import remove_social_regime_from_business_name
10@receiver(signals.post_save, sender=PractitionerInvoiceConfiguration)
11def create_facturapi_organization(sender, instance: PractitionerInvoiceConfiguration, created, *args, **kwargs):
12 if created:
13 instance.set_facturapi_organization_id()
14 instance.set_facturapi_secret_key()
17@receiver(signals.pre_save, sender=PractitionerInvoiceConfiguration)
18def set_legal_name(sender, instance, *args, **kwargs):
19 instance.legal_name = remove_social_regime_from_business_name(instance.legal_name)
22@receiver(signals.post_save, sender=PractitionerInvoiceConfiguration)
23def update_facturapi_organization_fiscal_data(
24 sender, instance: PractitionerInvoiceConfiguration, created, *args, **kwargs
25):
26 instance.update_facturapi_organization_fiscal_data()
29@receiver(signals.post_delete, sender=PractitionerInvoiceConfiguration)
30def delete_facturapi_organization(sender, instance: PractitionerInvoiceConfiguration, *args, **kwargs):
31 instance.delete_facturapi_organization()