2023-06-07 14:35:31 +00:00
|
|
|
{{ define "title" -}}
|
|
|
|
{{ .Number | printf ( pgettext "Quotation %s" "title" )}}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ define "breadcrumbs" -}}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.quote*/ -}}
|
|
|
|
<nav>
|
Remove almost all data-hx-boost attributes
Since 16e80b5ae, <body> no longer has overflow, thus no scroll. As a
consequence, htmx no longer is able to scroll up <main> when it changes
due to the default, implicit `show:true` applied to the request: is
calls <main>’s scrollIntoView, however there is nothing to scroll to.
I probably could fix it by changing the target of `show`, or even add
a `scroll` directive to all boosted links, but at this point i think it
is better no not boost links at all, as they do what i want—show the new
page from the top—with less markup, plus the browser now show a loading
animation, and it is not that slower, too.
2024-09-07 23:29:30 +00:00
|
|
|
<p>
|
2023-06-07 14:35:31 +00:00
|
|
|
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
|
|
|
|
<a href="{{ companyURI "/quotes"}}">{{( pgettext "Quotations" "title" )}}</a> /
|
|
|
|
<a>{{ .Number }}</a>
|
|
|
|
</p>
|
|
|
|
<p>
|
2023-06-10 18:46:03 +00:00
|
|
|
<a class="button primary"
|
|
|
|
href="{{ companyURI "/invoices/new"}}?quote={{ .Slug }}">{{( pgettext "Create invoice" "action" )}}</a>
|
2023-06-07 14:35:31 +00:00
|
|
|
<a class="button primary"
|
|
|
|
href="{{ companyURI "/quotes/new"}}?duplicate={{ .Slug }}">{{( pgettext "Duplicate" "action" )}}</a>
|
|
|
|
<a class="button primary"
|
|
|
|
href="{{ companyURI "/quotes/"}}{{ .Slug }}/edit">{{( pgettext "Edit" "action" )}}</a>
|
|
|
|
<a class="primary button"
|
|
|
|
href="{{ companyURI "/quotes/" }}{{ .Slug }}.pdf"
|
|
|
|
download="{{ .Number}}.pdf">{{( pgettext "Download quotation" "action" )}}</a>
|
|
|
|
</p>
|
|
|
|
</nav>
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ define "content" }}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.quote*/ -}}
|
2024-01-19 22:09:25 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="/static/invoice.css?v={{ numerusVersion }}">
|
2023-06-07 14:35:31 +00:00
|
|
|
<article class="invoice">
|
|
|
|
<header>
|
|
|
|
<div>
|
|
|
|
<h1>{{ .Number | printf ( pgettext "Quotation %s" "title" )}}</h1>
|
|
|
|
<p class="date">{{( pgettext "Date" "title" )}} {{ .Date | formatDate }}</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<address class="quoter">
|
|
|
|
{{ .Quoter.Name }}<br>
|
|
|
|
{{ .Quoter.VATIN }}<br>
|
|
|
|
{{ .Quoter.Address }}<br>
|
|
|
|
{{ .Quoter.City }} ({{ .Quoter.PostalCode}}), {{ .Quoter.Province }}<br>
|
|
|
|
{{ .Quoter.Email }}<br>
|
|
|
|
{{ .Quoter.Phone }}<br>
|
|
|
|
</address>
|
|
|
|
|
|
|
|
<p class="legal">{{ .LegalDisclaimer }}</p>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div>
|
Allow empty contact and payment method for quotes
I have to use a value to be used as “none” for payment method and
contact. In PL/pgSQL add_quote and edit_quote functions, that value is
NULL, while in forms it is the empty string. I can not simply pass the
empty string for either of these fields because PL/pgSQL expects
(nullable) integers, and "" is not a valid integer and is not NULL
either. A conversion is necessary.
Apparently, Go’s nil is not a valid representation for SQL’s NULL with
pgx, and had to use sql.NullString instead.
I also needed to coalesce contact’s VATIN and phone, because null values
can not be scanned to *string. I did not do that before because
`coalesce(vatin, '')` throws an error that '' is not a valid VATIN and
just left as is, wrongly expecting that pgx would do the job of leaving
the string blank for me. It does not.
Lastly, i can not blindly write Quotee’s tax details in the quote’s view
page, or we would see the (), characters for the empty address info.
2023-06-08 11:05:41 +00:00
|
|
|
{{ if .HasQuotee -}}
|
Split contact relation into tax_details, phone, web, and email
We need to have contacts with just a name: we need to assign
freelancer’s quote as expense linked the government, but of course we
do not have a phone or email for that “contact”, much less a VATIN or
other tax details.
It is also interesting for other expenses-only contacts to not have to
input all tax details, as we may not need to invoice then, thus are
useless for us, but sometimes it might be interesting to have them,
“just in case”.
Of course, i did not want to make nullable any of the tax details
required to generate an invoice, otherwise we could allow illegal
invoices. Therefore, that data had to go in a different relation,
and invoice’s foreign key update to point to that relation, not just
customer, or we would again be able to create invalid invoices.
We replaced the contact’s trade name with just name, because we do not
need _three_ names for a contact, but we _do_ need two: the one we use
to refer to them and the business name for tax purposes.
The new contact_phone, contact_web, and contact_email relations could be
simply a nullable field, but i did not see the point, since there are
not that many instances where i need any of this data.
Now company.taxDetailsForm is no longer “the same as contactForm with
some extra fields”, because i have to add a check whether the user needs
to invoice the contact, to check that the required values are there.
I have an additional problem with the contact form when not using
JavaScript: i must set the required field to all tax details fields to
avoid the “(optional)” suffix, and because they _are_ required when
that checkbox is enabled, but i can not set them optional when the check
is unchecked. My solution for now is to ignore the form validation,
and later i will add some JavaScript that adds the validation again,
so it will work in all cases.
2023-06-30 19:32:48 +00:00
|
|
|
<address class="quotee">
|
|
|
|
{{ .Quotee.Name }}<br>
|
|
|
|
{{ if .HasTaxDetails -}}
|
|
|
|
{{ .Quotee.VATIN }}<br>
|
|
|
|
{{ .Quotee.Address }}<br>
|
|
|
|
{{ .Quotee.City }} ({{ .Quotee.PostalCode}}), {{ .Quotee.Province }}<br>
|
|
|
|
{{- end }}
|
|
|
|
</address>
|
Allow empty contact and payment method for quotes
I have to use a value to be used as “none” for payment method and
contact. In PL/pgSQL add_quote and edit_quote functions, that value is
NULL, while in forms it is the empty string. I can not simply pass the
empty string for either of these fields because PL/pgSQL expects
(nullable) integers, and "" is not a valid integer and is not NULL
either. A conversion is necessary.
Apparently, Go’s nil is not a valid representation for SQL’s NULL with
pgx, and had to use sql.NullString instead.
I also needed to coalesce contact’s VATIN and phone, because null values
can not be scanned to *string. I did not do that before because
`coalesce(vatin, '')` throws an error that '' is not a valid VATIN and
just left as is, wrongly expecting that pgx would do the job of leaving
the string blank for me. It does not.
Lastly, i can not blindly write Quotee’s tax details in the quote’s view
page, or we would see the (), characters for the empty address info.
2023-06-08 11:05:41 +00:00
|
|
|
{{- end }}
|
2023-06-07 14:35:31 +00:00
|
|
|
|
2023-06-08 10:52:10 +00:00
|
|
|
{{ if .TermsAndConditions -}}
|
|
|
|
<p class="terms_and_conditions">{{(gettext "Terms and Conditions:")}} {{ .TermsAndConditions }}</p>
|
|
|
|
{{- end }}
|
Split contact relation into tax_details, phone, web, and email
We need to have contacts with just a name: we need to assign
freelancer’s quote as expense linked the government, but of course we
do not have a phone or email for that “contact”, much less a VATIN or
other tax details.
It is also interesting for other expenses-only contacts to not have to
input all tax details, as we may not need to invoice then, thus are
useless for us, but sometimes it might be interesting to have them,
“just in case”.
Of course, i did not want to make nullable any of the tax details
required to generate an invoice, otherwise we could allow illegal
invoices. Therefore, that data had to go in a different relation,
and invoice’s foreign key update to point to that relation, not just
customer, or we would again be able to create invalid invoices.
We replaced the contact’s trade name with just name, because we do not
need _three_ names for a contact, but we _do_ need two: the one we use
to refer to them and the business name for tax purposes.
The new contact_phone, contact_web, and contact_email relations could be
simply a nullable field, but i did not see the point, since there are
not that many instances where i need any of this data.
Now company.taxDetailsForm is no longer “the same as contactForm with
some extra fields”, because i have to add a check whether the user needs
to invoice the contact, to check that the required values are there.
I have an additional problem with the contact form when not using
JavaScript: i must set the required field to all tax details fields to
avoid the “(optional)” suffix, and because they _are_ required when
that checkbox is enabled, but i can not set them optional when the check
is unchecked. My solution for now is to ignore the form validation,
and later i will add some JavaScript that adds the validation again,
so it will work in all cases.
2023-06-30 19:32:48 +00:00
|
|
|
|
2023-06-07 14:35:31 +00:00
|
|
|
{{- $columns := 5 | add (len .TaxClasses) | add (boolToInt .HasDiscounts) -}}
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>{{( pgettext "Concept" "title" )}}</th>
|
|
|
|
<th class="numeric">{{( pgettext "Price" "title" )}}</th>
|
|
|
|
{{ if .HasDiscounts -}}
|
|
|
|
<th class="numeric">{{( pgettext "Discount" "title" )}}</th>
|
|
|
|
{{ end -}}
|
|
|
|
<th class="numeric">{{( pgettext "Units" "title" )}}</th>
|
|
|
|
<th class="numeric">{{( pgettext "Subtotal" "title" )}}</th>
|
|
|
|
{{ range $class := .TaxClasses -}}
|
|
|
|
<th class="numeric">{{ . }}</th>
|
|
|
|
{{ end -}}
|
|
|
|
<th class="numeric">{{( pgettext "Total" "title" )}}</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
{{ $lastIndex := len .Products | sub 1 }}
|
|
|
|
{{ range $index, $product := .Products -}}
|
|
|
|
<tbody>
|
|
|
|
{{- if .Description }}
|
|
|
|
<tr class="name">
|
|
|
|
<td colspan="{{ $columns }}">{{ .Name }}</td>
|
|
|
|
</tr>
|
|
|
|
{{ end -}}
|
|
|
|
<tr>
|
|
|
|
{{- if .Description }}
|
|
|
|
<td>{{ .Description }}</td>
|
|
|
|
{{- else }}
|
|
|
|
<td>{{ .Name }}</td>
|
|
|
|
{{- end -}}
|
|
|
|
<td class="numeric">{{ .Price | formatPrice }}</td>
|
|
|
|
{{ if $.HasDiscounts -}}
|
|
|
|
<td class="numeric">{{ $product.Discount | formatPercent }}</td>
|
|
|
|
{{ end -}}
|
|
|
|
<td class="numeric">{{ .Quantity }}</td>
|
|
|
|
<td class="numeric">{{ .Subtotal | formatPrice }}</td>
|
|
|
|
{{ range $class := $.TaxClasses -}}
|
|
|
|
<td class="numeric">{{ index $product.Taxes $class | formatPercent }}</td>
|
|
|
|
{{ end -}}
|
|
|
|
<td class="numeric">{{ .Total | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
{{ if (eq $index $lastIndex) }}
|
|
|
|
<tr class="tfoot separator">
|
|
|
|
<th scope="row" colspan="{{ $columns | sub 1 }}">{{( pgettext "Tax Base" "title" )}}</th>
|
|
|
|
<td class="numeric">{{ $.Subtotal | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
{{ range $tax := $.Taxes -}}
|
|
|
|
<tr class="tfoot">
|
|
|
|
<th scope="row" colspan="{{ $columns | sub 1 }}">{{ index . 0 }}</th>
|
|
|
|
<td class="numeric">{{ index . 1 | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
{{- end }}
|
|
|
|
<tr class="tfoot">
|
|
|
|
<th scope="row" colspan="{{ $columns | sub 1 }}">{{( pgettext "Total" "title" )}}</th>
|
|
|
|
<td class="numeric">{{ $.Total | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
</tbody>
|
|
|
|
{{- end }}
|
|
|
|
</table>
|
|
|
|
|
|
|
|
{{ if .Notes -}}
|
|
|
|
<p class="notes">{{ .Notes }}</p>
|
|
|
|
{{- end }}
|
|
|
|
<p class="payment-instructions">{{ .PaymentInstructions }}</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
{{- end}}
|