2023-02-12 20:06:48 +00:00
|
|
|
{{ define "title" -}}
|
|
|
|
{{( pgettext "Add Products to Invoice" "title" )}}
|
|
|
|
{{- end }}
|
|
|
|
|
2023-03-20 12:09:52 +00:00
|
|
|
{{ define "breadcrumbs" -}}
|
2023-02-12 20:06:48 +00:00
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.newInvoiceProductsPage*/ -}}
|
|
|
|
<nav>
|
|
|
|
<p>
|
|
|
|
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
|
|
|
|
<a href="{{ companyURI "/invoices"}}">{{( pgettext "Invoices" "title" )}}</a> /
|
2023-03-13 14:00:35 +00:00
|
|
|
{{ if eq .Form.Number.Val "" }}
|
|
|
|
<a>{{( pgettext "New Invoice" "title" )}}</a>
|
|
|
|
{{ else }}
|
|
|
|
<a>{{ .Form.Number }}</a>
|
|
|
|
{{ end }}
|
2023-02-12 20:06:48 +00:00
|
|
|
</p>
|
|
|
|
</nav>
|
2023-03-20 12:09:52 +00:00
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ define "content" }}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.newInvoiceProductsPage*/ -}}
|
2023-02-12 20:06:48 +00:00
|
|
|
<section class="dialog-content">
|
|
|
|
<h2>{{(pgettext "Add Products to Invoice" "title")}}</h2>
|
2023-03-13 14:00:35 +00:00
|
|
|
<form method="POST" action="{{ .Action }}">
|
2023-02-12 20:06:48 +00:00
|
|
|
{{ csrfToken }}
|
|
|
|
|
|
|
|
{{- with .Form }}
|
|
|
|
{{ template "hidden-select-field" .Customer }}
|
|
|
|
{{ template "hidden-field" .Number }}
|
|
|
|
{{ template "hidden-field" .Date }}
|
|
|
|
{{ template "hidden-field" .Notes }}
|
2023-03-10 13:02:55 +00:00
|
|
|
{{ template "hidden-field" .Tags }}
|
2023-02-12 20:06:48 +00:00
|
|
|
|
|
|
|
{{- range $product := .Products }}
|
|
|
|
<fieldset>
|
2023-03-13 14:00:35 +00:00
|
|
|
{{ template "hidden-field" .InvoiceProductId }}
|
2023-02-12 20:06:48 +00:00
|
|
|
{{ template "hidden-field" .ProductId }}
|
|
|
|
{{ template "hidden-field" .Name }}
|
|
|
|
{{ template "hidden-field" .Description }}
|
|
|
|
{{ template "hidden-field" .Price }}
|
|
|
|
{{ template "hidden-field" .Quantity }}
|
|
|
|
{{ template "hidden-field" .Discount }}
|
|
|
|
{{ template "hidden-select-field" .Tax }}
|
|
|
|
</fieldset>
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>{{( pgettext "All" "product" )}}</th>
|
|
|
|
<th>{{( pgettext "Name" "title" )}}</th>
|
|
|
|
<th>{{( pgettext "Price" "title" )}}</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{{ with .Products }}
|
|
|
|
{{- range $product, $key := . }}
|
|
|
|
<tr>
|
|
|
|
<td><input type="checkbox" name="id" id="new-product-id-{{$key}}" value="{{.Id}}"></td>
|
|
|
|
<td><label for="new-product-id-{{$key}}">{{ .Name }}</label></td>
|
Add currency_pattern to language relation
The design calls for rendering all amounts with their currency symbol,
but golang.org/x/text’s currency package always render the symbol in
front, which is wrong in Catalan and Spanish, and a lot of other
languages.
Consulting the Internet, the most popular package for that is
accounting[0], which is almost as useless because they confuse locale
with the currency’s country of origin’s “usual locale” (e.g., en-US for
USD), which is also wrong: in Catalan i need to write USD prices as
"1.234,56 $" regardless of what Americans do.
With accounting i have the recourse of initializing the struct that
holds all the “locale” information, which is also wrong because i have
to define the decimal and thousands separators, something that depends
only on the locale, next to the currency’s precision, that is
locale-independent. But, since all CLDR data from golang.org/x/text
is inside an internal package, i can not access it and would need to
define all that information myself, which defeats the purpose of using
an external package.
Since for now i only need the format pattern for currency, i just saved
it into the database of available languages, that i do not expect to
grow too much.
[0]: https://github.com/leekchan/accounting
2023-02-23 11:12:33 +00:00
|
|
|
<td class="numeric">{{ .Price | formatPrice }}</td>
|
2023-02-12 20:06:48 +00:00
|
|
|
</tr>
|
|
|
|
{{- end }}
|
|
|
|
{{ else }}
|
|
|
|
<tr>
|
|
|
|
<td colspan="4">{{( gettext "No products added yet." )}}</td>
|
|
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<fieldset>
|
2023-02-27 12:13:28 +00:00
|
|
|
<button class="primary" type="submit"
|
|
|
|
name="action" value="add-products">{{( pgettext "Add products" "action" )}}</button>
|
2023-02-12 20:06:48 +00:00
|
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
{{- end }}
|