Add the company relation and read-only form to edit
I do not have more time to update the update to the company today, but i
believe this is already a good amount of work for a commit.
The company is going to be used for row level security, as users will
only have access to the data from companies they are granted access, by
virtue of being in the company_user relation.
I did not know how add a row level security policy to the company_user
because i needed the to select on the same relation and this is not
allowed, because it would create an infinite loop.
Had to add the vat, pg_libphonenumber, and uri extensions in order to
validate VAT identification numbers, phone numbers, and URIs,
repectively. These libraries are not in Debian, but i created packages
for them all in https://dev.tandem.ws/tandem.
2023-01-24 20:46:07 +00:00
|
|
|
{{ define "content" }}
|
|
|
|
<section class="dialog-content">
|
|
|
|
<h2>{{(pgettext "Tax Details" "title")}}</h2>
|
2023-01-28 13:18:58 +00:00
|
|
|
<form id="details" method="POST">
|
2023-01-28 11:24:52 +00:00
|
|
|
<div class="input">
|
|
|
|
<input type="text" name="business_name" id="business_name" required="required" value="{{ .BusinessName }}" placeholder="{{( pgettext "Business name" "input" )}}">
|
|
|
|
<label for="business_name">{{( pgettext "Business name" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
<div class="input">
|
|
|
|
<input type="text" name="vatin" id="vatin" required="required" value="{{ .VATIN }}" placeholder="{{( pgettext "VAT number" "input" )}}">
|
|
|
|
<label for="vatin">{{( pgettext "VAT number" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
<div class="input">
|
|
|
|
<input type="text" name="trade_name" id="trade_name" value="{{ .TradeName }}" placeholder="{{( pgettext "Trade name" "input" )}}">
|
|
|
|
<label for="trade_name">{{( pgettext "Trade name" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
<div class="input">
|
|
|
|
<input type="tel" name="phone" id="phone" required="required" value="{{ .Phone }}" placeholder="{{( pgettext "Phone" "input" )}}">
|
|
|
|
<label for="phone">{{( pgettext "Phone" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
<div class="input">
|
|
|
|
<input type="email" name="email" id="email" required="required" value="{{ .Email }}" placeholder="{{( pgettext "Email" "input" )}}">
|
|
|
|
<label for="email">{{( pgettext "Email" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
<div class="input">
|
|
|
|
<input type="url" name="web" id="web" value="{{ .Web }}" placeholder="{{( pgettext "Web" "input" )}}">
|
|
|
|
<label for="web">{{( pgettext "Web" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
<div class="input">
|
|
|
|
<input type="text" name="address" id="address" class="width-2x" required="required" value="{{ .Address }}" placeholder="{{( pgettext "Address" "input" )}}">
|
|
|
|
<label for="address">{{( pgettext "Address" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
<div class="input">
|
|
|
|
<input type="text" name="city" id="city" required="required" value="{{ .City }}" placeholder="{{( pgettext "City" "input" )}}">
|
|
|
|
<label for="city">{{( pgettext "City" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
<div class="input">
|
|
|
|
<input type="text" name="province" id="province" required="required" value="{{ .City }}" placeholder="{{( pgettext "Province" "input" )}}">
|
|
|
|
<label for="province">{{( pgettext "Province" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
<div class="input">
|
|
|
|
<input type="text" name="postal_code" id="postal_code" required="required" value="{{ .PostalCode }}" placeholder="{{( pgettext "Postal code" "input" )}}">
|
|
|
|
<label for="postal_code">{{( pgettext "Postal code" "input" )}}</label>
|
|
|
|
</div>
|
2023-01-27 20:30:14 +00:00
|
|
|
|
2023-01-28 11:24:52 +00:00
|
|
|
<div class="input">
|
|
|
|
<select id="country" name="country" class="width-fixed">
|
|
|
|
{{- range $country := .Countries }}
|
|
|
|
<option value="{{ .Code }}" {{ if eq .Code $.CountryCode }}selected="selected"{{ end }}>{{ .Name }}</option>
|
|
|
|
{{- end }}
|
|
|
|
</select>
|
2023-01-28 13:18:58 +00:00
|
|
|
<label for="country">{{( pgettext "Country" "input" )}}</label>
|
2023-01-28 11:24:52 +00:00
|
|
|
</div>
|
2023-01-27 20:30:14 +00:00
|
|
|
|
2023-01-28 11:24:52 +00:00
|
|
|
<fieldset>
|
|
|
|
<legend id="currency-legend">{{( pgettext "Currency" "input" )}}</legend>
|
|
|
|
|
|
|
|
<select id="currency" name="currency" aria-labelledby="currency-legend">
|
|
|
|
{{- range $currency := .Currencies }}
|
|
|
|
<option value="{{ .Code }}" {{ if eq .Code $.CurrencyCode }}selected="selected"{{ end }}>{{ .Symbol }} ({{ .Code }})</option>
|
|
|
|
{{- end }}
|
|
|
|
</select>
|
|
|
|
</fieldset>
|
2023-01-28 13:18:58 +00:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<form id="newtax" method="POST" action="{{ companyURI "/tax" }}">
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<fieldset>
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th width="50%"></th>
|
|
|
|
<th>{{( pgettext "Tax Name" "title" )}}</th>
|
|
|
|
<th>{{( pgettext "Rate (%)" "title" )}}</th>
|
|
|
|
<th></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{{ with .Taxes }}
|
|
|
|
{{- range $tax := . }}
|
|
|
|
<tr>
|
|
|
|
<td></td>
|
|
|
|
<td>{{ .Name }}</td>
|
|
|
|
<td>{{ .Rate }}</td>
|
|
|
|
<td>
|
|
|
|
<form method="POST" action="{{ companyURI "/tax"}}/{{ .Id }}">
|
|
|
|
<input type="hidden" name="_method" name="DELETE"/>
|
|
|
|
<button class="icon" aria-label="{{( gettext "Delete tax" )}}" type="submit"><i class="ri-delete-back-2-line"></i></button>
|
|
|
|
</form>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{{- end }}
|
|
|
|
{{ else }}
|
|
|
|
<tr>
|
|
|
|
<td colspan="4">{{( gettext "No taxes added yet." )}}</td>
|
|
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr>
|
|
|
|
<th scope="row">{{( pgettext "New Line" "title")}}</th>
|
|
|
|
<td>
|
|
|
|
<div class="input">
|
|
|
|
<input form="newtax" type="text" name="name" id="tax_name" required="required" placeholder="{{( pgettext "Tax name" "input" )}}">
|
|
|
|
<label for="tax_name">{{( pgettext "Tax name" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td colspan="2">
|
|
|
|
<div class="input">
|
|
|
|
<input form="newtax" type="number" name="rate" id="tax_rate" min="-99" max="99" required="required" placeholder="{{( pgettext "Rate (%)" "input" )}}">
|
|
|
|
<label form="newtax" for="tax_rate">{{( pgettext "Rate (%)" "input" )}}</label>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td colspan="2"></td>
|
|
|
|
<td colspan="2">
|
|
|
|
<button form="newtax" type="submit">{{( pgettext "Add new tax" "action" )}}</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
|
|
|
</table>
|
|
|
|
</fieldset>
|
2023-01-28 11:24:52 +00:00
|
|
|
|
|
|
|
<fieldset>
|
2023-01-28 13:18:58 +00:00
|
|
|
<button form="details" type="submit">{{( pgettext "Save changes" "action" )}}</button>
|
2023-01-28 11:24:52 +00:00
|
|
|
</fieldset>
|
Add the company relation and read-only form to edit
I do not have more time to update the update to the company today, but i
believe this is already a good amount of work for a commit.
The company is going to be used for row level security, as users will
only have access to the data from companies they are granted access, by
virtue of being in the company_user relation.
I did not know how add a row level security policy to the company_user
because i needed the to select on the same relation and this is not
allowed, because it would create an infinite loop.
Had to add the vat, pg_libphonenumber, and uri extensions in order to
validate VAT identification numbers, phone numbers, and URIs,
repectively. These libraries are not in Debian, but i created packages
for them all in https://dev.tandem.ws/tandem.
2023-01-24 20:46:07 +00:00
|
|
|
</section>
|
|
|
|
{{- end }}
|