Skip to content

Commit

Permalink
Updated prefills to be debit and credit specific
Browse files Browse the repository at this point in the history
  • Loading branch information
edelgm6 committed Jul 25, 2024
1 parent c5d08ec commit 12659f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions api/views/journal_entry_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,16 @@ def get_journal_entry_form_html(
}
metadata_form = JournalEntryMetadataForm(initial=metadata)
# Set the total amounts for the debit and credits
prefilled_total = debit_formset.get_entry_total()
debit_prefilled_total = debit_formset.get_entry_total()
credit_prefilled_total = credit_formset.get_entry_total()
context = {
'debit_formset': debit_formset,
'credit_formset': credit_formset,
'transaction_id': transaction.id,
'autofocus_debit': is_debit,
'form_errors': form_errors,
'prefilled_total': prefilled_total,
'debit_prefilled_total': debit_prefilled_total,
'credit_prefilled_total': credit_prefilled_total,
'metadata_form': metadata_form
}

Expand Down Expand Up @@ -277,6 +279,8 @@ def _check_for_errors(self, request, debit_formset, credit_formset, metadata_for
'autofocus_debit': True,
'form_errors': form_errors,
'prefilled_total': debit_formset.get_entry_total(),
'debit_prefilled_total': debit_formset.get_entry_total(),
'credit_prefilled_total': credit_formset.get_entry_total(),
'metadata_form': metadata_form
}

Expand Down
4 changes: 2 additions & 2 deletions ledger/templates/api/entry_forms/journal-entry-item-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="col-md-6">
<h3>Debits</h3>
{{ debit_formset.management_form }}
<small>Total Debits: $<span id="totalDebits">{{ prefilled_total|floatformat:2|intcomma }}</span></small>
<small>Total Debits: $<span id="totalDebits">{{ debit_prefilled_total|floatformat:2|intcomma }}</span></small>
{% for form in debit_formset %}
<div class="row">
<div class="col-md-8">
Expand Down Expand Up @@ -79,7 +79,7 @@ <h3>Debits</h3>
<div class="col-md-6">
<h3>Credits</h3>
{{ credit_formset.management_form }}
<small>Total Credits: $<span id="totalCredits">{{ prefilled_total|floatformat:2|intcomma }}</span></small>
<small>Total Credits: $<span id="totalCredits">{{ credit_prefilled_total|floatformat:2|intcomma }}</span></small>
{% for form in credit_formset %}
<div class="row">
<div class="col-md-8">
Expand Down

0 comments on commit 12659f9

Please sign in to comment.