diff --git a/pkg/payments.go b/pkg/payments.go index a8353b4..0997cbe 100644 --- a/pkg/payments.go +++ b/pkg/payments.go @@ -19,13 +19,39 @@ func servePaymentIndex(w http.ResponseWriter, r *http.Request, _ httprouter.Para 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 { Payments []*PaymentEntry + BaseURI string + Expense *PaymentExpense } func NewPaymentIndexPage(ctx context.Context, conn *Conn, company *Company, locale *Locale) *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) } +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 { ID int Slug string @@ -47,7 +123,7 @@ type PaymentEntry struct { 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, ` select payment_id , 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 using (expense_id) where payment.company_id = $2 + and ($3 = 0 or expense_id = $3) order by payment_date desc, total desc - `, locale.Language, company.Id) + `, locale.Language, company.Id, expenseId) defer rows.Close() var entries []*PaymentEntry @@ -108,10 +185,42 @@ func servePaymentForm(w http.ResponseWriter, r *http.Request, params httprouter. 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 { locale *Locale company *Company Slug string + BaseURI string + Expense *PaymentExpense Description *InputField PaymentDate *InputField PaymentAccount *SelectField @@ -124,6 +233,7 @@ func newPaymentForm(ctx context.Context, conn *Conn, locale *Locale, company *Co return &PaymentForm{ locale: locale, company: company, + BaseURI: companyURI(company, "/payments"), Description: &InputField{ Name: "description", 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) { if f.Slug == "" { 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) company := mustGetCompany(r) 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 { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -244,11 +365,30 @@ func handleAddPayment(w http.ResponseWriter, r *http.Request, _ httprouter.Param form.MustRender(w, r) 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 { 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) { @@ -257,6 +397,10 @@ func handleEditPayment(w http.ResponseWriter, r *http.Request, params httprouter company := mustGetCompany(r) form := newPaymentForm(r.Context(), conn, locale, company) 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) { http.NotFound(w, r) return @@ -283,16 +427,35 @@ func handleEditPayment(w http.ResponseWriter, r *http.Request, params httprouter 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) } - htmxRedirect(w, r, companyURI(company, "/payments")) + htmxRedirect(w, r, form.BaseURI) } -func handleRemovePayment(w http.ResponseWriter, r *http.Request, params httprouter.Params) { - slug := params[0].Value - if !ValidUuid(slug) { +func handleEditExpensePayment(w http.ResponseWriter, r *http.Request, params httprouter.Params) { + conn := getConn(r) + locale := getLocale(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) + 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 { http.Error(w, err.Error(), http.StatusForbidden) return @@ -301,8 +464,20 @@ func handleRemovePayment(w http.ResponseWriter, r *http.Request, params httprout conn := getConn(r) 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) - 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) { diff --git a/pkg/router.go b/pkg/router.go index b5596b7..10b42ff 100644 --- a/pkg/router.go +++ b/pkg/router.go @@ -62,6 +62,11 @@ func NewRouter(db *Db, demo bool) http.Handler { companyRouter.PUT("/expenses/:slug/tags", HandleUpdateExpenseTags) companyRouter.GET("/expenses/:slug/tags/edit", ServeEditExpenseTags) 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.POST("/payments", handleAddPayment) companyRouter.GET("/payments/:slug", servePaymentForm) diff --git a/po/ca.po b/po/ca.po index a4ee94c..d681066 100644 --- a/po/ca.po +++ b/po/ca.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: numerus\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" "Last-Translator: jordi fita mas \n" "Language-Team: Catalan \n" @@ -116,7 +116,7 @@ msgstr "Subtotal" #: 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/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" msgid "Total" msgstr "Total" @@ -124,7 +124,7 @@ msgstr "Total" #: 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/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 msgctxt "action" msgid "Update" @@ -135,7 +135,7 @@ msgstr "Actualitza" #: 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/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 msgctxt "action" msgid "Save" @@ -193,14 +193,14 @@ msgid "Customer" msgstr "Client" #: 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" msgid "Status" msgstr "Estat" #: 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/products/index.gohtml:46 web/template/payments/index.gohtml:29 +#: web/template/products/index.gohtml:46 web/template/payments/index.gohtml:33 msgctxt "title" msgid "Tags" msgstr "Etiquetes" @@ -212,7 +212,7 @@ msgid "Amount" msgstr "Import" #: 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" msgid "Download" msgstr "Descàrrega" @@ -220,7 +220,7 @@ msgstr "Descàrrega" #: 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/company/switch.gohtml:23 web/template/products/index.gohtml:48 -#: web/template/payments/index.gohtml:32 +#: web/template/payments/index.gohtml:36 msgctxt "title" msgid "Actions" 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/quotes/index.gohtml:137 web/template/quotes/view.gohtml:22 #: 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" msgid "Edit" msgstr "Edita" @@ -258,7 +258,7 @@ msgid "No invoices added yet." msgstr "No hi ha cap factura." #: 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" msgstr "Total" @@ -633,6 +633,8 @@ msgstr "Nova despesa" #: 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/payments/new.gohtml:12 web/template/payments/index.gohtml:12 +#: web/template/payments/edit.gohtml:12 msgctxt "title" msgid "Expenses" msgstr "Despeses" @@ -656,7 +658,12 @@ msgstr "Número de factura" msgid "Actions for expense %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." msgstr "No hi ha cap despesa." @@ -768,51 +775,51 @@ msgctxt "title" msgid "Edit Product “%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" msgid "New Payment" msgstr "Nou pagament" -#: web/template/payments/new.gohtml:11 web/template/payments/index.gohtml:3 -#: web/template/payments/index.gohtml:11 web/template/payments/edit.gohtml:11 +#: web/template/payments/new.gohtml:15 web/template/payments/index.gohtml:3 +#: web/template/payments/index.gohtml:15 web/template/payments/edit.gohtml:15 msgctxt "title" msgid "Payments" msgstr "Pagaments" -#: web/template/payments/index.gohtml:16 +#: web/template/payments/index.gohtml:20 msgctxt "action" msgid "New payment" msgstr "Nou pagament" -#: web/template/payments/index.gohtml:25 +#: web/template/payments/index.gohtml:29 msgctxt "title" msgid "Payment Date" msgstr "Data del pagament" -#: web/template/payments/index.gohtml:26 +#: web/template/payments/index.gohtml:30 msgctxt "title" msgid "Description" msgstr "Descripció" -#: web/template/payments/index.gohtml:27 +#: web/template/payments/index.gohtml:31 msgctxt "title" msgid "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?" 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" msgstr "Accions pel pagament %s" -#: web/template/payments/index.gohtml:88 +#: web/template/payments/index.gohtml:92 msgctxt "action" msgid "Remove" msgstr "Esborra" -#: web/template/payments/index.gohtml:98 +#: web/template/payments/index.gohtml:102 msgid "No payments added yet." msgstr "No hi ha cap pagament." @@ -894,7 +901,7 @@ msgid "Name" msgstr "Nom" #: 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/contacts.go:362 msgctxt "input" @@ -929,7 +936,7 @@ msgstr "Qualsevol" 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." -#: 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 msgctxt "input" msgid "Description" @@ -1344,47 +1351,52 @@ msgstr "La confirmació no és igual a la contrasenya." msgid "Selected language is not valid." 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" msgid "Payment Date" msgstr "Data del pagament" -#: pkg/payments.go:141 +#: pkg/payments.go:251 msgctxt "input" msgid "Account" msgstr "Compte" -#: pkg/payments.go:147 pkg/expenses.go:319 +#: pkg/payments.go:257 pkg/expenses.go:319 msgctxt "input" msgid "Amount" 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" msgid "File" msgstr "Fitxer" -#: pkg/payments.go:169 +#: pkg/payments.go:286 msgid "Select an account." msgstr "Escolliu un compte." -#: pkg/payments.go:218 +#: pkg/payments.go:335 msgid "Description can not be empty." msgstr "No podeu deixar la descripció en blanc." -#: pkg/payments.go:219 +#: pkg/payments.go:336 msgid "Selected payment account is not valid." 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." 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." msgstr "No podeu deixar l’import 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." msgstr "L’import ha de ser un número major a zero." diff --git a/po/es.po b/po/es.po index 240f244..230b4cc 100644 --- a/po/es.po +++ b/po/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: numerus\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" "Last-Translator: jordi fita mas \n" "Language-Team: Spanish \n" @@ -116,7 +116,7 @@ msgstr "Subtotal" #: 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/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" msgid "Total" msgstr "Total" @@ -124,7 +124,7 @@ msgstr "Total" #: 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/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 msgctxt "action" msgid "Update" @@ -135,7 +135,7 @@ msgstr "Actualizar" #: 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/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 msgctxt "action" msgid "Save" @@ -193,14 +193,14 @@ msgid "Customer" msgstr "Cliente" #: 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" msgid "Status" msgstr "Estado" #: 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/products/index.gohtml:46 web/template/payments/index.gohtml:29 +#: web/template/products/index.gohtml:46 web/template/payments/index.gohtml:33 msgctxt "title" msgid "Tags" msgstr "Etiquetes" @@ -212,7 +212,7 @@ msgid "Amount" msgstr "Importe" #: 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" msgid "Download" msgstr "Descargar" @@ -220,7 +220,7 @@ msgstr "Descargar" #: 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/company/switch.gohtml:23 web/template/products/index.gohtml:48 -#: web/template/payments/index.gohtml:32 +#: web/template/payments/index.gohtml:36 msgctxt "title" msgid "Actions" 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/quotes/index.gohtml:137 web/template/quotes/view.gohtml:22 #: 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" msgid "Edit" msgstr "Editar" @@ -258,7 +258,7 @@ msgid "No invoices added yet." msgstr "No hay facturas." #: 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" msgstr "Total" @@ -633,6 +633,8 @@ msgstr "Nuevo gasto" #: 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/payments/new.gohtml:12 web/template/payments/index.gohtml:12 +#: web/template/payments/edit.gohtml:12 msgctxt "title" msgid "Expenses" msgstr "Gastos" @@ -656,7 +658,12 @@ msgstr "Número de factura" msgid "Actions for expense %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." msgstr "No hay gastos." @@ -768,51 +775,51 @@ msgctxt "title" msgid "Edit Product “%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" msgid "New Payment" msgstr "Nuevo pago" -#: web/template/payments/new.gohtml:11 web/template/payments/index.gohtml:3 -#: web/template/payments/index.gohtml:11 web/template/payments/edit.gohtml:11 +#: web/template/payments/new.gohtml:15 web/template/payments/index.gohtml:3 +#: web/template/payments/index.gohtml:15 web/template/payments/edit.gohtml:15 msgctxt "title" msgid "Payments" msgstr "Pagos" -#: web/template/payments/index.gohtml:16 +#: web/template/payments/index.gohtml:20 msgctxt "action" msgid "New payment" msgstr "Nuevo pago" -#: web/template/payments/index.gohtml:25 +#: web/template/payments/index.gohtml:29 msgctxt "title" msgid "Payment Date" msgstr "Fecha del pago" -#: web/template/payments/index.gohtml:26 +#: web/template/payments/index.gohtml:30 msgctxt "title" msgid "Description" msgstr "Descripción" -#: web/template/payments/index.gohtml:27 +#: web/template/payments/index.gohtml:31 msgctxt "title" msgid "Document" msgstr "Documento" -#: web/template/payments/index.gohtml:37 +#: web/template/payments/index.gohtml:41 msgid "Are you sure you wish to delete this payment?" 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" msgstr "Acciones para el pago %s" -#: web/template/payments/index.gohtml:88 +#: web/template/payments/index.gohtml:92 msgctxt "action" msgid "Remove" msgstr "Borrar" -#: web/template/payments/index.gohtml:98 +#: web/template/payments/index.gohtml:102 msgid "No payments added yet." msgstr "No hay pagos." @@ -894,7 +901,7 @@ msgid "Name" msgstr "Nombre" #: 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/contacts.go:362 msgctxt "input" @@ -929,7 +936,7 @@ msgstr "Cualquiera" msgid "Invoices must have at least one of the specified labels." 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 msgctxt "input" msgid "Description" @@ -1344,47 +1351,52 @@ msgstr "La confirmación no corresponde con la contraseña." msgid "Selected language is not valid." 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" msgid "Payment Date" msgstr "Fecha del pago" -#: pkg/payments.go:141 +#: pkg/payments.go:251 msgctxt "input" msgid "Account" msgstr "Cuenta" -#: pkg/payments.go:147 pkg/expenses.go:319 +#: pkg/payments.go:257 pkg/expenses.go:319 msgctxt "input" msgid "Amount" 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" msgid "File" msgstr "Archivo" -#: pkg/payments.go:169 +#: pkg/payments.go:286 msgid "Select an account." msgstr "Escoged una cuenta." -#: pkg/payments.go:218 +#: pkg/payments.go:335 msgid "Description can not be empty." 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." 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." 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." 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." msgstr "El importe tiene que ser un número mayor a cero." diff --git a/web/template/expenses/index.gohtml b/web/template/expenses/index.gohtml index 102ecd6..2e8c63d 100644 --- a/web/template/expenses/index.gohtml +++ b/web/template/expenses/index.gohtml @@ -116,15 +116,21 @@ diff --git a/web/template/payments/edit.gohtml b/web/template/payments/edit.gohtml index 9e72aef..b41423f 100644 --- a/web/template/payments/edit.gohtml +++ b/web/template/payments/edit.gohtml @@ -8,7 +8,11 @@ @@ -18,7 +22,7 @@ {{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.PaymentForm*/ -}}

{{ template "title" . }}

-

{{( pgettext "Home" "title" )}} / + {{ if .Expense }} + {{( pgettext "Expenses" "title" )}} / + {{ .Expense.InvoiceNumber }} / + {{ end }} {{( pgettext "Payments" "title" )}}

{{( pgettext "New payment" "action" )}} + href="{{ .BaseURI }}/new">{{( pgettext "New payment" "action" )}} {{- end }} @@ -38,7 +42,7 @@ {{- range $payment := . }} {{ .PaymentDate|formatDate }} - {{ .Description }} + {{ .Description }} {{- if .InvoiceNumber -}} {{ .InvoiceNumber }} @@ -46,7 +50,7 @@ {{ .StatusLabel }} @@ -70,7 +74,7 @@