Skip to content

Commit 0ebbde7

Browse files
committed
- **Simplified journal entry update logic in import process:**
- Adjusted the order of `unlock` and `unpost` calls to reflect appropriate transactional sequence before deletion. - **Refined transaction actions in template:** - Updated dropdown structure to consistently display transaction actions regardless of `is_parent` or `is_bundled` status. - Improved conditional logic to dynamically manage available actions like "View JE," "View Receipt," and "Undo Import." - Enhanced template organization for better readability and maintainability. ### **Summary** Streamlined journal entry handling logic and improved dropdown action display in transaction templates for better consistency and user experience. ### **Backwards Compatibility** These changes are fully backwards compatible. No significant behavioral or structural changes to existing workflows.
1 parent 6d3dd79 commit 0ebbde7

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

django_ledger/models/data_import.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,10 +1914,8 @@ def undo_import(self, raise_exception: bool = True):
19141914
tx_model = self.transaction_model
19151915
journal_entry_model = tx_model.journal_entry
19161916

1917-
if journal_entry_model.can_unlock():
1918-
journal_entry_model.unlock(raise_exception=False)
1919-
if journal_entry_model.can_unpost():
1920-
journal_entry_model.unpost(raise_exception=False)
1917+
journal_entry_model.unpost(raise_exception=False)
1918+
journal_entry_model.unlock(raise_exception=False)
19211919

19221920
journal_entry_model.delete()
19231921

django_ledger/templates/django_ledger/data_import/tags/data_import_job_txs_imported.html

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,36 @@
5353
<td>{{ imported_tx.account_model | default:'' }}</td>
5454
<td>{{ imported_tx.transaction_model | default:'' }}</td>
5555
<td class="has-text-centered">
56-
{% if not imported_tx.is_parent and not imported_tx.is_bundled %}
57-
<div class="dropdown is-hoverable is-right">
58-
<div class="dropdown-trigger">
59-
<button class="button is-small" aria-haspopup="true"
60-
aria-controls="actions-{{ imported_tx.uuid }}">
61-
<span>{% trans 'Actions' %}</span>
62-
<span class="icon is-small">{% icon 'mdi:chevron-down' 14 %}</span>
63-
</button>
64-
</div>
65-
<div class="dropdown-menu" id="actions-{{ imported_tx.uuid }}" role="menu">
66-
<div class="dropdown-content">
56+
<div class="dropdown is-hoverable is-right">
57+
<div class="dropdown-trigger">
58+
<button class="button is-small" aria-haspopup="true"
59+
aria-controls="actions-{{ imported_tx.uuid }}">
60+
<span>{% trans 'Actions' %}</span>
61+
<span class="icon is-small">{% icon 'mdi:chevron-down' 14 %}</span>
62+
</button>
63+
</div>
64+
<div class="dropdown-menu" id="actions-{{ imported_tx.uuid }}" role="menu">
65+
<div class="dropdown-content">
66+
{% if not imported_tx.is_parent and not imported_tx.is_bundled %}
6767
<a href="{% url 'django_ledger:je-detail' entity_slug=import_job_model.entity_slug ledger_pk=imported_tx.transaction_model.journal_entry.ledger_id je_pk=imported_tx.transaction_model.journal_entry_id %}"
6868
class="dropdown-item">{% trans 'View JE' %}</a>
69-
{% if imported_tx.receipt_uuid %}
70-
<a href="{% url 'django_ledger:receipt-detail' entity_slug=import_job_model.entity_slug receipt_pk=imported_tx.receiptmodel.uuid %}"
71-
class="dropdown-item">{% trans 'View Receipt' %}</a>
72-
{% endif %}
73-
<hr class="dropdown-divider">
74-
{% if imported_tx.can_undo_import %}
75-
<form method="post"
76-
action="{% url 'django_ledger:data-import-staged-tx-undo' entity_slug=import_job_model.entity_slug job_pk=import_job_model.uuid staged_tx_pk=imported_tx.uuid %}">
77-
{% csrf_token %}
78-
<button type="submit"
79-
class="dropdown-item has-text-danger">{% trans 'Undo Import' %}</button>
80-
</form>
81-
{% endif %}
82-
</div>
83-
</div>
69+
{% endif %}
70+
{% if imported_tx.receipt_uuid %}
71+
<a href="{% url 'django_ledger:receipt-detail' entity_slug=import_job_model.entity_slug receipt_pk=imported_tx.receiptmodel.uuid %}"
72+
class="dropdown-item">{% trans 'View Receipt' %}</a>
73+
{% endif %}
74+
<hr class="dropdown-divider">
75+
{% if imported_tx.can_undo_import %}
76+
<form method="post"
77+
action="{% url 'django_ledger:data-import-staged-tx-undo' entity_slug=import_job_model.entity_slug job_pk=import_job_model.uuid staged_tx_pk=imported_tx.uuid %}">
78+
{% csrf_token %}
79+
<button type="submit"
80+
class="dropdown-item has-text-danger">{% trans 'Undo Import' %}</button>
81+
</form>
82+
</div>
83+
{% endif %}
8484
</div>
85-
{% endif %}
85+
</div>
8686
</td>
8787
</tr>
8888
{% endfor %}

0 commit comments

Comments
 (0)