Add VAT and tourist tax information
Since i need the number of decimals to format the price in the template, i added them to the company, and used them in the call to price_parse().
This commit is contained in:
parent
76456aa9b2
commit
0beb0bb315
|
@ -15,6 +15,8 @@ import (
|
||||||
|
|
||||||
type Company struct {
|
type Company struct {
|
||||||
ID int
|
ID int
|
||||||
|
DecimalDigits int
|
||||||
|
CurrencySymbol string
|
||||||
DefaultLanguage language.Tag
|
DefaultLanguage language.Tag
|
||||||
Locales locale.Locales
|
Locales locale.Locales
|
||||||
}
|
}
|
||||||
|
@ -26,10 +28,16 @@ func CompanyByHost(ctx context.Context, conn *database.Conn, host string, allLoc
|
||||||
}
|
}
|
||||||
if err := conn.QueryRow(ctx, `
|
if err := conn.QueryRow(ctx, `
|
||||||
select company_id
|
select company_id
|
||||||
|
, decimal_digits
|
||||||
|
, currency_symbol
|
||||||
from company_host
|
from company_host
|
||||||
|
join company using (company_id)
|
||||||
|
join currency using (currency_code)
|
||||||
where host = $1
|
where host = $1
|
||||||
`, host).Scan(
|
`, host).Scan(
|
||||||
&company.ID,
|
&company.ID,
|
||||||
|
&company.DecimalDigits,
|
||||||
|
&company.CurrencySymbol,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ type publicPage struct {
|
||||||
Name string
|
Name string
|
||||||
Carousel []*carousel.Slide
|
Carousel []*carousel.Slide
|
||||||
Prices []*typePrice
|
Prices []*typePrice
|
||||||
|
TouristTax string
|
||||||
Features []*typeFeature
|
Features []*typeFeature
|
||||||
Calendar *season.Calendar
|
Calendar *season.Calendar
|
||||||
Spiel gotemplate.HTML
|
Spiel gotemplate.HTML
|
||||||
|
@ -130,6 +131,9 @@ func newPublicPage(ctx context.Context, company *auth.Company, conn *database.Co
|
||||||
if err := row.Scan(&page.Name, &page.Spiel, &page.Info, &page.Facilities, &page.Description, &page.AdditionalInfo); err != nil {
|
if err := row.Scan(&page.Name, &page.Spiel, &page.Info, &page.Facilities, &page.Description, &page.AdditionalInfo); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if err := conn.QueryRow(ctx, "select to_price(tourist_tax, $1) from company where company_id = $2", company.DecimalDigits, company.ID).Scan(&page.TouristTax); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return page, nil
|
return page, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,8 +282,8 @@ func editTaxDetails(w http.ResponseWriter, r *http.Request, user *auth.User, com
|
||||||
, invoice_number_format = $14
|
, invoice_number_format = $14
|
||||||
, legal_disclaimer = $15
|
, legal_disclaimer = $15
|
||||||
, rtc_number = $16
|
, rtc_number = $16
|
||||||
, tourist_tax = parse_price($17)
|
, tourist_tax = parse_price($17, $18)
|
||||||
where company_id = $18
|
where company_id = $19
|
||||||
`,
|
`,
|
||||||
f.BusinessName,
|
f.BusinessName,
|
||||||
f.VATIN,
|
f.VATIN,
|
||||||
|
@ -302,6 +302,7 @@ func editTaxDetails(w http.ResponseWriter, r *http.Request, user *auth.User, com
|
||||||
f.LegalDisclaimer,
|
f.LegalDisclaimer,
|
||||||
f.RTCNumber,
|
f.RTCNumber,
|
||||||
f.TouristTax,
|
f.TouristTax,
|
||||||
|
company.DecimalDigits,
|
||||||
company.ID)
|
company.ID)
|
||||||
httplib.Redirect(w, r, "/admin/company", http.StatusSeeOther)
|
httplib.Redirect(w, r, "/admin/company", http.StatusSeeOther)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
@ -16,6 +17,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/text/language"
|
||||||
|
"golang.org/x/text/message"
|
||||||
|
"golang.org/x/text/number"
|
||||||
|
|
||||||
"dev.tandem.ws/tandem/camper/pkg/auth"
|
"dev.tandem.ws/tandem/camper/pkg/auth"
|
||||||
httplib "dev.tandem.ws/tandem/camper/pkg/http"
|
httplib "dev.tandem.ws/tandem/camper/pkg/http"
|
||||||
)
|
)
|
||||||
|
@ -91,6 +96,9 @@ func mustRenderLayout(w io.Writer, user *auth.User, company *auth.Company, templ
|
||||||
"humanizeBytes": func(bytes int64) string {
|
"humanizeBytes": func(bytes int64) string {
|
||||||
return humanizeBytes(bytes)
|
return humanizeBytes(bytes)
|
||||||
},
|
},
|
||||||
|
"formatPrice": func(price string) string {
|
||||||
|
return formatPrice(price, user.Locale.Language, user.Locale.CurrencyPattern, company.DecimalDigits, company.CurrencySymbol)
|
||||||
|
},
|
||||||
"queryEscape": func(s string) string {
|
"queryEscape": func(s string) string {
|
||||||
return url.QueryEscape(s)
|
return url.QueryEscape(s)
|
||||||
},
|
},
|
||||||
|
@ -136,3 +144,12 @@ func mustRenderLayout(w io.Writer, user *auth.User, company *auth.Company, templ
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func formatPrice(price string, language language.Tag, currencyPattern string, decimalDigits int, currencySymbol string) string {
|
||||||
|
p := message.NewPrinter(language)
|
||||||
|
f, err := strconv.ParseFloat(price, 64)
|
||||||
|
if err != nil {
|
||||||
|
f = math.NaN()
|
||||||
|
}
|
||||||
|
return p.Sprintf(currencyPattern, decimalDigits, number.Decimal(f), currencySymbol)
|
||||||
|
}
|
||||||
|
|
28
po/ca.po
28
po/ca.po
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: camper\n"
|
"Project-Id-Version: camper\n"
|
||||||
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
|
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
|
||||||
"POT-Creation-Date: 2024-01-15 01:00+0100\n"
|
"POT-Creation-Date: 2024-01-15 01:40+0100\n"
|
||||||
"PO-Revision-Date: 2023-07-22 23:45+0200\n"
|
"PO-Revision-Date: 2023-07-22 23:45+0200\n"
|
||||||
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
|
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
|
||||||
"Language-Team: Catalan <ca@dodds.net>\n"
|
"Language-Team: Catalan <ca@dodds.net>\n"
|
||||||
|
@ -150,46 +150,54 @@ msgstr "%s €/nit"
|
||||||
msgid "*Minimum %d nights per stay"
|
msgid "*Minimum %d nights per stay"
|
||||||
msgstr "*Mínim %d nits per estada"
|
msgstr "*Mínim %d nits per estada"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:105
|
#: web/templates/public/campsite/type.gohtml:99
|
||||||
|
msgid "10 % VAT included."
|
||||||
|
msgstr "IVA del 10 % inclòs."
|
||||||
|
|
||||||
|
#: web/templates/public/campsite/type.gohtml:100
|
||||||
|
msgid "Tourist tax: %s per person aged 16 or over."
|
||||||
|
msgstr "Impost turístic: %s per persona de 16 anys o més."
|
||||||
|
|
||||||
|
#: web/templates/public/campsite/type.gohtml:107
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Features"
|
msgid "Features"
|
||||||
msgstr "Característiques"
|
msgstr "Característiques"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:116
|
#: web/templates/public/campsite/type.gohtml:118
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Info"
|
msgid "Info"
|
||||||
msgstr "Informació"
|
msgstr "Informació"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:120
|
#: web/templates/public/campsite/type.gohtml:122
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Facilities"
|
msgid "Facilities"
|
||||||
msgstr "Equipaments"
|
msgstr "Equipaments"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:124
|
#: web/templates/public/campsite/type.gohtml:126
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Description"
|
msgid "Description"
|
||||||
msgstr "Descripció"
|
msgstr "Descripció"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:128
|
#: web/templates/public/campsite/type.gohtml:130
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Additional Information"
|
msgid "Additional Information"
|
||||||
msgstr "Informació addicional"
|
msgstr "Informació addicional"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:131
|
#: web/templates/public/campsite/type.gohtml:133
|
||||||
msgctxt "time"
|
msgctxt "time"
|
||||||
msgid "Check in"
|
msgid "Check in"
|
||||||
msgstr "Entrada"
|
msgstr "Entrada"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:132
|
#: web/templates/public/campsite/type.gohtml:134
|
||||||
msgid "4 p.m. to 9 p.m."
|
msgid "4 p.m. to 9 p.m."
|
||||||
msgstr "16 h a 21 h"
|
msgstr "16 h a 21 h"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:135
|
#: web/templates/public/campsite/type.gohtml:137
|
||||||
msgctxt "time"
|
msgctxt "time"
|
||||||
msgid "Check out"
|
msgid "Check out"
|
||||||
msgstr "Sortida"
|
msgstr "Sortida"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:136
|
#: web/templates/public/campsite/type.gohtml:138
|
||||||
msgid "10 a.m."
|
msgid "10 a.m."
|
||||||
msgstr "10 h"
|
msgstr "10 h"
|
||||||
|
|
||||||
|
|
28
po/es.po
28
po/es.po
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: camper\n"
|
"Project-Id-Version: camper\n"
|
||||||
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
|
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
|
||||||
"POT-Creation-Date: 2024-01-15 01:00+0100\n"
|
"POT-Creation-Date: 2024-01-15 01:40+0100\n"
|
||||||
"PO-Revision-Date: 2023-07-22 23:46+0200\n"
|
"PO-Revision-Date: 2023-07-22 23:46+0200\n"
|
||||||
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
|
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
|
||||||
"Language-Team: Spanish <es@tp.org.es>\n"
|
"Language-Team: Spanish <es@tp.org.es>\n"
|
||||||
|
@ -150,46 +150,54 @@ msgstr "%s €/noche"
|
||||||
msgid "*Minimum %d nights per stay"
|
msgid "*Minimum %d nights per stay"
|
||||||
msgstr "*Mínimo %d noches por estancia"
|
msgstr "*Mínimo %d noches por estancia"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:105
|
#: web/templates/public/campsite/type.gohtml:99
|
||||||
|
msgid "10 % VAT included."
|
||||||
|
msgstr "IVA del 10 % incluido."
|
||||||
|
|
||||||
|
#: web/templates/public/campsite/type.gohtml:100
|
||||||
|
msgid "Tourist tax: %s per person aged 16 or over."
|
||||||
|
msgstr "Impuesto turístico: %s por persona de 16 años en adelante."
|
||||||
|
|
||||||
|
#: web/templates/public/campsite/type.gohtml:107
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Features"
|
msgid "Features"
|
||||||
msgstr "Características"
|
msgstr "Características"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:116
|
#: web/templates/public/campsite/type.gohtml:118
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Info"
|
msgid "Info"
|
||||||
msgstr "Información"
|
msgstr "Información"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:120
|
#: web/templates/public/campsite/type.gohtml:122
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Facilities"
|
msgid "Facilities"
|
||||||
msgstr "Equipamiento"
|
msgstr "Equipamiento"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:124
|
#: web/templates/public/campsite/type.gohtml:126
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Description"
|
msgid "Description"
|
||||||
msgstr "Descripción"
|
msgstr "Descripción"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:128
|
#: web/templates/public/campsite/type.gohtml:130
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Additional Information"
|
msgid "Additional Information"
|
||||||
msgstr "Información adicional"
|
msgstr "Información adicional"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:131
|
#: web/templates/public/campsite/type.gohtml:133
|
||||||
msgctxt "time"
|
msgctxt "time"
|
||||||
msgid "Check in"
|
msgid "Check in"
|
||||||
msgstr "Entrada"
|
msgstr "Entrada"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:132
|
#: web/templates/public/campsite/type.gohtml:134
|
||||||
msgid "4 p.m. to 9 p.m."
|
msgid "4 p.m. to 9 p.m."
|
||||||
msgstr "16 h a 21 h"
|
msgstr "16 h a 21 h"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:135
|
#: web/templates/public/campsite/type.gohtml:137
|
||||||
msgctxt "time"
|
msgctxt "time"
|
||||||
msgid "Check out"
|
msgid "Check out"
|
||||||
msgstr "Salida"
|
msgstr "Salida"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:136
|
#: web/templates/public/campsite/type.gohtml:138
|
||||||
msgid "10 a.m."
|
msgid "10 a.m."
|
||||||
msgstr "10 h"
|
msgstr "10 h"
|
||||||
|
|
||||||
|
|
28
po/fr.po
28
po/fr.po
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: camper\n"
|
"Project-Id-Version: camper\n"
|
||||||
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
|
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
|
||||||
"POT-Creation-Date: 2024-01-15 01:00+0100\n"
|
"POT-Creation-Date: 2024-01-15 01:40+0100\n"
|
||||||
"PO-Revision-Date: 2023-12-20 10:13+0100\n"
|
"PO-Revision-Date: 2023-12-20 10:13+0100\n"
|
||||||
"Last-Translator: Oriol Carbonell <info@oriolcarbonell.cat>\n"
|
"Last-Translator: Oriol Carbonell <info@oriolcarbonell.cat>\n"
|
||||||
"Language-Team: French <traduc@traduc.org>\n"
|
"Language-Team: French <traduc@traduc.org>\n"
|
||||||
|
@ -151,46 +151,54 @@ msgstr "%s €/nuit"
|
||||||
msgid "*Minimum %d nights per stay"
|
msgid "*Minimum %d nights per stay"
|
||||||
msgstr "*Minimum %d nuits par séjour"
|
msgstr "*Minimum %d nuits par séjour"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:105
|
#: web/templates/public/campsite/type.gohtml:99
|
||||||
|
msgid "10 % VAT included."
|
||||||
|
msgstr "10 % TVA incluse."
|
||||||
|
|
||||||
|
#: web/templates/public/campsite/type.gohtml:100
|
||||||
|
msgid "Tourist tax: %s per person aged 16 or over."
|
||||||
|
msgstr "Taxe touristique: %s par personne de 16 ans ou plus."
|
||||||
|
|
||||||
|
#: web/templates/public/campsite/type.gohtml:107
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Features"
|
msgid "Features"
|
||||||
msgstr "Caractéristiques"
|
msgstr "Caractéristiques"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:116
|
#: web/templates/public/campsite/type.gohtml:118
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Info"
|
msgid "Info"
|
||||||
msgstr "Info"
|
msgstr "Info"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:120
|
#: web/templates/public/campsite/type.gohtml:122
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Facilities"
|
msgid "Facilities"
|
||||||
msgstr "Installations"
|
msgstr "Installations"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:124
|
#: web/templates/public/campsite/type.gohtml:126
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Description"
|
msgid "Description"
|
||||||
msgstr "Description"
|
msgstr "Description"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:128
|
#: web/templates/public/campsite/type.gohtml:130
|
||||||
msgctxt "title"
|
msgctxt "title"
|
||||||
msgid "Additional Information"
|
msgid "Additional Information"
|
||||||
msgstr "Informations Complémentaires"
|
msgstr "Informations Complémentaires"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:131
|
#: web/templates/public/campsite/type.gohtml:133
|
||||||
msgctxt "time"
|
msgctxt "time"
|
||||||
msgid "Check in"
|
msgid "Check in"
|
||||||
msgstr "Arrivée"
|
msgstr "Arrivée"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:132
|
#: web/templates/public/campsite/type.gohtml:134
|
||||||
msgid "4 p.m. to 9 p.m."
|
msgid "4 p.m. to 9 p.m."
|
||||||
msgstr "16 h à 21 h"
|
msgstr "16 h à 21 h"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:135
|
#: web/templates/public/campsite/type.gohtml:137
|
||||||
msgctxt "time"
|
msgctxt "time"
|
||||||
msgid "Check out"
|
msgid "Check out"
|
||||||
msgstr "Départ"
|
msgstr "Départ"
|
||||||
|
|
||||||
#: web/templates/public/campsite/type.gohtml:136
|
#: web/templates/public/campsite/type.gohtml:138
|
||||||
msgid "10 a.m."
|
msgid "10 a.m."
|
||||||
msgstr "10 h"
|
msgstr "10 h"
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ p, h1, h2, h3, h4, h5, h6 {
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
p + p {
|
p + p, dl + p {
|
||||||
margin-top: 1.5em;
|
margin-top: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,8 @@
|
||||||
</div>
|
</div>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</dl>
|
</dl>
|
||||||
|
<p>{{( gettext "10 % VAT included." )}}</p>
|
||||||
|
<p>{{printf (gettext "Tourist tax: %s per person aged 16 or over.") (formatPrice $.TouristTax)}}</p>
|
||||||
</article>
|
</article>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue