2023-05-03 10:46:25 +00:00
|
|
|
{{ define "title" -}}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.editExpensePage*/ -}}
|
|
|
|
{{ printf ( pgettext "Edit Expense “%s”" "title" ) .Slug }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ define "breadcrumbs" -}}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.editExpensePage*/ -}}
|
|
|
|
<nav data-hx-target="main" data-hx-boost="true">
|
|
|
|
<p>
|
|
|
|
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
|
|
|
|
<a href="{{ companyURI "/expenses"}}">{{( pgettext "Expenses" "title" )}}</a> /
|
|
|
|
<a>{{ .Slug }}</a>
|
|
|
|
</p>
|
|
|
|
</nav>
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ define "content" }}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.editExpensePage*/ -}}
|
2023-05-23 21:13:21 +00:00
|
|
|
<section id="new-expense-dialog-content" data-hx-target="main">
|
2023-05-03 10:46:25 +00:00
|
|
|
<h2>{{ printf (pgettext "Edit Expense “%s”" "title") .Slug }}</h2>
|
2023-07-11 13:33:26 +00:00
|
|
|
<form enctype="multipart/form-data" method="POST" action="{{ companyURI "/expenses/" }}{{ .Slug }}"
|
Compute the total amount, base plus taxes, of all expenses
This works mostly like invoices: i have to “update” the expense form
to compute its total based on the subtotal and the selected taxes,
although in this case i do no need to compute the subtotal because that
is given by the user.
Nevertheless, i added a new function to compute that total because it
was already hairy enough for the dashboard, that also needs to compute
the tota, not just the base, and i wanted to test that function.
There is no need for a custom input type for that function as it only
needs a couple of simple domains. I have created the output type,
though, because otherwise i would need to have records or “reuse” any
other “amount” output type, which would be confusing.\
Part of #68.
2023-07-13 18:50:26 +00:00
|
|
|
data-hx-boost="true"
|
|
|
|
data-hx-swap="innerHTML show:false"
|
|
|
|
>
|
2023-05-03 10:46:25 +00:00
|
|
|
{{ csrfToken }}
|
|
|
|
|
|
|
|
{{ with .Form -}}
|
2023-07-11 13:33:26 +00:00
|
|
|
<div class="expenses-data">
|
|
|
|
{{ template "select-field" .Invoicer }}
|
|
|
|
{{ template "input-field" .InvoiceNumber }}
|
|
|
|
{{ template "input-field" .InvoiceDate }}
|
|
|
|
{{ template "input-field" .Amount }}
|
|
|
|
{{ template "select-field" .Tax }}
|
|
|
|
{{ template "tags-field" .Tags }}
|
|
|
|
{{ template "select-field" .ExpenseStatus }}
|
|
|
|
{{ template "file-field" .File }}
|
|
|
|
</div>
|
2023-05-03 10:46:25 +00:00
|
|
|
{{- end }}
|
|
|
|
|
Compute the total amount, base plus taxes, of all expenses
This works mostly like invoices: i have to “update” the expense form
to compute its total based on the subtotal and the selected taxes,
although in this case i do no need to compute the subtotal because that
is given by the user.
Nevertheless, i added a new function to compute that total because it
was already hairy enough for the dashboard, that also needs to compute
the tota, not just the base, and i wanted to test that function.
There is no need for a custom input type for that function as it only
needs a couple of simple domains. I have created the output type,
though, because otherwise i would need to have records or “reuse” any
other “amount” output type, which would be confusing.\
Part of #68.
2023-07-13 18:50:26 +00:00
|
|
|
<table id="invoice-summary">
|
|
|
|
<tbody>
|
|
|
|
{{- range $tax := .Taxes }}
|
|
|
|
<tr>
|
|
|
|
<th scope="row">{{ index . 0 }}</th>
|
|
|
|
<td class="numeric">{{ index . 1 | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
{{- end }}
|
|
|
|
<tr>
|
|
|
|
<th scope="row">{{(pgettext "Total" "title")}}</th>
|
|
|
|
<td class="numeric">{{ .Total | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<fieldset class="button-bar">
|
|
|
|
<button formnovalidate
|
|
|
|
id="recompute-button"
|
|
|
|
name="action" value="update"
|
|
|
|
type="submit">{{( pgettext "Update" "action" )}}</button>
|
|
|
|
<button class="primary"
|
|
|
|
name="_method" value="PUT"
|
|
|
|
type="submit">{{( pgettext "Save" "action" )}}</button>
|
2023-05-03 10:46:25 +00:00
|
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
</section>
|
Compute the total amount, base plus taxes, of all expenses
This works mostly like invoices: i have to “update” the expense form
to compute its total based on the subtotal and the selected taxes,
although in this case i do no need to compute the subtotal because that
is given by the user.
Nevertheless, i added a new function to compute that total because it
was already hairy enough for the dashboard, that also needs to compute
the tota, not just the base, and i wanted to test that function.
There is no need for a custom input type for that function as it only
needs a couple of simple domains. I have created the output type,
though, because otherwise i would need to have records or “reuse” any
other “amount” output type, which would be confusing.\
Part of #68.
2023-07-13 18:50:26 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
document.body.addEventListener('recompute', function () {
|
|
|
|
document.getElementById('recompute-button').click();
|
|
|
|
});
|
|
|
|
</script>
|
2023-05-03 10:46:25 +00:00
|
|
|
{{- end }}
|