Commit d47f1957 authored by plb's avatar plb
Browse files

clean the project

parent 49a19399
......@@ -5,17 +5,13 @@ from __future__ import unicode_literals
import getopt
import locale
import logging
import os
import shutil
import sys
import csv
import datetime
import codecs
import getpass
from himports import settings
from himports.hledger import *
from himports.dolibarrAlchemyHledger import *
from himports.dolibarrWriter import Writer
from himports.dolibarrAlchemyHledger import HledgerDolibarrSQLAlchemy
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('hreport')
......@@ -57,53 +53,6 @@ def process_args(argv):
return options
def do_mysql(options):
# On recupere les donnees via la base de donnees de dolibarr
s = settings.get('MYSQL_SETTINGS')
password = s['password']
if 'mysql_password' in options:
password = options['mysql_password']
if password is None or password == "":
password = getpass.getpass("password for mysql user '%s': " % (s['user']))
port = s['port']
if 'mysql_port' in options:
port = options['mysql_port']
if options['alchemy']:
dolibarr = HledgerDolibarrSQLAlchemy(s['host'], port, s['database'], s['user'], password)
dolibarr.connect()
else:
dolibarr = DolibarrSQL(s['host'], port, s['database'], s['user'], password)
dolibarr.connect()
bank_entries = dolibarr.get_bank_entries()
sell_entries = dolibarr.get_sell_entries()
supplier_entries = dolibarr.get_supplier_entries()
social_entries = dolibarr.get_social_entries()
dolibarr.disconnect()
# On verifie s'il manque des postes comptables dans les ecritures
pc_missing = set()
pc_missing.update(bank_entries.check_pc())
pc_missing.update(sell_entries.check_pc())
pc_missing.update(supplier_entries.check_pc())
pc_missing.update(social_entries.check_pc())
if len(pc_missing) > 0:
print "WARNING: poste comptable manquant"
for pc in pc_missing:
sys.stdout.write("%s\n" % (pc))
# On ecrie les fichiers hledger
Writer.write("bank",bank_entries)
Writer.write("sells",sell_entries)
Writer.write("suppliers",supplier_entries)
Writer.write("social",social_entries)
Writer.write_hreport_plan()
def do_sqlalchemy(options):
# On recupere les donnees via la base de donnees de dolibarr
s = settings.get('MYSQL_SETTINGS')
......@@ -121,18 +70,11 @@ def do_sqlalchemy(options):
dolibarr = HledgerDolibarrSQLAlchemy(s['host'], port, s['database'], s['user'], password, options['verbose'] >= 2)
dolibarr.connect()
if options['pdb']:
s = dolibarr.session
b = s.query(Bank).all()[10]
set_trace()
pass
bank_journal = dolibarr.get_bank_journal()
sell_journal = dolibarr.get_sell_journal()
supplier_journal = dolibarr.get_supplier_journal()
social_journal = dolibarr.get_social_journal()
# On verifie s'il manque des postes comptables dans les ecritures
pc_missing = set()
pc_missing.update(bank_journal.check_pc())
......@@ -143,7 +85,7 @@ def do_sqlalchemy(options):
print "WARNING: poste comptable manquant"
for pc in pc_missing:
sys.stdout.write("%s\n" % (pc))
# On ecrie les fichiers hledger
Writer.write("bank", bank_journal)
Writer.write("sells", sell_journal)
......@@ -154,15 +96,14 @@ def do_sqlalchemy(options):
dolibarr.disconnect()
def main(argv):
locale.setlocale(locale.LC_ALL, b'fr_FR.utf-8')
options = process_args(argv)
if options['alchemy']:
do_sqlalchemy(options)
else:
do_mysql(options)
raise Exception("Not implemented")
if __name__ == "__main__":
......
This diff is collapsed.
......@@ -55,4 +55,3 @@ if 'ACCOUNTING_YEARS' in __settings:
if 'TVA_TYPE' not in __settings or\
__settings['TVA_TYPE'] not in ["standard", "service_sur_debit"]:
raise Exception("need TVA_TYPE settings either: standard | service_sur_debit")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment