Renamed the credit_amount attribute to credit and debit_summary to debit in RecordSummary in the accounting application.
This commit is contained in:
parent
a15a359ca7
commit
753e69d4e9
@ -322,8 +322,8 @@ class Record(models.Model):
|
|||||||
class RecordSummary(models.Model):
|
class RecordSummary(models.Model):
|
||||||
"""A summary record."""
|
"""A summary record."""
|
||||||
month = models.DateField(primary_key=True)
|
month = models.DateField(primary_key=True)
|
||||||
credit_amount = models.PositiveIntegerField()
|
credit = models.PositiveIntegerField()
|
||||||
debit_amount = models.PositiveIntegerField()
|
debit = models.PositiveIntegerField()
|
||||||
balance = models.IntegerField()
|
balance = models.IntegerField()
|
||||||
|
|
||||||
_label = None
|
_label = None
|
||||||
|
@ -102,8 +102,8 @@ First written: 2020/7/15
|
|||||||
{% for record in records %}
|
{% for record in records %}
|
||||||
<tr class="{% if record.balance < 0 %} table-danger {% endif %}">
|
<tr class="{% if record.balance < 0 %} table-danger {% endif %}">
|
||||||
<td>{{ record.label }}</td>
|
<td>{{ record.label }}</td>
|
||||||
<td class="amount">{{ record.credit_amount|accounting_amount }}</td>
|
<td class="amount">{{ record.credit|accounting_amount }}</td>
|
||||||
<td class="amount">{{ record.debit_amount|accounting_amount }}</td>
|
<td class="amount">{{ record.debit|accounting_amount }}</td>
|
||||||
<td class="amount {% if record.balance < 0 %} text-danger {% endif %}">{{ record.balance|accounting_amount }}</td>
|
<td class="amount {% if record.balance < 0 %} text-danger {% endif %}">{{ record.balance|accounting_amount }}</td>
|
||||||
<td class="amount {% if record.cumulative_balance < 0 %} text-danger {% endif %}">{{ record.cumulative_balance|accounting_amount }}</td>
|
<td class="amount {% if record.cumulative_balance < 0 %} text-danger {% endif %}">{{ record.cumulative_balance|accounting_amount }}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
@ -128,10 +128,10 @@ First written: 2020/7/15
|
|||||||
{{ record.label }}
|
{{ record.label }}
|
||||||
<div>
|
<div>
|
||||||
<span class="badge badge-success badge-pill">
|
<span class="badge badge-success badge-pill">
|
||||||
{{ record.credit_amount|accounting_amount }}
|
{{ record.credit|accounting_amount }}
|
||||||
</span>
|
</span>
|
||||||
<span class="badge badge-warning badge-pill">
|
<span class="badge badge-warning badge-pill">
|
||||||
{{ record.debit_amount|accounting_amount }}
|
{{ record.debit|accounting_amount }}
|
||||||
</span>
|
</span>
|
||||||
<span class="badge {% if record.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
|
<span class="badge {% if record.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
|
||||||
{{ record.balance|intcomma:False }}
|
{{ record.balance|intcomma:False }}
|
||||||
@ -146,10 +146,10 @@ First written: 2020/7/15
|
|||||||
{{ record.label }}
|
{{ record.label }}
|
||||||
<div>
|
<div>
|
||||||
<span class="badge badge-success badge-pill">
|
<span class="badge badge-success badge-pill">
|
||||||
{{ record.credit_amount|accounting_amount }}
|
{{ record.credit|accounting_amount }}
|
||||||
</span>
|
</span>
|
||||||
<span class="badge badge-warning badge-pill">
|
<span class="badge badge-warning badge-pill">
|
||||||
{{ record.debit_amount|accounting_amount }}
|
{{ record.debit|accounting_amount }}
|
||||||
</span>
|
</span>
|
||||||
<span class="badge {% if record.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
|
<span class="badge {% if record.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
|
||||||
{{ record.balance|intcomma:False }}
|
{{ record.balance|intcomma:False }}
|
||||||
|
@ -95,8 +95,8 @@ First written: 2020/7/17
|
|||||||
{% for record in records %}
|
{% for record in records %}
|
||||||
<tr class="{% if current_subject.code|first in "12" and record.balance < 0 %} table-danger {% endif %}">
|
<tr class="{% if current_subject.code|first in "12" and record.balance < 0 %} table-danger {% endif %}">
|
||||||
<td>{{ record.label }}</td>
|
<td>{{ record.label }}</td>
|
||||||
<td class="amount">{{ record.debit_amount|accounting_amount }}</td>
|
<td class="amount">{{ record.debit|accounting_amount }}</td>
|
||||||
<td class="amount">{{ record.credit_amount|accounting_amount }}</td>
|
<td class="amount">{{ record.credit|accounting_amount }}</td>
|
||||||
<td class="amount {% if record.balance < 0 %} text-danger {% endif %}">{{ record.balance|accounting_amount }}</td>
|
<td class="amount {% if record.balance < 0 %} text-danger {% endif %}">{{ record.balance|accounting_amount }}</td>
|
||||||
<td class="amount {% if record.cumulative_balance < 0 %} text-danger {% endif %}">{{ record.cumulative_balance|accounting_amount }}</td>
|
<td class="amount {% if record.cumulative_balance < 0 %} text-danger {% endif %}">{{ record.cumulative_balance|accounting_amount }}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
@ -121,10 +121,10 @@ First written: 2020/7/17
|
|||||||
{{ record.label }}
|
{{ record.label }}
|
||||||
<div>
|
<div>
|
||||||
<span class="badge badge-success badge-pill">
|
<span class="badge badge-success badge-pill">
|
||||||
{{ record.debit_amount|accounting_amount }}
|
{{ record.debit|accounting_amount }}
|
||||||
</span>
|
</span>
|
||||||
<span class="badge badge-warning badge-pill">
|
<span class="badge badge-warning badge-pill">
|
||||||
{{ record.credit_amount|accounting_amount }}
|
{{ record.credit|accounting_amount }}
|
||||||
</span>
|
</span>
|
||||||
<span class="badge {% if record.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
|
<span class="badge {% if record.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
|
||||||
{{ record.balance|intcomma:False }}
|
{{ record.balance|intcomma:False }}
|
||||||
@ -145,10 +145,10 @@ First written: 2020/7/17
|
|||||||
{{ record.label }}
|
{{ record.label }}
|
||||||
<div>
|
<div>
|
||||||
<span class="badge badge-success badge-pill">
|
<span class="badge badge-success badge-pill">
|
||||||
{{ record.debit_amount|accounting_amount }}
|
{{ record.debit|accounting_amount }}
|
||||||
</span>
|
</span>
|
||||||
<span class="badge badge-warning badge-pill">
|
<span class="badge badge-warning badge-pill">
|
||||||
{{ record.credit_amount|accounting_amount }}
|
{{ record.credit|accounting_amount }}
|
||||||
</span>
|
</span>
|
||||||
<span class="badge {% if record.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
|
<span class="badge {% if record.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
|
||||||
{{ record.balance|intcomma:False }}
|
{{ record.balance|intcomma:False }}
|
||||||
|
@ -298,8 +298,8 @@ def cash_summary(request, subject_code):
|
|||||||
records = list(RecordSummary.objects.raw(
|
records = list(RecordSummary.objects.raw(
|
||||||
f"""SELECT
|
f"""SELECT
|
||||||
{month_definition} AS month,
|
{month_definition} AS month,
|
||||||
SUM(CASE WHEN r.is_credit THEN r.amount ELSE 0 END) AS credit_amount,
|
SUM(CASE WHEN r.is_credit THEN r.amount ELSE 0 END) AS credit,
|
||||||
SUM(CASE WHEN r.is_credit THEN 0 ELSE r.amount END) AS debit_amount,
|
SUM(CASE WHEN r.is_credit THEN 0 ELSE r.amount END) AS debit,
|
||||||
SUM(CASE WHEN r.is_credit THEN 1 ELSE -1 END * r.amount) AS balance
|
SUM(CASE WHEN r.is_credit THEN 1 ELSE -1 END * r.amount) AS balance
|
||||||
FROM accounting_records AS r
|
FROM accounting_records AS r
|
||||||
INNER JOIN (SELECT
|
INNER JOIN (SELECT
|
||||||
@ -326,8 +326,8 @@ ORDER BY month"""))
|
|||||||
records = list(RecordSummary.objects.raw(
|
records = list(RecordSummary.objects.raw(
|
||||||
f"""SELECT
|
f"""SELECT
|
||||||
{month_definition} AS month,
|
{month_definition} AS month,
|
||||||
SUM(CASE WHEN r.is_credit THEN r.amount ELSE 0 END) AS credit_amount,
|
SUM(CASE WHEN r.is_credit THEN r.amount ELSE 0 END) AS credit,
|
||||||
SUM(CASE WHEN r.is_credit THEN 0 ELSE r.amount END) AS debit_amount,
|
SUM(CASE WHEN r.is_credit THEN 0 ELSE r.amount END) AS debit,
|
||||||
SUM(CASE WHEN r.is_credit THEN 1 ELSE -1 END * r.amount) AS balance
|
SUM(CASE WHEN r.is_credit THEN 1 ELSE -1 END * r.amount) AS balance
|
||||||
FROM accounting_records AS r
|
FROM accounting_records AS r
|
||||||
INNER JOIN (SELECT
|
INNER JOIN (SELECT
|
||||||
@ -351,8 +351,8 @@ ORDER BY month""",
|
|||||||
record.cumulative_balance = cumulative_balance
|
record.cumulative_balance = cumulative_balance
|
||||||
records.append(RecordSummary(
|
records.append(RecordSummary(
|
||||||
label=pgettext("Accounting|", "Total"),
|
label=pgettext("Accounting|", "Total"),
|
||||||
credit_amount=sum([x.credit_amount for x in records]),
|
credit=sum([x.credit for x in records]),
|
||||||
debit_amount=sum([x.debit_amount for x in records]),
|
debit=sum([x.debit for x in records]),
|
||||||
balance=sum([x.balance for x in records]),
|
balance=sum([x.balance for x in records]),
|
||||||
cumulative_balance=cumulative_balance,
|
cumulative_balance=cumulative_balance,
|
||||||
))
|
))
|
||||||
@ -468,8 +468,8 @@ def ledger_summary(request, subject_code):
|
|||||||
# The accounting records
|
# The accounting records
|
||||||
records = [RecordSummary(
|
records = [RecordSummary(
|
||||||
month=x["month"],
|
month=x["month"],
|
||||||
debit_amount=x["debit"] if x["debit"] is not None else 0,
|
debit=x["debit"] if x["debit"] is not None else 0,
|
||||||
credit_amount=x["credit"] if x["credit"] is not None else 0,
|
credit=x["credit"] if x["credit"] is not None else 0,
|
||||||
balance=x["balance"],
|
balance=x["balance"],
|
||||||
) for x in Record.objects\
|
) for x in Record.objects\
|
||||||
.filter(subject__code__startswith=current_subject.code)\
|
.filter(subject__code__startswith=current_subject.code)\
|
||||||
@ -492,8 +492,8 @@ def ledger_summary(request, subject_code):
|
|||||||
record.cumulative_balance = cumulative_balance
|
record.cumulative_balance = cumulative_balance
|
||||||
records.append(RecordSummary(
|
records.append(RecordSummary(
|
||||||
label=pgettext("Accounting|", "Total"),
|
label=pgettext("Accounting|", "Total"),
|
||||||
credit_amount=sum([x.credit_amount for x in records]),
|
credit=sum([x.credit for x in records]),
|
||||||
debit_amount=sum([x.debit_amount for x in records]),
|
debit=sum([x.debit for x in records]),
|
||||||
balance=sum([x.balance for x in records]),
|
balance=sum([x.balance for x in records]),
|
||||||
cumulative_balance=cumulative_balance,
|
cumulative_balance=cumulative_balance,
|
||||||
))
|
))
|
||||||
|
Loading…
Reference in New Issue
Block a user