|
@@ -2,7 +2,7 @@
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
import settings
|
|
|
-
|
|
|
+import datetime
|
|
|
import decimal
|
|
|
|
|
|
from himports.dolibarrAlchemy import *
|
|
@@ -78,7 +78,7 @@ class HledgerJournal(object):
|
|
|
by_year[entry_year] = []
|
|
|
by_year[entry_year].append(entry)
|
|
|
return by_year
|
|
|
-
|
|
|
+
|
|
|
def check_pc(self):
|
|
|
pc_missing = set()
|
|
|
for entry in self.get_entries():
|
|
@@ -90,16 +90,16 @@ class HledgerJournal(object):
|
|
|
class HledgerBankEntry(HledgerEntry):
|
|
|
sql_class = Bank
|
|
|
k_accounting_date = 'datev'
|
|
|
-
|
|
|
+
|
|
|
@classmethod
|
|
|
def get_third_code(cls, e):
|
|
|
third_code = ""
|
|
|
if e.url_payment_supplier:
|
|
|
if e.url_company:
|
|
|
third_code = e.url_company.societe.code_compta_fournisseur
|
|
|
-
|
|
|
+
|
|
|
if e.url_payment_sc:
|
|
|
- code = e.url_payment_sc.payment_sc.cotisation_sociale.type.code
|
|
|
+ code = e.url_payment_sc.payment_sc.cotisation_sociale.type.code
|
|
|
if code in settings.get('SOCIAL_REFS'):
|
|
|
third_code = settings.get('SOCIAL_REFS')[code]
|
|
|
|
|
@@ -110,7 +110,7 @@ class HledgerBankEntry(HledgerEntry):
|
|
|
if third_code == "":
|
|
|
fn = settings.get('PC_REFS')['fn_custom_code']
|
|
|
third_code = fn(e)
|
|
|
-
|
|
|
+
|
|
|
if third_code == "":
|
|
|
third_code = cls.pc_default_tiers
|
|
|
|
|
@@ -167,7 +167,7 @@ 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_paiement_amounts(f.facture, journal="bank")
|
|
@@ -234,7 +234,7 @@ class HledgerFactureEntry(HledgerEntry):
|
|
|
tvas[tva_account] = 0
|
|
|
tvas[tva_account] += -total_tva
|
|
|
tvas[tva_regul] += total_tva
|
|
|
-
|
|
|
+
|
|
|
elif journal == "sell" or journal == "supplier":
|
|
|
if ed.product_type == 1 and cls.tva_type == 'standard':
|
|
|
if tva_regul not in tvas:
|
|
@@ -246,11 +246,11 @@ class HledgerFactureEntry(HledgerEntry):
|
|
|
tvas[tva_account] += -total_tva
|
|
|
|
|
|
return tvas
|
|
|
-
|
|
|
+
|
|
|
@classmethod
|
|
|
def get_tva_regul_account(cls, ed):
|
|
|
tx = int(float(ed.tva_tx) * 100)
|
|
|
-
|
|
|
+
|
|
|
key = "tva_regul_%s" % (tx,)
|
|
|
|
|
|
return settings.get('PC_REFS')[key]
|
|
@@ -323,7 +323,7 @@ class HledgerSupplierEntry(HledgerFactureEntry):
|
|
|
'compte_produit': settings.get_ledger_account(p_code),
|
|
|
'amount_ht': self._value(-ed.total_ht)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
tvas = self.get_tva_facture_amounts(self.e, journal="supplier")
|
|
|
for k in tvas:
|
|
|
s += " %(compte_tva)s \t %(amount_tva)s\n" % {
|
|
@@ -332,12 +332,12 @@ class HledgerSupplierEntry(HledgerFactureEntry):
|
|
|
}
|
|
|
|
|
|
return s
|
|
|
-
|
|
|
+
|
|
|
@classmethod
|
|
|
def get_tva_account(cls, ed):
|
|
|
p_code = cls.get_product_account_code(ed)
|
|
|
tx = int(float(ed.tva_tx) * 100)
|
|
|
-
|
|
|
+
|
|
|
if p_code.startswith("2"):
|
|
|
prefix = 'tva_deductible'
|
|
|
else:
|
|
@@ -356,7 +356,7 @@ class HledgerSupplierEntry(HledgerFactureEntry):
|
|
|
else:
|
|
|
p_code = cls.pc_default_charge
|
|
|
return p_code
|
|
|
-
|
|
|
+
|
|
|
@classmethod
|
|
|
def get_supplier_code(cls, e):
|
|
|
s_code = e.societe.code_compta_fournisseur
|
|
@@ -387,7 +387,7 @@ class HledgerSellEntry(HledgerFactureEntry):
|
|
|
'amount_ttc': self._value(-e.total_ttc),
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
# lignes pour compte de produits
|
|
|
for ed in e.details:
|
|
|
p_code = self.get_product_account_code(ed)
|
|
@@ -405,7 +405,7 @@ class HledgerSellEntry(HledgerFactureEntry):
|
|
|
}
|
|
|
|
|
|
return s
|
|
|
-
|
|
|
+
|
|
|
@classmethod
|
|
|
def get_tva_account(cls, ed):
|
|
|
tx = int(float(ed.tva_tx) * 100)
|
|
@@ -468,7 +468,7 @@ class HledgerSellEntry(HledgerFactureEntry):
|
|
|
class HledgerSocialEntry(HledgerEntry):
|
|
|
sql_class = CotisationsSociales
|
|
|
k_accounting_date = 'date_ech'
|
|
|
-
|
|
|
+
|
|
|
@classmethod
|
|
|
def get_entries(cls, session):
|
|
|
return [cls(e) for e in session.query(cls.sql_class).order_by(CotisationsSociales.date_ech).all()]
|
|
@@ -490,7 +490,7 @@ class HledgerSocialEntry(HledgerEntry):
|
|
|
if s_code == "":
|
|
|
s_code = cls.pc_default_charge
|
|
|
return s_code
|
|
|
-
|
|
|
+
|
|
|
def getMissingPC(self):
|
|
|
pc_missing = []
|
|
|
if self.get_social_code(self.e) == self.pc_default_charge:
|
|
@@ -543,6 +543,3 @@ class HledgerDolibarrSQLAlchemy(DolibarrSQLAlchemy):
|
|
|
|
|
|
def get_social_journal(self):
|
|
|
return HledgerJournal(self.session, HledgerSocialEntry)
|
|
|
-
|
|
|
-
|
|
|
-
|