Cards for all treasury

This commit is contained in:
Alexandre Iooss 2020-08-25 18:10:21 +02:00
parent 5ba18a2d89
commit bca301700d
8 changed files with 298 additions and 222 deletions

View File

@ -3,7 +3,7 @@
{% load crispy_forms_tags %}
{% block content %}
<div class="card bg-light shadow">
<div class="card bg-light">
<div class="card-header text-center">
<h4>{% trans "Delete invoice" %}</h4>
</div>

View File

@ -1,44 +1,55 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block content %}
<p><a class="btn btn-default" href="{% url 'treasury:invoice_list' %}">{% trans "Invoices list" %}</a></p>
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n crispy_forms_tags %}
{% block contenttitle %}{% endblock %}
{% if object.pk and not object.locked %}
{% block content %}
<div class="card bg-white mb-3">
<h3 class="card-header text-center">
{{ title }}
</h3>
<div class="card-body">
{% if object.pk and not object.locked %}
<div class="alert alert-info">
{% blocktrans trimmed %}
Warning: the LaTeX template is saved with this object. Updating the invoice implies regenerate it.
Be careful if you manipulate old invoices.
Warning: the LaTeX template is saved with this object. Updating the invoice implies regenerate it.
Be careful if you manipulate old invoices.
{% endblocktrans %}
</div>
{% elif object.locked %}
{% elif object.locked %}
<div class="alert alert-info">
{% blocktrans trimmed %}
This invoice is locked and can no longer be edited.
This invoice is locked and can no longer be edited.
{% endblocktrans %}
</div>
{% endif %}
{% endif %}
</div>
<form method="post" action="">
{% csrf_token %}
{# Render the invoice form #}
{% crispy form %}
<div class="card-body">
{% crispy form %}
</div>
{# The next part concerns the product formset #}
{# Generate some hidden fields that manage the number of products, and make easier the parsing #}
{{ formset.management_form }}
<table class="table table-condensed table-striped">
{# Fill initial data #}
{% for form in formset %}
{% if forloop.first %}
<thead>
<tr>
<th>{{ form.designation.label }}<span class="asteriskField">*</span></th>
<th>{{ form.quantity.label }}<span class="asteriskField">*</span></th>
<th>{{ form.amount.label }}<span class="asteriskField">*</span></th>
</tr>
</thead>
<tbody id="form_body">
{% if forloop.first %}
<thead>
<tr>
<th>{{ form.designation.label }}<span class="asteriskField">*</span></th>
<th>{{ form.quantity.label }}<span class="asteriskField">*</span></th>
<th>{{ form.amount.label }}<span class="asteriskField">*</span></th>
</tr>
</thead>
<tbody id="form_body">
{% endif %}
<tr class="row-formset">
<td>{{ form.designation }}</td>
@ -48,27 +59,28 @@
{{ form.invoice }}
{{ form.id }}
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
{# Display buttons to add and remove products #}
{% if not object.locked %}
<div class="card-body">
{% if not object.locked %}
<div class="btn-group btn-block" role="group">
<button type="button" id="add_more" class="btn btn-primary">{% trans "Add product" %}</button>
<button type="button" id="add_more" class="btn btn-success">{% trans "Add product" %}</button>
<button type="button" id="remove_one" class="btn btn-danger">{% trans "Remove product" %}</button>
</div>
{% endif %}
{% endif %}
<div class="btn-block">
<button type="submit" class="btn btn-block btn-primary">{% trans "Submit" %}</button>
</div>
</form>
</div>
<div id="empty_form" style="display: none;">
{# Hidden div that store an empty product form, to be copied into new forms #}
<table class='no_error'>
<tbody id="for_real">
{# Hidden div that store an empty product form, to be copied into new forms #}
<div id="empty_form" style="display: none;">
<table class='no_error'>
<tbody id="for_real">
<tr class="row-formset">
<td>{{ formset.empty_form.designation }}</td>
<td>{{ formset.empty_form.quantity }} </td>
@ -76,32 +88,32 @@
{{ formset.empty_form.invoice }}
{{ formset.empty_form.id }}
</tr>
</tbody>
</table>
</div>
</tbody>
</table>
</div>
{% endblock %}
{% block extrajavascript %}
<script>
{# Script that handles add and remove lines #}
IDS = {};
<script>
/* script that handles add and remove lines */
IDS = {};
$("#id_products-TOTAL_FORMS").val($(".row-formset").length - 1);
$("#id_products-TOTAL_FORMS").val($(".row-formset").length - 1);
$('#add_more').click(function () {
let form_idx = $('#id_products-TOTAL_FORMS').val();
$('#form_body').append($('#for_real').html().replace(/__prefix__/g, form_idx));
$('#id_products-TOTAL_FORMS').val(parseInt(form_idx) + 1);
$('#id_products-' + parseInt(form_idx) + '-id').val(IDS[parseInt(form_idx)]);
});
$('#add_more').click(function () {
let form_idx = $('#id_products-TOTAL_FORMS').val();
$('#form_body').append($('#for_real').html().replace(/__prefix__/g, form_idx));
$('#id_products-TOTAL_FORMS').val(parseInt(form_idx) + 1);
$('#id_products-' + parseInt(form_idx) + '-id').val(IDS[parseInt(form_idx)]);
});
$('#remove_one').click(function () {
let form_idx = $('#id_products-TOTAL_FORMS').val();
if (form_idx > 0) {
IDS[parseInt(form_idx) - 1] = $('#id_products-' + (parseInt(form_idx) - 1) + '-id').val();
$('#form_body tr:last-child').remove();
$('#id_products-TOTAL_FORMS').val(parseInt(form_idx) - 1);
}
});
</script>
$('#remove_one').click(function () {
let form_idx = $('#id_products-TOTAL_FORMS').val();
if (form_idx > 0) {
IDS[parseInt(form_idx) - 1] = $('#id_products-' + (parseInt(form_idx) - 1) + '-id').val();
$('#form_body tr:last-child').remove();
$('#id_products-TOTAL_FORMS').val(parseInt(form_idx) - 1);
}
});
</script>
{% endblock %}

View File

@ -1,26 +1,35 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% block content %}
{% block contenttitle %}{% endblock %}
<div class="row">
<div class="col-xl-12">
<div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0" data-toggle="buttons">
<a href="#" class="btn btn-sm btn-outline-primary active">
{% trans "Invoice" %}s
</a>
<a href="{% url "treasury:remittance_list" %}" class="btn btn-sm btn-outline-primary">
{% trans "Remittance" %}s
</a>
<a href="{% url "treasury:soge_credits" %}" class="btn btn-sm btn-outline-primary">
{% trans "Société générale credits" %}
</a>
</div>
{% block content %}
<div class="row">
<div class="col-xl-12">
<div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0" data-toggle="buttons">
<a href="#" class="btn btn-sm btn-outline-primary active">
{% trans "Invoice" %}s
</a>
<a href="{% url "treasury:remittance_list" %}" class="btn btn-sm btn-outline-primary">
{% trans "Remittance" %}s
</a>
<a href="{% url "treasury:soge_credits" %}" class="btn btn-sm btn-outline-primary">
{% trans "Société générale credits" %}
</a>
</div>
</div>
</div>
{% render_table table %}
<a class="btn btn-primary" href="{% url 'treasury:invoice_create' %}">{% trans "New invoice" %}</a>
<div class="card bg-white mb-3">
<h3 class="card-header text-center">
{{ title }}
</h3>
{% render_table table %}
<div class="card-footer">
<a class="btn btn-sm btn-success" href="{% url 'treasury:invoice_create' %}">{% trans "New invoice" %}</a>
</div>
</div>
{% endblock %}

View File

@ -1,37 +1,47 @@
{% extends "base.html" %}
{% load static %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% load crispy_forms_tags pretty_money %}
{% load render_table from django_tables2 %}
{% block content %}
<h1>{% trans "Remittance #" %}{{ object.pk }}</h1>
<p><a class="btn btn-default" href="{% url 'treasury:remittance_list' %}">{% trans "Remittances list" %}</a></p>
{% if object.pk %}
<div id="div_id_type" class="form-group"><label for="id_count" class="col-form-label">{% trans "Count" %}</label>
<div class="">
<input type="text" name="count" value="{{ object.count }}" class="textinput textInput form-control" id="id_count" disabled>
</div>
<div class="card bg-white mb-3">
<h3 class="card-header text-center">
{% trans "Remittance #" %}{{ object.pk }}
</h3>
<div class="card-body">
{% if object.pk %}
<div id="div_id_type">
<label for="id_count" class="col-form-label">{% trans "Count" %}</label>
<input type="text" name="count" value="{{ object.count }}" class="textinput textInput form-control"
id="id_count" disabled>
</div>
<div id="div_id_type" class="form-group"><label for="id_amount" class="col-form-label">{% trans "Amount" %}</label>
<div class="">
<input class="textinput textInput form-control" type="text" value="{{ object.amount|pretty_money }}" id="id_amount" disabled>
</div>
<div id="div_id_type">
<label for="id_amount" class="col-form-label">{% trans "Amount" %}</label>
<input class="textinput textInput form-control" type="text" value="{{ object.amount|pretty_money }}"
id="id_amount" disabled>
</div>
{% endif %}
{% endif %}
{% crispy form %}
{% crispy form %}
</div>
</div>
<hr>
<h2>{% trans "Linked transactions" %}</h2>
<div class="card bg-white mb-3">
<h3 class="card-header text-center">
{% trans "Linked transactions" %}
</h3>
{% if special_transactions.data %}
{% render_table special_transactions %}
{% render_table special_transactions %}
{% else %}
<div class="card-body">
<div class="alert alert-warning">
{% trans "There is no transaction linked with this remittance." %}
</div>
</div>
{% endif %}
</div>
{% endblock %}

View File

@ -1,65 +1,88 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% block content %}
{% block contenttitle %}{% endblock %}
<div class="row">
<div class="col-xl-12">
<div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0" data-toggle="buttons">
<a href="{% url "treasury:invoice_list" %}" class="btn btn-sm btn-outline-primary">
{% trans "Invoice" %}s
</a>
<a href="#" class="btn btn-sm btn-outline-primary active">
{% trans "Remittance" %}s
</a>
<a href="{% url "treasury:soge_credits" %}" class="btn btn-sm btn-outline-primary">
{% trans "Société générale credits" %}
</a>
</div>
{% block content %}
<div class="row">
<div class="col-xl-12">
<div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0" data-toggle="buttons">
<a href="{% url "treasury:invoice_list" %}" class="btn btn-sm btn-outline-primary">
{% trans "Invoice" %}s
</a>
<a href="#" class="btn btn-sm btn-outline-primary active">
{% trans "Remittance" %}s
</a>
<a href="{% url "treasury:soge_credits" %}" class="btn btn-sm btn-outline-primary">
{% trans "Société générale credits" %}
</a>
</div>
</div>
</div>
<h2>{% trans "Opened remittances" %}</h2>
<div class="card bg-white mb-3">
<h3 class="card-header text-center">
{% trans "Opened remittances" %}
</h3>
{% if opened_remittances.data %}
{% render_table opened_remittances %}
{% render_table opened_remittances %}
{% else %}
<div class="card-body">
<div class="alert alert-warning">
{% trans "There is no opened remittance." %}
</div>
</div>
{% endif %}
<div class="card-footer">
<a class="btn btn-sm btn-success" href="{% url 'treasury:remittance_create' %}">{% trans "New remittance" %}</a>
</div>
</div>
<a class="btn btn-primary" href="{% url 'treasury:remittance_create' %}">{% trans "New remittance" %}</a>
<hr>
<h2>{% trans "Transfers without remittances" %}</h2>
<div class="card bg-white mb-3">
<h3 class="card-header text-center">
{% trans "Transfers without remittances" %}
</h3>
{% if special_transactions_no_remittance.data %}
{% render_table special_transactions_no_remittance %}
{% render_table special_transactions_no_remittance %}
{% else %}
<div class="card-body">
<div class="alert alert-warning">
{% trans "There is no transaction without any linked remittance." %}
</div>
</div>
{% endif %}
</div>
<hr>
<h2>{% trans "Transfers with opened remittances" %}</h2>
<div class="card bg-white mb-3">
<h3 class="card-header text-center">
{% trans "Transfers with opened remittances" %}
</h3>
{% if special_transactions_with_remittance.data %}
{% render_table special_transactions_with_remittance %}
{% render_table special_transactions_with_remittance %}
{% else %}
<div class="card-body">
<div class="alert alert-warning">
{% trans "There is no transaction with an opened linked remittance." %}
</div>
</div>
{% endif %}
</div>
<hr>
<h2>{% trans "Closed remittances" %}</h2>
<div class="card bg-white mb-3">
<h3 class="card-header text-center">
{% trans "Closed remittances" %}
</h3>
{% if closed_remittances.data %}
{% render_table closed_remittances %}
{% render_table closed_remittances %}
{% else %}
<div class="card-body">
<div class="alert alert-warning">
{% trans "There is no closed remittance yet." %}
</div>
</div>
{% endif %}
</div>
{% endblock %}

View File

@ -1,67 +1,69 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% load pretty_money %}
{% load perms %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n pretty_money perms %}
{% block contenttitle %}{% endblock %}
{% block content %}
<div class="card bg-light shadow">
<div class="card-header text-center">
<h4>{% trans "Credit from the Société générale" %}</h4>
</div>
<div class="card-body">
<dl class="row">
<dt class="col-xl-6 text-right">{% trans 'user'|capfirst %}</dt>
<dd class="col-xl-6"><a href="{% url 'member:user_detail' pk=object.user.pk %}">{{ object.user }}</a></dd>
{% if "note.view_note_balance"|has_perm:object.user.note %}
<dt class="col-xl-6 text-right">{% trans 'balance'|capfirst %}</dt>
<dd class="col-xl-6">{{ object.user.note.balance|pretty_money }}</dd>
{% endif %}
<dt class="col-xl-6 text-right">{% trans 'transactions'|capfirst %}</dt>
<dd class="col-xl-6">
{% for transaction in object.transactions.all %}
{{ transaction.membership.club }} ({{ transaction.amount|pretty_money }})<br>
{% endfor %}
</dd>
<dt class="col-xl-6 text-right">{% trans 'total amount'|capfirst %}</dt>
<dd class="col-xl-6">{{ object.amount|pretty_money }}</dd>
</dl>
</div>
<div class="alert alert-warning">
{% trans 'Warning: Validating this credit implies that all membership transactions will be validated.' %}
{% trans 'If you delete this credit, there all membership transactions will be also validated, but no credit will be operated.' %}
{% trans "If this credit is validated, then the user won't be able to ask for a credit from the Société générale." %}
{% trans 'If you think there is an error, please contact the "respos info".' %}
</div>
<div class="card-footer text-center" id="buttons_footer">
{% if object.valid %}
<div class="alert alert-danger">
{% trans "This credit is already validated." %}
</div>
{% else %}
{% if object.user.note.balance < object.amount %}
<div class="alert alert-warning">
{% trans "Warning: if you don't validate this credit, the note of the user doesn't have enough money to pay its memberships." %}
{% trans "Please ask the user to credit its note before deleting this credit." %}
</div>
{% endif %}
<form method="post">
{% csrf_token %}
<div class="btn-group btn-block">
<button name="validate" class="btn btn-success">{% trans "Validate" %}</button>
{% if object.user.note.balance >= object.amount %}
<button name="delete" class="btn btn-danger">{% trans "Delete" %}</button>
{% endif %}
</div>
</form>
{% endif %}
<a href="{% url 'treasury:soge_credits' %}"><button class="btn btn-primary btn-block">{% trans "Return to credit list" %}</button></a>
</div>
<div class="card bg-light">
<div class="card-header text-center">
<h4>{% trans "Credit from the Société générale" %}</h4>
</div>
<div class="card-body">
<dl class="row">
<dt class="col-xl-6 text-right">{% trans 'user'|capfirst %}</dt>
<dd class="col-xl-6"><a href="{% url 'member:user_detail' pk=object.user.pk %}">{{ object.user }}</a></dd>
{% if "note.view_note_balance"|has_perm:object.user.note %}
<dt class="col-xl-6 text-right">{% trans 'balance'|capfirst %}</dt>
<dd class="col-xl-6">{{ object.user.note.balance|pretty_money }}</dd>
{% endif %}
<dt class="col-xl-6 text-right">{% trans 'transactions'|capfirst %}</dt>
<dd class="col-xl-6">
{% for transaction in object.transactions.all %}
{{ transaction.membership.club }} ({{ transaction.amount|pretty_money }})<br>
{% endfor %}
</dd>
<dt class="col-xl-6 text-right">{% trans 'total amount'|capfirst %}</dt>
<dd class="col-xl-6">{{ object.amount|pretty_money }}</dd>
</dl>
</div>
<div class="alert alert-warning">
{% trans 'Warning: Validating this credit implies that all membership transactions will be validated.' %}
{% trans 'If you delete this credit, there all membership transactions will be also validated, but no credit will be operated.' %}
{% trans "If this credit is validated, then the user won't be able to ask for a credit from the Société générale." %}
{% trans 'If you think there is an error, please contact the "respos info".' %}
</div>
<div class="card-footer text-center" id="buttons_footer">
{% if object.valid %}
<div class="alert alert-danger">
{% trans "This credit is already validated." %}
</div>
{% else %}
{% if object.user.note.balance < object.amount %}
<div class="alert alert-warning">
{% trans "Warning: if you don't validate this credit, the note of the user doesn't have enough money to pay its memberships." %}
{% trans "Please ask the user to credit its note before deleting this credit." %}
</div>
{% endif %}
<form method="post">
{% csrf_token %}
<div class="btn-group btn-block">
<button name="validate" class="btn btn-success">{% trans "Validate" %}</button>
{% if object.user.note.balance >= object.amount %}
<button name="delete" class="btn btn-danger">{% trans "Delete" %}</button>
{% endif %}
</div>
</form>
{% endif %}
<a href="{% url 'treasury:soge_credits' %}"><button
class="btn btn-primary btn-block">{% trans "Return to credit list" %}</button></a>
</div>
</div>
{% endblock %}

View File

@ -1,47 +1,58 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% block content %}
{% block contenttitle %}{% endblock %}
<div class="row">
<div class="col-xl-12">
<div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0" data-toggle="buttons">
<a href="{% url "treasury:invoice_list" %}" class="btn btn-sm btn-outline-primary">
{% trans "Invoice" %}s
</a>
<a href="{% url "treasury:remittance_list" %}" class="btn btn-sm btn-outline-primary">
{% trans "Remittance" %}s
</a>
<a href="#" class="btn btn-sm btn-outline-primary active">
{% trans "Société générale credits" %}
</a>
</div>
{% block content %}
<div class="row">
<div class="col-xl-12">
<div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0" data-toggle="buttons">
<a href="{% url "treasury:invoice_list" %}" class="btn btn-sm btn-outline-primary">
{% trans "Invoice" %}s
</a>
<a href="{% url "treasury:remittance_list" %}" class="btn btn-sm btn-outline-primary">
{% trans "Remittance" %}s
</a>
<a href="#" class="btn btn-sm btn-outline-primary active">
{% trans "Société générale credits" %}
</a>
</div>
</div>
</div>
<input id="searchbar" type="text" class="form-control" placeholder="Nom/prénom/note ...">
<div class="form-check">
<label for="invalid_only" class="form-check-label">
<input id="invalid_only" name="invalid_only" type="checkbox" class="checkboxinput form-check-input">
{% trans "Filter with unvalidated credits only" %}
</label>
<div class="card bg-white mb-3">
<h3 class="card-header text-center">
{{ title }}
</h3>
<div class="card-body">
<input id="searchbar" type="text" class="form-control" placeholder="Nom/prénom/note ...">
<div class="form-check">
<label for="invalid_only" class="form-check-label">
<input id="invalid_only" name="invalid_only" type="checkbox" class="checkboxinput form-check-input">
{% trans "Filter with unvalidated credits only" %}
</label>
</div>
</div>
<hr>
<div id="credits_table">
{% if table.data %}
{% render_table table %}
{% render_table table %}
{% else %}
<div class="card-body">
<div class="alert alert-warning">
{% trans "There is no matched user that have asked for a Société générale credit." %}
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}
{% block extrajavascript %}
<script type="text/javascript">
$(document).ready(function() {
$(document).ready(function () {
let old_pattern = null;
let searchbar_obj = $("#searchbar");
let invalid_only_obj = $("#invalid_only");
@ -52,9 +63,10 @@
if (pattern === old_pattern || pattern === "")
return;
$("#credits_table").load(location.pathname + "?search=" + pattern.replace(" ", "%20") + (invalid_only_obj.is(':checked') ? "&valid=false" : "") + " #credits_table");
$("#credits_table").load(location.pathname + "?search=" + pattern.replace(" ", "%20") + (
invalid_only_obj.is(':checked') ? "&valid=false" : "") + " #credits_table");
$(".table-row").click(function() {
$(".table-row").click(function () {
window.document.location = $(this).data("href");
});
}

View File

@ -1,9 +1,17 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% load crispy_forms_tags pretty_money %}
{% load render_table from django_tables2 %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load crispy_forms_tags %}
{% block contenttitle %}{% endblock %}
{% block content %}
<p><a class="btn btn-default" href="{% url 'treasury:remittance_list' %}">{% trans "Remittances list" %}</a></p>
{% crispy form %}
<div class="card bg-white mb-3">
<h3 class="card-header text-center">
{{ title }}
</h3>
<div class="card-body">
{% crispy form %}
</div>
</div>
{% endblock %}