|
@@ -217,25 +217,25 @@ class HledgerBankEntry(HledgerEntry):
|
|
|
'account': settings.get_ledger_account(third_code),
|
|
|
'amount': self._value(e.amount)
|
|
|
}
|
|
|
-
|
|
|
- if e.url_payment_supplier:
|
|
|
- for f in e.url_payment_supplier.payment_supplier.factures:
|
|
|
- tvas = HledgerSupplierEntry.get_tva_payment_amounts(self.dolibarr_alchemy, f.facture, journal="bank")
|
|
|
- for k in tvas:
|
|
|
- s += " %(account_tva)s \t %(amount_tva)s\n" % {
|
|
|
- 'account_tva': settings.get_ledger_account(k),
|
|
|
- 'amount_tva': self._value(tvas[k] * (f.amount / f.facture.total_ttc))
|
|
|
- }
|
|
|
- elif e.url_payment:
|
|
|
- for f in e.url_payment.payment.factures:
|
|
|
- tvas = HledgerSellEntry.get_tva_payment_amounts(self.dolibarr_alchemy, f.facture, journal="bank")
|
|
|
- for k in tvas:
|
|
|
- s += " %(account_tva)s \t %(amount_tva)s\n" % {
|
|
|
- 'account_tva': settings.get_ledger_account(k),
|
|
|
- 'amount_tva': self._value(tvas[k] * (f.amount / f.facture.total_ttc))
|
|
|
- }
|
|
|
- else:
|
|
|
- pass
|
|
|
+ if self.tva_type != 'none':
|
|
|
+ if e.url_payment_supplier:
|
|
|
+ for f in e.url_payment_supplier.payment_supplier.factures:
|
|
|
+ tvas = HledgerSupplierEntry.get_tva_payment_amounts(self.dolibarr_alchemy, f.facture, journal="bank")
|
|
|
+ for k in tvas:
|
|
|
+ s += " %(account_tva)s \t %(amount_tva)s\n" % {
|
|
|
+ 'account_tva': settings.get_ledger_account(k),
|
|
|
+ 'amount_tva': self._value(tvas[k] * (f.amount / f.facture.total_ttc))
|
|
|
+ }
|
|
|
+ elif e.url_payment:
|
|
|
+ for f in e.url_payment.payment.factures:
|
|
|
+ tvas = HledgerSellEntry.get_tva_payment_amounts(self.dolibarr_alchemy, f.facture, journal="bank")
|
|
|
+ for k in tvas:
|
|
|
+ s += " %(account_tva)s \t %(amount_tva)s\n" % {
|
|
|
+ 'account_tva': settings.get_ledger_account(k),
|
|
|
+ 'amount_tva': self._value(tvas[k] * (f.amount / f.facture.total_ttc))
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ pass
|
|
|
|
|
|
return s
|
|
|
|
|
@@ -382,19 +382,30 @@ class HledgerSupplierEntry(HledgerBillingEntry):
|
|
|
'amount_ttc': self._value(e.total_ttc),
|
|
|
}
|
|
|
|
|
|
- for ed in e.details:
|
|
|
- p_code = self.get_product_account_code(ed)
|
|
|
- s += " %(compte_produit)s \t %(amount_ht)s\n" % {
|
|
|
- 'compte_produit': settings.get_ledger_account(p_code),
|
|
|
- 'amount_ht': self._value(-ed.total_ht)
|
|
|
- }
|
|
|
-
|
|
|
- tvas = self.get_tva_billing_amounts(self.dolibarr_alchemy, self.e, journal="supplier")
|
|
|
- for k in tvas:
|
|
|
- s += " %(compte_tva)s \t %(amount_tva)s\n" % {
|
|
|
- 'compte_tva': settings.get_ledger_account(k),
|
|
|
- 'amount_tva': self._value(tvas[k]),
|
|
|
- }
|
|
|
+ # lignes compte fournisseur
|
|
|
+ if self.tva_type == 'none':
|
|
|
+ for ed in e.details:
|
|
|
+ p_code = self.get_product_account_code(ed)
|
|
|
+ s += " %(compte_produit)s \t %(amount_ttc)s\n" % {
|
|
|
+ 'compte_produit': settings.get_ledger_account(p_code),
|
|
|
+ 'amount_ttc': self._value(-ed.total_ttc)
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ for ed in e.details:
|
|
|
+ p_code = self.get_product_account_code(ed)
|
|
|
+ s += " %(compte_produit)s \t %(amount_ht)s\n" % {
|
|
|
+ 'compte_produit': settings.get_ledger_account(p_code),
|
|
|
+ 'amount_ht': self._value(-ed.total_ht)
|
|
|
+ }
|
|
|
+
|
|
|
+ # value-added tax
|
|
|
+ if self.tva_type != 'none':
|
|
|
+ tvas = self.get_tva_billing_amounts(self.dolibarr_alchemy, self.e, journal="supplier")
|
|
|
+ for k in tvas:
|
|
|
+ s += " %(compte_tva)s \t %(amount_tva)s\n" % {
|
|
|
+ 'compte_tva': settings.get_ledger_account(k),
|
|
|
+ 'amount_tva': self._value(tvas[k]),
|
|
|
+ }
|
|
|
|
|
|
return s
|
|
|
|
|
@@ -469,20 +480,31 @@ class HledgerSellEntry(HledgerBillingEntry):
|
|
|
}
|
|
|
|
|
|
# lignes pour compte de produits
|
|
|
- for ed in e.details:
|
|
|
- p_code = self.get_product_account_code(ed)
|
|
|
- s += " %(compte_produit)s %(amount_ht)s\n" % {
|
|
|
- 'compte_produit': settings.get_ledger_account(p_code),
|
|
|
- 'amount_ht': self._value(ed.total_ht)
|
|
|
- }
|
|
|
+ if self.tva_type == 'none':
|
|
|
+ for ed in e.details:
|
|
|
+ p_code = self.get_product_account_code(ed)
|
|
|
+
|
|
|
+ s += " %(compte_produit)s %(amount_ttc)s\n" % {
|
|
|
+ 'compte_produit': settings.get_ledger_account(p_code),
|
|
|
+ 'amount_ttc': self._value(ed.total_ttc)
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ for ed in e.details:
|
|
|
+ p_code = self.get_product_account_code(ed)
|
|
|
+
|
|
|
+ s += " %(compte_produit)s %(amount_ht)s\n" % {
|
|
|
+ 'compte_produit': settings.get_ledger_account(p_code),
|
|
|
+ 'amount_ht': self._value(ed.total_ht)
|
|
|
+ }
|
|
|
|
|
|
# lignes pour la tva
|
|
|
- tvas = self.get_tva_billing_amounts(self.dolibarr_alchemy, self.e, journal="sell")
|
|
|
- for k in tvas:
|
|
|
- s += " %(compte_tva)s %(amount_tva)s\n" % {
|
|
|
- 'compte_tva': settings.get_ledger_account(k),
|
|
|
- 'amount_tva': self._value(tvas[k]),
|
|
|
- }
|
|
|
+ if self.tva_type != 'none':
|
|
|
+ tvas = self.get_tva_billing_amounts(self.dolibarr_alchemy, self.e, journal="sell")
|
|
|
+ for k in tvas:
|
|
|
+ s += " %(compte_tva)s %(amount_tva)s\n" % {
|
|
|
+ 'compte_tva': settings.get_ledger_account(k),
|
|
|
+ 'amount_tva': self._value(tvas[k]),
|
|
|
+ }
|
|
|
|
|
|
return s
|
|
|
|