Sync Indy integre dans l'interface web + anti-doublon

This commit is contained in:
2026-06-30 14:08:35 +02:00
parent 458f80f201
commit 75af558b49
13 changed files with 665 additions and 48 deletions
+6 -1
View File
@@ -88,6 +88,9 @@ class Entreprise(models.Model):
num_tva_intracom = models.CharField("N° TVA intracommunautaire", max_length=20, blank=True)
vue_tva = models.CharField(
"Mode d'affichage de la déclaration TVA", max_length=10, choices=VUE_TVA, default="simplifie")
indy_token = models.TextField(
"Token Indy (API)", blank=True,
help_text="Token JWT capté dans le navigateur, pour la synchronisation. Expire ~1 h.")
utilisateurs = models.ManyToManyField(
settings.AUTH_USER_MODEL, blank=True, related_name="entreprises",
verbose_name="Utilisateurs autorisés",
@@ -151,6 +154,7 @@ class Facture(models.Model):
montant_tva = models.DecimalField(max_digits=12, decimal_places=2, default=Decimal("0"))
montant_ttc = models.DecimalField(max_digits=12, decimal_places=2, default=Decimal("0"))
notes = models.TextField(blank=True)
indy_id = models.CharField(max_length=40, blank=True, db_index=True)
cree_le = models.DateTimeField(auto_now_add=True)
class Meta:
@@ -207,6 +211,7 @@ class Paiement(models.Model):
categorie = models.ForeignKey(Categorie, on_delete=models.SET_NULL, null=True, blank=True,
related_name="paiements",
help_text="Surtout pour les mouvements neutres.")
indy_id = models.CharField(max_length=40, blank=True, db_index=True)
cree_le = models.DateTimeField(auto_now_add=True)
class Meta:
@@ -255,6 +260,7 @@ class Depense(models.Model):
"Taux de TVA (%)", max_digits=4, decimal_places=2, default=Decimal("20"),
choices=TAUX_TVA_CHOICES,
help_text="Achat national : la TVA déductible est calculée. UE/import : taux auto-liquidé.")
indy_id = models.CharField(max_length=40, blank=True, db_index=True)
cree_le = models.DateTimeField(auto_now_add=True)
class Meta:
@@ -266,7 +272,6 @@ class Depense(models.Model):
return f"{self.date}{self.libelle}"
def save(self, *args, **kwargs):
# TVA déductible calculée : incluse dans le TTC (national), nulle en autoliq.
t = self.taux_tva or Decimal("0")
if self.autoliquidee:
self.montant_tva = Decimal("0.00")