Replaced the use of the sn field with pk, for compatibility in the future.

This commit is contained in:
依瑪貓 2020-07-23 23:15:33 +08:00
parent e04736b90d
commit 1dcbd37fbd
5 changed files with 9 additions and 9 deletions

View File

@ -206,4 +206,4 @@ class TransactionConverter:
Returns:
str: The transaction ID.
"""
return value.sn
return value.pk

View File

@ -127,7 +127,7 @@ First written: 2020/7/1
<td class="amount">{{ item.debit_amount|accounting_amount }}</td>
<td class="amount {% if item.balance < 0 %} text-danger {% endif %}">{{ item.balance|accounting_amount }}</td>
<td class="actions">
{% if item.sn is not None %}
{% if item.pk is not None %}
<a href="{% url_with_return "accounting:transactions.show" item.transaction.type item.transaction %}" class="btn btn-info" role="button">
<i class="fas fa-eye"></i>
<span class="d-none d-lg-inline">{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}</span>
@ -143,7 +143,7 @@ First written: 2020/7/1
<ul class="list-group d-md-none">
{% for item in item_list %}
<li class="list-group-item {% if not item.is_balanced or item.has_order_hole %} list-group-item-danger {% endif %}">
{% if item.sn is not None %}
{% if item.pk is not None %}
<a class="list-group-item-action" href="{% url_with_return "accounting:transactions.show" item.transaction.type item.transaction %}">
<div class="date-account-line d-flex justify-content-between align-items-center">
{{ item.transaction.date|smart_date }} {{ item.account.title|title }}

View File

@ -107,7 +107,7 @@ First written: 2020/7/17
<td class="amount">{{ item.credit_amount|accounting_amount }}</td>
<td>{{ item.transaction.note|default:"" }}</td>
<td class="actions">
{% if item.sn is not None %}
{% if item.pk is not None %}
<a href="{% url_with_return "accounting:transactions.show" item.transaction.type item.transaction %}" class="btn btn-info" role="button">
<i class="fas fa-eye"></i>
{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}
@ -123,7 +123,7 @@ First written: 2020/7/17
<ul class="list-group d-lg-none">
{% for item in item_list %}
<li class="list-group-item {% if not item.is_balanced or item.has_order_hole %} list-group-item-danger {% endif %}">
{% if item.sn is not None %}
{% if item.pk is not None %}
<a class="list-group-item-action" href="{% url_with_return "accounting:transactions.show" item.transaction.type item.transaction %}">
<div class="{% if item.is_credit %} journal-credit {% else %} journal-debit {% endif %}">
<div class="date-account-line">

View File

@ -130,7 +130,7 @@ First written: 2020/7/16
<td class="amount">{{ item.credit_amount|accounting_amount }}</td>
<td class="amount {% if item.balance < 0 %} text-danger {% endif %}">{{ item.balance|accounting_amount }}</td>
<td class="actions">
{% if item.sn is not None %}
{% if item.pk is not None %}
<a href="{% url_with_return "accounting:transactions.show" item.transaction.type item.transaction %}" class="btn btn-info" role="button">
<i class="fas fa-eye"></i>
<span class="d-none d-lg-inline">{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}</span>
@ -146,7 +146,7 @@ First written: 2020/7/16
<ul class="list-group d-md-none">
{% for item in item_list %}
<li class="list-group-item {% if not item.is_balanced or item.has_order_hole or not item.is_credit_card_paid %} list-group-item-danger {% endif %}{% if item.is_existing_equipment %} list-group-item-info {% endif %}">
{% if item.sn is not None %}
{% if item.pk is not None %}
<a class="list-group-item-action" href="{% url_with_return "accounting:transactions.show" item.transaction.type item.transaction %}">
<div class="date-account-line">
{{ item.transaction.date|smart_date }} {{ item.account.title|title }}

View File

@ -260,14 +260,14 @@ def find_imbalanced(records):
Args:
records (list[Record]): The accounting records.
"""
imbalanced = [x.sn for x in Transaction.objects
imbalanced = [x.pk for x in Transaction.objects
.annotate(
balance=Sum(Case(
When(record__is_credit=True, then=-1),
default=1) * F("record__amount")))
.filter(~Q(balance=0))]
for record in records:
record.is_balanced = record.transaction.sn not in imbalanced
record.is_balanced = record.transaction.pk not in imbalanced
def find_order_holes(records):