Add a new payments “subsection” for expenses

With Oriol we agreed that to add new payments to expenses we should
direct users to a separate payments section, much like the general
payments but centered around the payments of the given expense.

In fact, the only thing i had to do is extract the expense from the
URL, and then adjust the base URI to keep things always within the
correct section; the rest of the code is shared with the general
section.
This commit is contained in:
jordi fita mas 2024-08-17 05:31:01 +02:00
parent eb880fed36
commit 4f646e35d6
8 changed files with 313 additions and 91 deletions

View File

@ -19,13 +19,39 @@ func servePaymentIndex(w http.ResponseWriter, r *http.Request, _ httprouter.Para
page.MustRender(w, r) page.MustRender(w, r)
} }
func serveExpensePaymentIndex(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
expenseSlug := params[0].Value
conn := getConn(r)
company := mustGetCompany(r)
locale := getLocale(r)
expense := mustGetPaymentExpense(r.Context(), conn, expenseSlug)
if expense == nil {
http.NotFound(w, r)
return
}
page := NewPaymentIndexPageForExpense(r.Context(), conn, company, locale, expense)
page.MustRender(w, r)
}
type PaymentIndexPage struct { type PaymentIndexPage struct {
Payments []*PaymentEntry Payments []*PaymentEntry
BaseURI string
Expense *PaymentExpense
} }
func NewPaymentIndexPage(ctx context.Context, conn *Conn, company *Company, locale *Locale) *PaymentIndexPage { func NewPaymentIndexPage(ctx context.Context, conn *Conn, company *Company, locale *Locale) *PaymentIndexPage {
return &PaymentIndexPage{ return &PaymentIndexPage{
Payments: mustCollectPaymentEntries(ctx, conn, company, locale), Payments: mustCollectPaymentEntries(ctx, conn, company, locale, 0),
BaseURI: companyURI(company, "/payments"),
}
}
func NewPaymentIndexPageForExpense(ctx context.Context, conn *Conn, company *Company, locale *Locale, expense *PaymentExpense) *PaymentIndexPage {
return &PaymentIndexPage{
Payments: mustCollectPaymentEntries(ctx, conn, company, locale, expense.Id),
BaseURI: companyURI(company, "/expenses/"+expense.Slug+"/payments"),
Expense: expense,
} }
} }
@ -33,6 +59,56 @@ func (page *PaymentIndexPage) MustRender(w http.ResponseWriter, r *http.Request)
mustRenderMainTemplate(w, r, "payments/index.gohtml", page) mustRenderMainTemplate(w, r, "payments/index.gohtml", page)
} }
type PaymentExpense struct {
Id int
Slug string
InvoiceNumber string
}
func mustGetPaymentExpense(ctx context.Context, conn *Conn, expenseSlug string) *PaymentExpense {
if !ValidUuid(expenseSlug) {
return nil
}
expense := &PaymentExpense{}
if notFoundErrorOrPanic(conn.QueryRow(ctx, `
select expense_id
, slug
, coalesce(nullif(invoice_number, ''), slug::text)
from expense
where expense.slug = $1
`, expenseSlug).Scan(
&expense.Id,
&expense.Slug,
&expense.InvoiceNumber)) {
return nil
}
return expense
}
func (expense *PaymentExpense) calcRemainingPaymentAmount(ctx context.Context, conn *Conn) string {
return conn.MustGetText(ctx, "", `
select to_price(greatest(0, expense.amount + tax_amount - paid_amount)::int, decimal_digits)
from (
select coalesce (sum(payment.amount), 0) as paid_amount
from expense_payment
join payment using (payment_id)
where expense_payment.expense_id = $1
) as payment
cross join (
select coalesce (sum(amount), 0) as tax_amount
from expense_tax_amount
where expense_id = $1
) as tax
cross join (
select amount, decimal_digits
from expense
join currency using (currency_code)
where expense_id = $1
) as expense
`, expense.Id)
}
type PaymentEntry struct { type PaymentEntry struct {
ID int ID int
Slug string Slug string
@ -47,7 +123,7 @@ type PaymentEntry struct {
StatusLabel string StatusLabel string
} }
func mustCollectPaymentEntries(ctx context.Context, conn *Conn, company *Company, locale *Locale) []*PaymentEntry { func mustCollectPaymentEntries(ctx context.Context, conn *Conn, company *Company, locale *Locale, expenseId int) []*PaymentEntry {
rows := conn.MustQuery(ctx, ` rows := conn.MustQuery(ctx, `
select payment_id select payment_id
, payment.slug , payment.slug
@ -67,8 +143,9 @@ func mustCollectPaymentEntries(ctx context.Context, conn *Conn, company *Company
left join expense_payment using (payment_id) left join expense_payment using (payment_id)
left join expense using (expense_id) left join expense using (expense_id)
where payment.company_id = $2 where payment.company_id = $2
and ($3 = 0 or expense_id = $3)
order by payment_date desc, total desc order by payment_date desc, total desc
`, locale.Language, company.Id) `, locale.Language, company.Id, expenseId)
defer rows.Close() defer rows.Close()
var entries []*PaymentEntry var entries []*PaymentEntry
@ -108,10 +185,42 @@ func servePaymentForm(w http.ResponseWriter, r *http.Request, params httprouter.
form.MustRender(w, r) form.MustRender(w, r)
} }
func serveExpensePaymentForm(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
locale := getLocale(r)
conn := getConn(r)
company := mustGetCompany(r)
expenseSlug := params[0].Value
expense := mustGetPaymentExpense(r.Context(), conn, expenseSlug)
if expense == nil {
http.NotFound(w, r)
return
}
form := newPaymentFormForExpense(r.Context(), conn, locale, company, expense)
paymentSlug := params[1].Value
if paymentSlug == "new" {
form.PaymentDate.Val = time.Now().Format("2006-01-02")
form.Description.Val = fmt.Sprintf(gettext("Payment of %s", locale), form.Expense.InvoiceNumber)
form.Amount.Val = form.Expense.calcRemainingPaymentAmount(r.Context(), conn)
form.MustRender(w, r)
return
}
if !ValidUuid(paymentSlug) {
http.NotFound(w, r)
return
}
if !form.MustFillFromDatabase(r.Context(), conn, paymentSlug) {
http.NotFound(w, r)
return
}
form.MustRender(w, r)
}
type PaymentForm struct { type PaymentForm struct {
locale *Locale locale *Locale
company *Company company *Company
Slug string Slug string
BaseURI string
Expense *PaymentExpense
Description *InputField Description *InputField
PaymentDate *InputField PaymentDate *InputField
PaymentAccount *SelectField PaymentAccount *SelectField
@ -124,6 +233,7 @@ func newPaymentForm(ctx context.Context, conn *Conn, locale *Locale, company *Co
return &PaymentForm{ return &PaymentForm{
locale: locale, locale: locale,
company: company, company: company,
BaseURI: companyURI(company, "/payments"),
Description: &InputField{ Description: &InputField{
Name: "description", Name: "description",
Label: pgettext("input", "Description", locale), Label: pgettext("input", "Description", locale),
@ -164,6 +274,13 @@ func newPaymentForm(ctx context.Context, conn *Conn, locale *Locale, company *Co
} }
} }
func newPaymentFormForExpense(ctx context.Context, conn *Conn, locale *Locale, company *Company, expense *PaymentExpense) *PaymentForm {
form := newPaymentForm(ctx, conn, locale, company)
form.BaseURI = companyURI(company, "/expenses/"+expense.Slug+"/payments")
form.Expense = expense
return form
}
func (f *PaymentForm) MustRender(w http.ResponseWriter, r *http.Request) { func (f *PaymentForm) MustRender(w http.ResponseWriter, r *http.Request) {
if f.Slug == "" { if f.Slug == "" {
f.PaymentAccount.EmptyLabel = gettext("Select an account.", f.locale) f.PaymentAccount.EmptyLabel = gettext("Select an account.", f.locale)
@ -229,6 +346,10 @@ func handleAddPayment(w http.ResponseWriter, r *http.Request, _ httprouter.Param
conn := getConn(r) conn := getConn(r)
company := mustGetCompany(r) company := mustGetCompany(r)
form := newPaymentForm(r.Context(), conn, locale, company) form := newPaymentForm(r.Context(), conn, locale, company)
handleAddPaymentForm(w, r, conn, company, form)
}
func handleAddPaymentForm(w http.ResponseWriter, r *http.Request, conn *Conn, company *Company, form *PaymentForm) {
if err := form.Parse(r); err != nil { if err := form.Parse(r); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return
@ -244,11 +365,30 @@ func handleAddPayment(w http.ResponseWriter, r *http.Request, _ httprouter.Param
form.MustRender(w, r) form.MustRender(w, r)
return return
} }
slug := conn.MustGetText(r.Context(), "", "select add_payment($1, $2, $3, $4, $5, $6, $7)", company.Id, nil, form.PaymentDate, form.PaymentAccount, form.Description, form.Amount, form.Tags) var paymentSlug any
if form.Expense != nil {
paymentSlug = form.Expense.Id
}
slug := conn.MustGetText(r.Context(), "", "select add_payment($1, $2, $3, $4, $5, $6, $7)", company.Id, paymentSlug, form.PaymentDate, form.PaymentAccount, form.Description, form.Amount, form.Tags)
if len(form.File.Content) > 0 { if len(form.File.Content) > 0 {
conn.MustQuery(r.Context(), "select attach_to_payment($1, $2, $3, $4)", slug, form.File.OriginalFileName, form.File.ContentType, form.File.Content) conn.MustQuery(r.Context(), "select attach_to_payment($1, $2, $3, $4)", slug, form.File.OriginalFileName, form.File.ContentType, form.File.Content)
} }
htmxRedirect(w, r, companyURI(company, "/payments")) htmxRedirect(w, r, form.BaseURI)
}
func handleAddExpensePayment(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
expenseSlug := params[0].Value
locale := getLocale(r)
conn := getConn(r)
company := mustGetCompany(r)
expense := mustGetPaymentExpense(r.Context(), conn, expenseSlug)
if expense == nil {
http.NotFound(w, r)
return
}
form := newPaymentFormForExpense(r.Context(), conn, locale, company, expense)
handleAddPaymentForm(w, r, conn, company, form)
} }
func handleEditPayment(w http.ResponseWriter, r *http.Request, params httprouter.Params) { func handleEditPayment(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
@ -257,6 +397,10 @@ func handleEditPayment(w http.ResponseWriter, r *http.Request, params httprouter
company := mustGetCompany(r) company := mustGetCompany(r)
form := newPaymentForm(r.Context(), conn, locale, company) form := newPaymentForm(r.Context(), conn, locale, company)
form.Slug = params[0].Value form.Slug = params[0].Value
handleEditPaymentForm(w, r, conn, form)
}
func handleEditPaymentForm(w http.ResponseWriter, r *http.Request, conn *Conn, form *PaymentForm) {
if !ValidUuid(form.Slug) { if !ValidUuid(form.Slug) {
http.NotFound(w, r) http.NotFound(w, r)
return return
@ -283,16 +427,35 @@ func handleEditPayment(w http.ResponseWriter, r *http.Request, params httprouter
if len(form.File.Content) > 0 { if len(form.File.Content) > 0 {
conn.MustQuery(r.Context(), "select attach_to_payment($1, $2, $3, $4)", form.Slug, form.File.OriginalFileName, form.File.ContentType, form.File.Content) conn.MustQuery(r.Context(), "select attach_to_payment($1, $2, $3, $4)", form.Slug, form.File.OriginalFileName, form.File.ContentType, form.File.Content)
} }
htmxRedirect(w, r, companyURI(company, "/payments")) htmxRedirect(w, r, form.BaseURI)
} }
func handleRemovePayment(w http.ResponseWriter, r *http.Request, params httprouter.Params) { func handleEditExpensePayment(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
slug := params[0].Value conn := getConn(r)
if !ValidUuid(slug) { locale := getLocale(r)
company := mustGetCompany(r)
expenseSlug := params[0].Value
expense := mustGetPaymentExpense(r.Context(), conn, expenseSlug)
if expense == nil {
http.NotFound(w, r) http.NotFound(w, r)
return return
} }
form := newPaymentFormForExpense(r.Context(), conn, locale, company, expense)
form.Slug = params[1].Value
handleEditPaymentForm(w, r, conn, form)
}
func handleRemovePayment(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
company := mustGetCompany(r)
removePayment(w, r, params[0].Value, companyURI(company, "/payments"))
}
func removePayment(w http.ResponseWriter, r *http.Request, slug string, backURI string) {
if !ValidUuid(slug) {
http.NotFound(w, r)
return
}
if err := verifyCsrfTokenValid(r); err != nil { if err := verifyCsrfTokenValid(r); err != nil {
http.Error(w, err.Error(), http.StatusForbidden) http.Error(w, err.Error(), http.StatusForbidden)
return return
@ -301,8 +464,20 @@ func handleRemovePayment(w http.ResponseWriter, r *http.Request, params httprout
conn := getConn(r) conn := getConn(r)
conn.MustExec(r.Context(), "select remove_payment($1)", slug) conn.MustExec(r.Context(), "select remove_payment($1)", slug)
htmxRedirect(w, r, backURI)
}
func handleRemoveExpensePayment(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
conn := getConn(r)
expenseSlug := params[0].Value
expense := mustGetPaymentExpense(r.Context(), conn, expenseSlug)
if expense == nil {
http.NotFound(w, r)
return
}
company := mustGetCompany(r) company := mustGetCompany(r)
htmxRedirect(w, r, companyURI(company, "/payments")) removePayment(w, r, params[1].Value, companyURI(company, "/expenses/"+expense.Slug+"/payments"))
} }
func servePaymentAttachment(w http.ResponseWriter, r *http.Request, params httprouter.Params) { func servePaymentAttachment(w http.ResponseWriter, r *http.Request, params httprouter.Params) {

View File

@ -62,6 +62,11 @@ func NewRouter(db *Db, demo bool) http.Handler {
companyRouter.PUT("/expenses/:slug/tags", HandleUpdateExpenseTags) companyRouter.PUT("/expenses/:slug/tags", HandleUpdateExpenseTags)
companyRouter.GET("/expenses/:slug/tags/edit", ServeEditExpenseTags) companyRouter.GET("/expenses/:slug/tags/edit", ServeEditExpenseTags)
companyRouter.GET("/expenses/:slug/download/:filename", ServeExpenseAttachment) companyRouter.GET("/expenses/:slug/download/:filename", ServeExpenseAttachment)
companyRouter.GET("/expenses/:slug/payments", serveExpensePaymentIndex)
companyRouter.POST("/expenses/:slug/payments", handleAddExpensePayment)
companyRouter.GET("/expenses/:slug/payments/:slug", serveExpensePaymentForm)
companyRouter.PUT("/expenses/:slug/payments/:slug", handleEditExpensePayment)
companyRouter.DELETE("/expenses/:slug/payments/:slug", handleRemoveExpensePayment)
companyRouter.GET("/payments", servePaymentIndex) companyRouter.GET("/payments", servePaymentIndex)
companyRouter.POST("/payments", handleAddPayment) companyRouter.POST("/payments", handleAddPayment)
companyRouter.GET("/payments/:slug", servePaymentForm) companyRouter.GET("/payments/:slug", servePaymentForm)

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: numerus\n" "Project-Id-Version: numerus\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-08-16 01:57+0200\n" "POT-Creation-Date: 2024-08-17 05:26+0200\n"
"PO-Revision-Date: 2023-01-18 17:08+0100\n" "PO-Revision-Date: 2023-01-18 17:08+0100\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"
@ -116,7 +116,7 @@ msgstr "Subtotal"
#: web/template/quotes/new.gohtml:74 web/template/quotes/view.gohtml:82 #: web/template/quotes/new.gohtml:74 web/template/quotes/view.gohtml:82
#: web/template/quotes/view.gohtml:122 web/template/quotes/edit.gohtml:75 #: web/template/quotes/view.gohtml:122 web/template/quotes/edit.gohtml:75
#: web/template/expenses/new.gohtml:46 web/template/expenses/index.gohtml:74 #: web/template/expenses/new.gohtml:46 web/template/expenses/index.gohtml:74
#: web/template/expenses/edit.gohtml:48 web/template/payments/index.gohtml:30 #: web/template/expenses/edit.gohtml:48 web/template/payments/index.gohtml:34
msgctxt "title" msgctxt "title"
msgid "Total" msgid "Total"
msgstr "Total" msgstr "Total"
@ -124,7 +124,7 @@ msgstr "Total"
#: web/template/invoices/new.gohtml:92 web/template/invoices/edit.gohtml:93 #: web/template/invoices/new.gohtml:92 web/template/invoices/edit.gohtml:93
#: web/template/quotes/new.gohtml:92 web/template/quotes/edit.gohtml:93 #: web/template/quotes/new.gohtml:92 web/template/quotes/edit.gohtml:93
#: web/template/expenses/new.gohtml:56 web/template/expenses/edit.gohtml:58 #: web/template/expenses/new.gohtml:56 web/template/expenses/edit.gohtml:58
#: web/template/payments/edit.gohtml:37 #: web/template/payments/edit.gohtml:41
#: web/template/payments/accounts/edit.gohtml:38 #: web/template/payments/accounts/edit.gohtml:38
msgctxt "action" msgctxt "action"
msgid "Update" msgid "Update"
@ -135,7 +135,7 @@ msgstr "Actualitza"
#: web/template/contacts/new.gohtml:49 web/template/contacts/edit.gohtml:53 #: web/template/contacts/new.gohtml:49 web/template/contacts/edit.gohtml:53
#: web/template/expenses/new.gohtml:59 web/template/expenses/edit.gohtml:61 #: web/template/expenses/new.gohtml:59 web/template/expenses/edit.gohtml:61
#: web/template/products/new.gohtml:30 web/template/products/edit.gohtml:36 #: web/template/products/new.gohtml:30 web/template/products/edit.gohtml:36
#: web/template/payments/new.gohtml:35 #: web/template/payments/new.gohtml:39
#: web/template/payments/accounts/new.gohtml:41 #: web/template/payments/accounts/new.gohtml:41
msgctxt "action" msgctxt "action"
msgid "Save" msgid "Save"
@ -193,14 +193,14 @@ msgid "Customer"
msgstr "Client" msgstr "Client"
#: web/template/invoices/index.gohtml:70 web/template/quotes/index.gohtml:70 #: web/template/invoices/index.gohtml:70 web/template/quotes/index.gohtml:70
#: web/template/expenses/index.gohtml:68 web/template/payments/index.gohtml:28 #: web/template/expenses/index.gohtml:68 web/template/payments/index.gohtml:32
msgctxt "title" msgctxt "title"
msgid "Status" msgid "Status"
msgstr "Estat" msgstr "Estat"
#: web/template/invoices/index.gohtml:71 web/template/quotes/index.gohtml:71 #: web/template/invoices/index.gohtml:71 web/template/quotes/index.gohtml:71
#: web/template/contacts/index.gohtml:50 web/template/expenses/index.gohtml:69 #: web/template/contacts/index.gohtml:50 web/template/expenses/index.gohtml:69
#: web/template/products/index.gohtml:46 web/template/payments/index.gohtml:29 #: web/template/products/index.gohtml:46 web/template/payments/index.gohtml:33
msgctxt "title" msgctxt "title"
msgid "Tags" msgid "Tags"
msgstr "Etiquetes" msgstr "Etiquetes"
@ -212,7 +212,7 @@ msgid "Amount"
msgstr "Import" msgstr "Import"
#: web/template/invoices/index.gohtml:73 web/template/quotes/index.gohtml:73 #: web/template/invoices/index.gohtml:73 web/template/quotes/index.gohtml:73
#: web/template/expenses/index.gohtml:75 web/template/payments/index.gohtml:31 #: web/template/expenses/index.gohtml:75 web/template/payments/index.gohtml:35
msgctxt "title" msgctxt "title"
msgid "Download" msgid "Download"
msgstr "Descàrrega" msgstr "Descàrrega"
@ -220,7 +220,7 @@ msgstr "Descàrrega"
#: web/template/invoices/index.gohtml:74 web/template/quotes/index.gohtml:74 #: web/template/invoices/index.gohtml:74 web/template/quotes/index.gohtml:74
#: web/template/contacts/index.gohtml:51 web/template/expenses/index.gohtml:76 #: web/template/contacts/index.gohtml:51 web/template/expenses/index.gohtml:76
#: web/template/company/switch.gohtml:23 web/template/products/index.gohtml:48 #: web/template/company/switch.gohtml:23 web/template/products/index.gohtml:48
#: web/template/payments/index.gohtml:32 #: web/template/payments/index.gohtml:36
msgctxt "title" msgctxt "title"
msgid "Actions" msgid "Actions"
msgstr "Accions" msgstr "Accions"
@ -242,7 +242,7 @@ msgstr "Accions per la factura %s"
#: web/template/invoices/index.gohtml:139 web/template/invoices/view.gohtml:19 #: web/template/invoices/index.gohtml:139 web/template/invoices/view.gohtml:19
#: web/template/quotes/index.gohtml:137 web/template/quotes/view.gohtml:22 #: web/template/quotes/index.gohtml:137 web/template/quotes/view.gohtml:22
#: web/template/contacts/index.gohtml:82 web/template/expenses/index.gohtml:125 #: web/template/contacts/index.gohtml:82 web/template/expenses/index.gohtml:125
#: web/template/products/index.gohtml:78 web/template/payments/index.gohtml:77 #: web/template/products/index.gohtml:78 web/template/payments/index.gohtml:81
msgctxt "action" msgctxt "action"
msgid "Edit" msgid "Edit"
msgstr "Edita" msgstr "Edita"
@ -258,7 +258,7 @@ msgid "No invoices added yet."
msgstr "No hi ha cap factura." msgstr "No hi ha cap factura."
#: web/template/invoices/index.gohtml:164 web/template/quotes/index.gohtml:170 #: web/template/invoices/index.gohtml:164 web/template/quotes/index.gohtml:170
#: web/template/expenses/index.gohtml:142 #: web/template/expenses/index.gohtml:148
msgid "Total" msgid "Total"
msgstr "Total" msgstr "Total"
@ -633,6 +633,8 @@ msgstr "Nova despesa"
#: web/template/expenses/new.gohtml:11 web/template/expenses/index.gohtml:3 #: web/template/expenses/new.gohtml:11 web/template/expenses/index.gohtml:3
#: web/template/expenses/index.gohtml:11 web/template/expenses/edit.gohtml:11 #: web/template/expenses/index.gohtml:11 web/template/expenses/edit.gohtml:11
#: web/template/payments/new.gohtml:12 web/template/payments/index.gohtml:12
#: web/template/payments/edit.gohtml:12
msgctxt "title" msgctxt "title"
msgid "Expenses" msgid "Expenses"
msgstr "Despeses" msgstr "Despeses"
@ -656,7 +658,12 @@ msgstr "Número de factura"
msgid "Actions for expense %s" msgid "Actions for expense %s"
msgstr "Accions per la despesa %s" msgstr "Accions per la despesa %s"
#: web/template/expenses/index.gohtml:135 #: web/template/expenses/index.gohtml:131
msgctxt "action"
msgid "Payments"
msgstr "Pagaments"
#: web/template/expenses/index.gohtml:141
msgid "No expenses added yet." msgid "No expenses added yet."
msgstr "No hi ha cap despesa." msgstr "No hi ha cap despesa."
@ -768,51 +775,51 @@ msgctxt "title"
msgid "Edit Product “%s”" msgid "Edit Product “%s”"
msgstr "Edició del producte «%s»" msgstr "Edició del producte «%s»"
#: web/template/payments/new.gohtml:3 web/template/payments/new.gohtml:12 #: web/template/payments/new.gohtml:3 web/template/payments/new.gohtml:16
msgctxt "title" msgctxt "title"
msgid "New Payment" msgid "New Payment"
msgstr "Nou pagament" msgstr "Nou pagament"
#: web/template/payments/new.gohtml:11 web/template/payments/index.gohtml:3 #: web/template/payments/new.gohtml:15 web/template/payments/index.gohtml:3
#: web/template/payments/index.gohtml:11 web/template/payments/edit.gohtml:11 #: web/template/payments/index.gohtml:15 web/template/payments/edit.gohtml:15
msgctxt "title" msgctxt "title"
msgid "Payments" msgid "Payments"
msgstr "Pagaments" msgstr "Pagaments"
#: web/template/payments/index.gohtml:16 #: web/template/payments/index.gohtml:20
msgctxt "action" msgctxt "action"
msgid "New payment" msgid "New payment"
msgstr "Nou pagament" msgstr "Nou pagament"
#: web/template/payments/index.gohtml:25 #: web/template/payments/index.gohtml:29
msgctxt "title" msgctxt "title"
msgid "Payment Date" msgid "Payment Date"
msgstr "Data del pagament" msgstr "Data del pagament"
#: web/template/payments/index.gohtml:26 #: web/template/payments/index.gohtml:30
msgctxt "title" msgctxt "title"
msgid "Description" msgid "Description"
msgstr "Descripció" msgstr "Descripció"
#: web/template/payments/index.gohtml:27 #: web/template/payments/index.gohtml:31
msgctxt "title" msgctxt "title"
msgid "Document" msgid "Document"
msgstr "Document" msgstr "Document"
#: web/template/payments/index.gohtml:37 #: web/template/payments/index.gohtml:41
msgid "Are you sure you wish to delete this payment?" msgid "Are you sure you wish to delete this payment?"
msgstr "Esteu segur de voler esborrar aquest pagament?" msgstr "Esteu segur de voler esborrar aquest pagament?"
#: web/template/payments/index.gohtml:69 #: web/template/payments/index.gohtml:73
msgid "Actions for payment %s" msgid "Actions for payment %s"
msgstr "Accions pel pagament %s" msgstr "Accions pel pagament %s"
#: web/template/payments/index.gohtml:88 #: web/template/payments/index.gohtml:92
msgctxt "action" msgctxt "action"
msgid "Remove" msgid "Remove"
msgstr "Esborra" msgstr "Esborra"
#: web/template/payments/index.gohtml:98 #: web/template/payments/index.gohtml:102
msgid "No payments added yet." msgid "No payments added yet."
msgstr "No hi ha cap pagament." msgstr "No hi ha cap pagament."
@ -894,7 +901,7 @@ msgid "Name"
msgstr "Nom" msgstr "Nom"
#: pkg/products.go:177 pkg/products.go:303 pkg/tags.go:37 pkg/quote.go:174 #: pkg/products.go:177 pkg/products.go:303 pkg/tags.go:37 pkg/quote.go:174
#: pkg/quote.go:708 pkg/payments.go:162 pkg/expenses.go:335 pkg/expenses.go:485 #: pkg/quote.go:708 pkg/payments.go:272 pkg/expenses.go:335 pkg/expenses.go:485
#: pkg/invoices.go:177 pkg/invoices.go:877 pkg/contacts.go:154 #: pkg/invoices.go:177 pkg/invoices.go:877 pkg/contacts.go:154
#: pkg/contacts.go:362 #: pkg/contacts.go:362
msgctxt "input" msgctxt "input"
@ -929,7 +936,7 @@ msgstr "Qualsevol"
msgid "Invoices must have at least one of the specified labels." msgid "Invoices must have at least one of the specified labels."
msgstr "Les factures han de tenir com a mínim una de les etiquetes." msgstr "Les factures han de tenir com a mínim una de les etiquetes."
#: pkg/products.go:282 pkg/quote.go:915 pkg/payments.go:129 #: pkg/products.go:282 pkg/quote.go:915 pkg/payments.go:239
#: pkg/invoices.go:1161 #: pkg/invoices.go:1161
msgctxt "input" msgctxt "input"
msgid "Description" msgid "Description"
@ -1344,47 +1351,52 @@ msgstr "La confirmació no és igual a la contrasenya."
msgid "Selected language is not valid." msgid "Selected language is not valid."
msgstr "Heu seleccionat un idioma que no és vàlid." msgstr "Heu seleccionat un idioma que no és vàlid."
#: pkg/payments.go:135 #: pkg/payments.go:202
#, c-format
msgid "Payment of %s"
msgstr "Pagament de %s"
#: pkg/payments.go:245
msgctxt "input" msgctxt "input"
msgid "Payment Date" msgid "Payment Date"
msgstr "Data del pagament" msgstr "Data del pagament"
#: pkg/payments.go:141 #: pkg/payments.go:251
msgctxt "input" msgctxt "input"
msgid "Account" msgid "Account"
msgstr "Compte" msgstr "Compte"
#: pkg/payments.go:147 pkg/expenses.go:319 #: pkg/payments.go:257 pkg/expenses.go:319
msgctxt "input" msgctxt "input"
msgid "Amount" msgid "Amount"
msgstr "Import" msgstr "Import"
#: pkg/payments.go:157 pkg/expenses.go:330 pkg/invoices.go:888 #: pkg/payments.go:267 pkg/expenses.go:330 pkg/invoices.go:888
msgctxt "input" msgctxt "input"
msgid "File" msgid "File"
msgstr "Fitxer" msgstr "Fitxer"
#: pkg/payments.go:169 #: pkg/payments.go:286
msgid "Select an account." msgid "Select an account."
msgstr "Escolliu un compte." msgstr "Escolliu un compte."
#: pkg/payments.go:218 #: pkg/payments.go:335
msgid "Description can not be empty." msgid "Description can not be empty."
msgstr "No podeu deixar la descripció en blanc." msgstr "No podeu deixar la descripció en blanc."
#: pkg/payments.go:219 #: pkg/payments.go:336
msgid "Selected payment account is not valid." msgid "Selected payment account is not valid."
msgstr "Heu seleccionat un compte de pagament que no és vàlid." msgstr "Heu seleccionat un compte de pagament que no és vàlid."
#: pkg/payments.go:220 #: pkg/payments.go:337
msgid "Payment date must be a valid date." msgid "Payment date must be a valid date."
msgstr "La data de pagament ha de ser vàlida." msgstr "La data de pagament ha de ser vàlida."
#: pkg/payments.go:221 pkg/expenses.go:372 #: pkg/payments.go:338 pkg/expenses.go:372
msgid "Amount can not be empty." msgid "Amount can not be empty."
msgstr "No podeu deixar limport en blanc." msgstr "No podeu deixar limport en blanc."
#: pkg/payments.go:222 pkg/expenses.go:373 #: pkg/payments.go:339 pkg/expenses.go:373
msgid "Amount must be a number greater than zero." msgid "Amount must be a number greater than zero."
msgstr "Limport ha de ser un número major a zero." msgstr "Limport ha de ser un número major a zero."

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: numerus\n" "Project-Id-Version: numerus\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-08-16 01:57+0200\n" "POT-Creation-Date: 2024-08-17 05:26+0200\n"
"PO-Revision-Date: 2023-01-18 17:45+0100\n" "PO-Revision-Date: 2023-01-18 17:45+0100\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"
@ -116,7 +116,7 @@ msgstr "Subtotal"
#: web/template/quotes/new.gohtml:74 web/template/quotes/view.gohtml:82 #: web/template/quotes/new.gohtml:74 web/template/quotes/view.gohtml:82
#: web/template/quotes/view.gohtml:122 web/template/quotes/edit.gohtml:75 #: web/template/quotes/view.gohtml:122 web/template/quotes/edit.gohtml:75
#: web/template/expenses/new.gohtml:46 web/template/expenses/index.gohtml:74 #: web/template/expenses/new.gohtml:46 web/template/expenses/index.gohtml:74
#: web/template/expenses/edit.gohtml:48 web/template/payments/index.gohtml:30 #: web/template/expenses/edit.gohtml:48 web/template/payments/index.gohtml:34
msgctxt "title" msgctxt "title"
msgid "Total" msgid "Total"
msgstr "Total" msgstr "Total"
@ -124,7 +124,7 @@ msgstr "Total"
#: web/template/invoices/new.gohtml:92 web/template/invoices/edit.gohtml:93 #: web/template/invoices/new.gohtml:92 web/template/invoices/edit.gohtml:93
#: web/template/quotes/new.gohtml:92 web/template/quotes/edit.gohtml:93 #: web/template/quotes/new.gohtml:92 web/template/quotes/edit.gohtml:93
#: web/template/expenses/new.gohtml:56 web/template/expenses/edit.gohtml:58 #: web/template/expenses/new.gohtml:56 web/template/expenses/edit.gohtml:58
#: web/template/payments/edit.gohtml:37 #: web/template/payments/edit.gohtml:41
#: web/template/payments/accounts/edit.gohtml:38 #: web/template/payments/accounts/edit.gohtml:38
msgctxt "action" msgctxt "action"
msgid "Update" msgid "Update"
@ -135,7 +135,7 @@ msgstr "Actualizar"
#: web/template/contacts/new.gohtml:49 web/template/contacts/edit.gohtml:53 #: web/template/contacts/new.gohtml:49 web/template/contacts/edit.gohtml:53
#: web/template/expenses/new.gohtml:59 web/template/expenses/edit.gohtml:61 #: web/template/expenses/new.gohtml:59 web/template/expenses/edit.gohtml:61
#: web/template/products/new.gohtml:30 web/template/products/edit.gohtml:36 #: web/template/products/new.gohtml:30 web/template/products/edit.gohtml:36
#: web/template/payments/new.gohtml:35 #: web/template/payments/new.gohtml:39
#: web/template/payments/accounts/new.gohtml:41 #: web/template/payments/accounts/new.gohtml:41
msgctxt "action" msgctxt "action"
msgid "Save" msgid "Save"
@ -193,14 +193,14 @@ msgid "Customer"
msgstr "Cliente" msgstr "Cliente"
#: web/template/invoices/index.gohtml:70 web/template/quotes/index.gohtml:70 #: web/template/invoices/index.gohtml:70 web/template/quotes/index.gohtml:70
#: web/template/expenses/index.gohtml:68 web/template/payments/index.gohtml:28 #: web/template/expenses/index.gohtml:68 web/template/payments/index.gohtml:32
msgctxt "title" msgctxt "title"
msgid "Status" msgid "Status"
msgstr "Estado" msgstr "Estado"
#: web/template/invoices/index.gohtml:71 web/template/quotes/index.gohtml:71 #: web/template/invoices/index.gohtml:71 web/template/quotes/index.gohtml:71
#: web/template/contacts/index.gohtml:50 web/template/expenses/index.gohtml:69 #: web/template/contacts/index.gohtml:50 web/template/expenses/index.gohtml:69
#: web/template/products/index.gohtml:46 web/template/payments/index.gohtml:29 #: web/template/products/index.gohtml:46 web/template/payments/index.gohtml:33
msgctxt "title" msgctxt "title"
msgid "Tags" msgid "Tags"
msgstr "Etiquetes" msgstr "Etiquetes"
@ -212,7 +212,7 @@ msgid "Amount"
msgstr "Importe" msgstr "Importe"
#: web/template/invoices/index.gohtml:73 web/template/quotes/index.gohtml:73 #: web/template/invoices/index.gohtml:73 web/template/quotes/index.gohtml:73
#: web/template/expenses/index.gohtml:75 web/template/payments/index.gohtml:31 #: web/template/expenses/index.gohtml:75 web/template/payments/index.gohtml:35
msgctxt "title" msgctxt "title"
msgid "Download" msgid "Download"
msgstr "Descargar" msgstr "Descargar"
@ -220,7 +220,7 @@ msgstr "Descargar"
#: web/template/invoices/index.gohtml:74 web/template/quotes/index.gohtml:74 #: web/template/invoices/index.gohtml:74 web/template/quotes/index.gohtml:74
#: web/template/contacts/index.gohtml:51 web/template/expenses/index.gohtml:76 #: web/template/contacts/index.gohtml:51 web/template/expenses/index.gohtml:76
#: web/template/company/switch.gohtml:23 web/template/products/index.gohtml:48 #: web/template/company/switch.gohtml:23 web/template/products/index.gohtml:48
#: web/template/payments/index.gohtml:32 #: web/template/payments/index.gohtml:36
msgctxt "title" msgctxt "title"
msgid "Actions" msgid "Actions"
msgstr "Acciones" msgstr "Acciones"
@ -242,7 +242,7 @@ msgstr "Acciones para la factura %s"
#: web/template/invoices/index.gohtml:139 web/template/invoices/view.gohtml:19 #: web/template/invoices/index.gohtml:139 web/template/invoices/view.gohtml:19
#: web/template/quotes/index.gohtml:137 web/template/quotes/view.gohtml:22 #: web/template/quotes/index.gohtml:137 web/template/quotes/view.gohtml:22
#: web/template/contacts/index.gohtml:82 web/template/expenses/index.gohtml:125 #: web/template/contacts/index.gohtml:82 web/template/expenses/index.gohtml:125
#: web/template/products/index.gohtml:78 web/template/payments/index.gohtml:77 #: web/template/products/index.gohtml:78 web/template/payments/index.gohtml:81
msgctxt "action" msgctxt "action"
msgid "Edit" msgid "Edit"
msgstr "Editar" msgstr "Editar"
@ -258,7 +258,7 @@ msgid "No invoices added yet."
msgstr "No hay facturas." msgstr "No hay facturas."
#: web/template/invoices/index.gohtml:164 web/template/quotes/index.gohtml:170 #: web/template/invoices/index.gohtml:164 web/template/quotes/index.gohtml:170
#: web/template/expenses/index.gohtml:142 #: web/template/expenses/index.gohtml:148
msgid "Total" msgid "Total"
msgstr "Total" msgstr "Total"
@ -633,6 +633,8 @@ msgstr "Nuevo gasto"
#: web/template/expenses/new.gohtml:11 web/template/expenses/index.gohtml:3 #: web/template/expenses/new.gohtml:11 web/template/expenses/index.gohtml:3
#: web/template/expenses/index.gohtml:11 web/template/expenses/edit.gohtml:11 #: web/template/expenses/index.gohtml:11 web/template/expenses/edit.gohtml:11
#: web/template/payments/new.gohtml:12 web/template/payments/index.gohtml:12
#: web/template/payments/edit.gohtml:12
msgctxt "title" msgctxt "title"
msgid "Expenses" msgid "Expenses"
msgstr "Gastos" msgstr "Gastos"
@ -656,7 +658,12 @@ msgstr "Número de factura"
msgid "Actions for expense %s" msgid "Actions for expense %s"
msgstr "Acciones para el gasto %s" msgstr "Acciones para el gasto %s"
#: web/template/expenses/index.gohtml:135 #: web/template/expenses/index.gohtml:131
msgctxt "action"
msgid "Payments"
msgstr "Pagos"
#: web/template/expenses/index.gohtml:141
msgid "No expenses added yet." msgid "No expenses added yet."
msgstr "No hay gastos." msgstr "No hay gastos."
@ -768,51 +775,51 @@ msgctxt "title"
msgid "Edit Product “%s”" msgid "Edit Product “%s”"
msgstr "Edición del producto «%s»" msgstr "Edición del producto «%s»"
#: web/template/payments/new.gohtml:3 web/template/payments/new.gohtml:12 #: web/template/payments/new.gohtml:3 web/template/payments/new.gohtml:16
msgctxt "title" msgctxt "title"
msgid "New Payment" msgid "New Payment"
msgstr "Nuevo pago" msgstr "Nuevo pago"
#: web/template/payments/new.gohtml:11 web/template/payments/index.gohtml:3 #: web/template/payments/new.gohtml:15 web/template/payments/index.gohtml:3
#: web/template/payments/index.gohtml:11 web/template/payments/edit.gohtml:11 #: web/template/payments/index.gohtml:15 web/template/payments/edit.gohtml:15
msgctxt "title" msgctxt "title"
msgid "Payments" msgid "Payments"
msgstr "Pagos" msgstr "Pagos"
#: web/template/payments/index.gohtml:16 #: web/template/payments/index.gohtml:20
msgctxt "action" msgctxt "action"
msgid "New payment" msgid "New payment"
msgstr "Nuevo pago" msgstr "Nuevo pago"
#: web/template/payments/index.gohtml:25 #: web/template/payments/index.gohtml:29
msgctxt "title" msgctxt "title"
msgid "Payment Date" msgid "Payment Date"
msgstr "Fecha del pago" msgstr "Fecha del pago"
#: web/template/payments/index.gohtml:26 #: web/template/payments/index.gohtml:30
msgctxt "title" msgctxt "title"
msgid "Description" msgid "Description"
msgstr "Descripción" msgstr "Descripción"
#: web/template/payments/index.gohtml:27 #: web/template/payments/index.gohtml:31
msgctxt "title" msgctxt "title"
msgid "Document" msgid "Document"
msgstr "Documento" msgstr "Documento"
#: web/template/payments/index.gohtml:37 #: web/template/payments/index.gohtml:41
msgid "Are you sure you wish to delete this payment?" msgid "Are you sure you wish to delete this payment?"
msgstr "¿Estáis seguro de querer borrar este pago?" msgstr "¿Estáis seguro de querer borrar este pago?"
#: web/template/payments/index.gohtml:69 #: web/template/payments/index.gohtml:73
msgid "Actions for payment %s" msgid "Actions for payment %s"
msgstr "Acciones para el pago %s" msgstr "Acciones para el pago %s"
#: web/template/payments/index.gohtml:88 #: web/template/payments/index.gohtml:92
msgctxt "action" msgctxt "action"
msgid "Remove" msgid "Remove"
msgstr "Borrar" msgstr "Borrar"
#: web/template/payments/index.gohtml:98 #: web/template/payments/index.gohtml:102
msgid "No payments added yet." msgid "No payments added yet."
msgstr "No hay pagos." msgstr "No hay pagos."
@ -894,7 +901,7 @@ msgid "Name"
msgstr "Nombre" msgstr "Nombre"
#: pkg/products.go:177 pkg/products.go:303 pkg/tags.go:37 pkg/quote.go:174 #: pkg/products.go:177 pkg/products.go:303 pkg/tags.go:37 pkg/quote.go:174
#: pkg/quote.go:708 pkg/payments.go:162 pkg/expenses.go:335 pkg/expenses.go:485 #: pkg/quote.go:708 pkg/payments.go:272 pkg/expenses.go:335 pkg/expenses.go:485
#: pkg/invoices.go:177 pkg/invoices.go:877 pkg/contacts.go:154 #: pkg/invoices.go:177 pkg/invoices.go:877 pkg/contacts.go:154
#: pkg/contacts.go:362 #: pkg/contacts.go:362
msgctxt "input" msgctxt "input"
@ -929,7 +936,7 @@ msgstr "Cualquiera"
msgid "Invoices must have at least one of the specified labels." msgid "Invoices must have at least one of the specified labels."
msgstr "Las facturas deben tener como mínimo una de las etiquetas." msgstr "Las facturas deben tener como mínimo una de las etiquetas."
#: pkg/products.go:282 pkg/quote.go:915 pkg/payments.go:129 #: pkg/products.go:282 pkg/quote.go:915 pkg/payments.go:239
#: pkg/invoices.go:1161 #: pkg/invoices.go:1161
msgctxt "input" msgctxt "input"
msgid "Description" msgid "Description"
@ -1344,47 +1351,52 @@ msgstr "La confirmación no corresponde con la contraseña."
msgid "Selected language is not valid." msgid "Selected language is not valid."
msgstr "Habéis escogido un idioma que no es válido." msgstr "Habéis escogido un idioma que no es válido."
#: pkg/payments.go:135 #: pkg/payments.go:202
#, c-format
msgid "Payment of %s"
msgstr "Pago de %s"
#: pkg/payments.go:245
msgctxt "input" msgctxt "input"
msgid "Payment Date" msgid "Payment Date"
msgstr "Fecha del pago" msgstr "Fecha del pago"
#: pkg/payments.go:141 #: pkg/payments.go:251
msgctxt "input" msgctxt "input"
msgid "Account" msgid "Account"
msgstr "Cuenta" msgstr "Cuenta"
#: pkg/payments.go:147 pkg/expenses.go:319 #: pkg/payments.go:257 pkg/expenses.go:319
msgctxt "input" msgctxt "input"
msgid "Amount" msgid "Amount"
msgstr "Importe" msgstr "Importe"
#: pkg/payments.go:157 pkg/expenses.go:330 pkg/invoices.go:888 #: pkg/payments.go:267 pkg/expenses.go:330 pkg/invoices.go:888
msgctxt "input" msgctxt "input"
msgid "File" msgid "File"
msgstr "Archivo" msgstr "Archivo"
#: pkg/payments.go:169 #: pkg/payments.go:286
msgid "Select an account." msgid "Select an account."
msgstr "Escoged una cuenta." msgstr "Escoged una cuenta."
#: pkg/payments.go:218 #: pkg/payments.go:335
msgid "Description can not be empty." msgid "Description can not be empty."
msgstr "No podéis dejar la descripción en blanco." msgstr "No podéis dejar la descripción en blanco."
#: pkg/payments.go:219 #: pkg/payments.go:336
msgid "Selected payment account is not valid." msgid "Selected payment account is not valid."
msgstr "Habéis escogido una cuenta de pago que no es válida." msgstr "Habéis escogido una cuenta de pago que no es válida."
#: pkg/payments.go:220 #: pkg/payments.go:337
msgid "Payment date must be a valid date." msgid "Payment date must be a valid date."
msgstr "La fecha de pago debe ser válida." msgstr "La fecha de pago debe ser válida."
#: pkg/payments.go:221 pkg/expenses.go:372 #: pkg/payments.go:338 pkg/expenses.go:372
msgid "Amount can not be empty." msgid "Amount can not be empty."
msgstr "No podéis dejar el importe en blanco." msgstr "No podéis dejar el importe en blanco."
#: pkg/payments.go:222 pkg/expenses.go:373 #: pkg/payments.go:339 pkg/expenses.go:373
msgid "Amount must be a number greater than zero." msgid "Amount must be a number greater than zero."
msgstr "El importe tiene que ser un número mayor a cero." msgstr "El importe tiene que ser un número mayor a cero."

View File

@ -116,15 +116,21 @@
<details class="menu"> <details class="menu">
{{- $label := .InvoiceNumber | printf (gettext "Actions for expense %s") -}} {{- $label := .InvoiceNumber | printf (gettext "Actions for expense %s") -}}
<summary aria-label="{{ $label }}"><i class="ri-more-line"></i></summary> <summary aria-label="{{ $label }}"><i class="ri-more-line"></i></summary>
<ul role="menu" class="action-menu"> <ul role="menu" class="action-menu"
data-hx-target="main" data-hx-boost="true"
>
<li role="presentation"> <li role="presentation">
<a role="menuitem" href="{{ companyURI "/expenses"}}/{{ .Slug }}" <a role="menuitem" href="{{ companyURI "/expenses"}}/{{ .Slug }}">
data-hx-target="main" data-hx-boost="true"
>
<i class="ri-edit-line"></i> <i class="ri-edit-line"></i>
{{( pgettext "Edit" "action" )}} {{( pgettext "Edit" "action" )}}
</a> </a>
</li> </li>
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/expenses"}}/{{ .Slug }}/payments">
<i class="ri-bank-card-2-line"></i>
{{( pgettext "Payments" "action" )}}
</a>
</li>
</ul> </ul>
</details> </details>
</td> </td>

View File

@ -8,7 +8,11 @@
<nav data-hx-target="main" data-hx-boost="true"> <nav data-hx-target="main" data-hx-boost="true">
<p> <p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> / <a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a href="{{ companyURI "/payments"}}">{{( pgettext "Payments" "title" )}}</a> / {{ if .Expense }}
<a href="{{ companyURI "/expenses" }}">{{( pgettext "Expenses" "title" )}}</a> /
<a href="{{ companyURI "/expenses/" }}{{ .Expense.Slug }}">{{ .Expense.InvoiceNumber }}</a> /
{{ end }}
<a href="{{ .BaseURI }}">{{( pgettext "Payments" "title" )}}</a> /
<a>{{ .Description }}</a> <a>{{ .Description }}</a>
</p> </p>
</nav> </nav>
@ -18,7 +22,7 @@
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.PaymentForm*/ -}} {{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.PaymentForm*/ -}}
<section data-hx-target="main"> <section data-hx-target="main">
<h2>{{ template "title" . }}</h2> <h2>{{ template "title" . }}</h2>
<form method="POST" action="{{ companyURI "/payments/" }}{{ .Slug }}" <form method="POST" action="{{ .BaseURI }}/{{ .Slug }}"
enctype="multipart/form-data" enctype="multipart/form-data"
data-hx-swap="innerHTML show:false" data-hx-swap="innerHTML show:false"
data-hx-boost="true" data-hx-boost="true"

View File

@ -8,12 +8,16 @@
<nav data-hx-target="main"> <nav data-hx-target="main">
<p data-hx-boost="true"> <p data-hx-boost="true">
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> / <a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
{{ if .Expense }}
<a href="{{ companyURI "/expenses" }}">{{( pgettext "Expenses" "title" )}}</a> /
<a href="{{ companyURI "/expenses/" }}{{ .Expense.Slug }}">{{ .Expense.InvoiceNumber }}</a> /
{{ end }}
<a>{{( pgettext "Payments" "title" )}}</a> <a>{{( pgettext "Payments" "title" )}}</a>
</p> </p>
<a class="primary button" <a class="primary button"
data-hx-boost="true" data-hx-boost="true"
href="{{ companyURI "/payments/new" }}">{{( pgettext "New payment" "action" )}}</a> href="{{ .BaseURI }}/new">{{( pgettext "New payment" "action" )}}</a>
</nav> </nav>
{{- end }} {{- end }}
@ -38,7 +42,7 @@
{{- range $payment := . }} {{- range $payment := . }}
<tr> <tr>
<td>{{ .PaymentDate|formatDate }}</td> <td>{{ .PaymentDate|formatDate }}</td>
<td><a href="{{ companyURI "/payments/"}}{{ .Slug }}">{{ .Description }}</a></td> <td><a href="{{ $.BaseURI }}/{{ .Slug }}">{{ .Description }}</a></td>
<td> <td>
{{- if .InvoiceNumber -}} {{- if .InvoiceNumber -}}
<a href="{{ companyURI "/expenses/"}}{{ .ExpenseSlug }}">{{ .InvoiceNumber }}</a> <a href="{{ companyURI "/expenses/"}}{{ .ExpenseSlug }}">{{ .InvoiceNumber }}</a>
@ -46,7 +50,7 @@
</td> </td>
<td class="payment-status-{{ .Status }}">{{ .StatusLabel }}</td> <td class="payment-status-{{ .Status }}">{{ .StatusLabel }}</td>
<td <td
data-hx-get="{{companyURI "/payments/"}}{{ .Slug }}/tags/edit" data-hx-get="{{ companyURI "/payments/" }}{{ .Slug }}/tags/edit"
data-hx-target="this" data-hx-target="this"
data-hx-swap="outerHTML" data-hx-swap="outerHTML"
> >
@ -70,7 +74,7 @@
<summary aria-label="{{ $label }}"><i class="ri-more-line"></i></summary> <summary aria-label="{{ $label }}"><i class="ri-more-line"></i></summary>
<ul role="menu" class="action-menu"> <ul role="menu" class="action-menu">
<li role="presentation"> <li role="presentation">
<a role="menuitem" href="{{ companyURI "/payments"}}/{{ .Slug }}" <a role="menuitem" href="{{ $.BaseURI }}/{{ .Slug }}"
data-hx-target="main" data-hx-boost="true" data-hx-target="main" data-hx-boost="true"
> >
<i class="ri-edit-line"></i> <i class="ri-edit-line"></i>
@ -79,7 +83,7 @@
</li> </li>
<li role="presentation"> <li role="presentation">
<button role="menuitem" <button role="menuitem"
data-hx-delete="{{ companyURI "/payments"}}/{{ .Slug }}" data-hx-delete="{{ $.BaseURI }}/{{ .Slug }}"
data-hx-confirm="{{ $confirm }}" data-hx-confirm="{{ $confirm }}"
data-hx-headers='{ {{ csrfHeader }} }' data-hx-headers='{ {{ csrfHeader }} }'
data-hx-target="main" data-hx-target="main"

View File

@ -8,7 +8,11 @@
<nav data-hx-target="main" data-hx-boost="true"> <nav data-hx-target="main" data-hx-boost="true">
<p> <p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> / <a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a href="{{ companyURI "/payments"}}">{{( pgettext "Payments" "title" )}}</a> / {{ if .Expense }}
<a href="{{ companyURI "/expenses" }}">{{( pgettext "Expenses" "title" )}}</a> /
<a href="{{ companyURI "/expenses/" }}{{ .Expense.Slug }}">{{ .Expense.InvoiceNumber }}</a> /
{{ end }}
<a href="{{ .BaseURI }}">{{( pgettext "Payments" "title" )}}</a> /
<a>{{( pgettext "New Payment" "title" )}}</a> <a>{{( pgettext "New Payment" "title" )}}</a>
</p> </p>
</nav> </nav>
@ -18,7 +22,7 @@
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.PaymentForm*/ -}} {{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.PaymentForm*/ -}}
<section data-hx-target="main"> <section data-hx-target="main">
<h2>{{ template "title" . }}</h2> <h2>{{ template "title" . }}</h2>
<form method="POST" action="{{ companyURI "/payments" }}" <form method="POST" action="{{ .BaseURI }}"
enctype="multipart/form-data" enctype="multipart/form-data"
data-hx-swap="innerHTML show:false" data-hx-swap="innerHTML show:false"
data-hx-boost="true"> data-hx-boost="true">