Add buttons

This commit is contained in:
Gregory Trullemans 2022-05-10 10:56:25 +02:00
parent 0c0bda5014
commit 3a939eca76
7 changed files with 17 additions and 89 deletions

View File

@ -132,6 +132,10 @@ USE_L10N = True
USE_TZ = True
LOGIN_URL = "/login/"
LOGOUT_URL = "/logout/"
# USE_THOUSAND_SEPARATOR = True
# THOUSAND_SEPARATOR = '.'

View File

@ -79,81 +79,6 @@ class MyDialect(csv.Dialect):
lineterminator = "\n"
# class KeytradeForm(TransactionForm):
# def __init__(self, item):
# current_dict = {
# 'registrationDate': datetime.datetime.strptime(row.get('Date'), '%d.%m.%Y'),
# 'totalAmount': float(row.get('Montant')),
# 'bkAmount': float(row.get('Montant')),
# 'amount': float(row.get('Montant')),
# 'transaction_type': 5,
# 'description': row.get('Description'),
# 'is_done': True,
# 'is_simulated': False,
# 'counterpart': row.get('Compte'),
# 'bxAmount': 0,
# 'otherDescription': row.get('Description'),
# 'account_number': row.get('Compte'),
# 'notes': row.get('Description'),
# }
# # Par défaut on considère que le montant est positif et
# # est donc une recette. Il faut donc corrigé si nécessaire.
# # id "Autre dépense" = 4 | id "Autre recette" = 5
# word = "cotisation"
# if current_dict['totalAmount'] < 0:
# current_dict['transaction_type'] = 4
# current_dict['totalAmount'] = math.fabs(current_dict['totalAmount'])
# current_dict['bkAmount'] = current_dict['totalAmount']
# current_dict['amount'] = current_dict['totalAmount']
# elif word in current_dict['description'].lower():
# current_dict['transaction_type'] = 6
# if current_dict['counterpart'] == "-":
# current_dict['counterpart'] = 'KEYTRADE'
# current_dict['transaction_type'] = 3
# super().init(current_dict)
# class CrelanForm(TransactionForm):
# def __init__(self, item):
# current_dict = {
# 'registrationDate': datetime.datetime.strptime(row.get('Date'), '%d/%m/%Y'),
# 'totalAmount': float(row.get('Montant')),
# 'bkAmount': float(row.get('Montant')),
# 'amount': float(row.get('Montant')),
# 'transaction_type': 5,
# 'description': row.get('Communication'),
# 'is_done': True,
# 'is_simulated': False,
# 'counterpart': row.get('Contrepartie'),
# 'bxAmount': 0,
# 'otherDescription': row.get("Type d'opération"),
# 'account_number': row.get('Compte contrepartie'),
# }
# # Par défaut on considère que le montant est positif et
# # est donc une recette. Il faut donc corrigé si nécessaire.
# # id "Autre dépense" = 4 | id "Autre recette" = 5
# word = "cotisation"
# if current_dict['totalAmount'] < 0:
# current_dict['transaction_type'] = 4
# current_dict['totalAmount'] = math.fabs(current_dict['totalAmount'])
# current_dict['bkAmount'] = current_dict['totalAmount']
# current_dict['amount'] = current_dict['totalAmount']
# elif word in current_dict['description'].lower():
# current_dict['transaction_type'] = 6
# if not current_dict['counterpart'] and not current_dict['description']:
# current_dict['counterpart'] = 'CRELAN'
# current_dict['description'] = row.get("Type d'opération")
# current_dict['transaction_type'] = 3
# current_dict['notes'] = current_dict['description']
# super().init(current_dict)
def import_csv_transaction(file, bank):
"""
Lit un fichier CSV exporté d'un compte et ajoute les lignes
@ -174,7 +99,9 @@ def import_csv_transaction(file, bank):
records_added = 0
reader = csv.DictReader(csvfile, dialect=MyDialect())
line_number = 0
for row in reader:
line_number += 1
if bank == "crelan":
myDict = map_crelan_dict(row)
else:
@ -186,13 +113,10 @@ def import_csv_transaction(file, bank):
form.save()
records_added += 1
else:
print("Ligne en erreur…")
for key, value in form.errors.items():
print(key, "->", value)
print("Ligne " + str(line_number) + " en erreur.")
print(form.errors)
errors.append(form.errors)
return records_added, errors
return records_added
def get_key(current_dict, key, cast_type=None):

View File

@ -53,11 +53,9 @@ class Command(BaseCommand):
# records_added += 1
if options["bank"] == "crelan" or options["bank"] == "keytrade":
records_added, error_list = import_csv_transaction(
records_added = import_csv_transaction(
options["file"], options["bank"]
)
print("%s transactions ont été importées" % records_added)
for error in error_list:
print(error)
else:
print("Format non supporté…")

View File

@ -18,7 +18,7 @@
<table class="table-condensed">
<tr>
<td class="col-xs-6 col-sm-4 col-md-4 col-lg-4"><p class="text-muted">Date</p></td>
<td class="col-xs-6 col-sm-8 col-md-8 col-lg-8"><p class="text-primary">{{ transaction.registrationDate | date:'l j F Y' }}</p></td>
<td class="col-xs-6 col-sm-8 col-md-8 col-lg-8"><p class="text-primary"><a href="{% url 'by_year' 2022 %}">{{ transaction.registrationDate | date:'l j F Y' }}</a></p></td>
</tr>
<tr>
<td><p class="text-muted">Type de transaction</p></td>

View File

@ -23,7 +23,7 @@
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th class="centered">ID</th>
<!-- <th class="centered">ID</th> -->
<th class="centered">Date</th>
<th>Description</th>
<th class="centered">Montant</th>
@ -32,7 +32,7 @@
</thead>
{% for transaction in transaction_list %}
<tr {% if transaction.0.is_done == False %}class="alert alert-danger"{% elif transaction.0.is_simulated == True %}class="alert alert-warning simulated"{% endif %}>
<td class="centered">{{ transaction.0.id }}</td>
<!-- <td class="centered">{{ transaction.0.id }}</td> -->
<td class="push-right">{{ transaction.0.registrationDate | date:"j M" }}</td>
<td><a href="{% url 'transaction_details' transaction.0.id %}">{{ transaction.0.description }}</a></td>
{% if transaction.0.transaction_type.transaction_type == 0 %}

View File

@ -155,7 +155,7 @@
</div>
<div class="row">
<div class="span12">
<p class="right"><a href="{% url 'pdf_export' accounting_year %}" class="btn btn-default btn-primary" role="button">Comptes PDF</a></p>
<p class="right"><a href="{% url 'pdf_export' accounting_year %}" class="btn btn-default btn-primary" role="button">Export PDF</a></p>
</div>
</div>
</div>

View File

@ -101,7 +101,9 @@
</tfoot>
</table>
<br>
<p align="center" class="noprint"><a href="{% url 'by_year' accounting_year %}">Listing</a> | <a href="{% url 'export' accounting_year 'ooo' %}">Affichage 2 tableaux</a> | <a href="{% url 'export_simple' accounting_year %}">Affichage 1 tableaux simplifié</a></p>
<p align="center" class="noprint">
<a href="{% url 'by_year' accounting_year %}"><button type="button" class="btn btn-primary">Listing</button></a>&nbsp;&nbsp;&nbsp;<a href="{% url 'export' accounting_year 'ooo' %}"><button type="button" class="btn btn-primary">2 tableaux</button></a>&nbsp;&nbsp;&nbsp;<a href="{% url 'export_simple' accounting_year %}"><button type="button" class="btn btn-primary">Export SPF</button></a>
</p>
<br>
</div>
</div>