+
+
+

Management information

+
+
{{ block "main-content" . }}{{ end }}
diff --git a/web/template/layout/page.gotmpl b/web/template/layout/page.gotmpl index 1246741..b7f79b9 100644 --- a/web/template/layout/page.gotmpl +++ b/web/template/layout/page.gotmpl @@ -21,7 +21,7 @@ - + {{ template "header" . }} {{ block "main" . }}{{ end }} From d5c30101e56159c9a6d2dff602abce3fb8412084 Mon Sep 17 00:00:00 2001 From: nicholassully Date: Mon, 12 Aug 2024 14:00:16 +0100 Subject: [PATCH 2/7] pfs-116 changing post to a get --- adrs/0002-new-finance-back-end.md | 2 +- internal/api/api_client.go | 16 +++--- .../api/{submit_download.go => download.go} | 4 +- ...bmit_download_test.go => download_test.go} | 24 ++++----- internal/model/journal_type.go | 6 --- internal/model/schedule_type.go | 6 +++ internal/server/download.go | 50 +++++++++++++++++++ ...bmit_download_test.go => download_test.go} | 12 ++--- internal/server/environment_vars.go | 2 + internal/server/server.go | 4 +- internal/server/server_test.go | 2 +- internal/server/submit_download.go | 49 ------------------ internal/util/util/translate.go | 4 +- main.go | 2 +- web/template/downloads.gotmpl | 4 +- 15 files changed, 96 insertions(+), 91 deletions(-) rename internal/api/{submit_download.go => download.go} (86%) rename internal/api/{submit_download_test.go => download_test.go} (69%) create mode 100644 internal/server/download.go rename internal/server/{submit_download_test.go => download_test.go} (82%) delete mode 100644 internal/server/submit_download.go diff --git a/adrs/0002-new-finance-back-end.md b/adrs/0002-new-finance-back-end.md index 33f3601..a342c55 100644 --- a/adrs/0002-new-finance-back-end.md +++ b/adrs/0002-new-finance-back-end.md @@ -15,7 +15,7 @@ the source of truth for payments moving to us from SOP. We are therefore replaci ## Decision This will be a new Front End service following our established Golang FE pattern. The web pages it serves will have two -separate functions: Uploading files for processing, and downloading reports. Reportsing will be broken out into a separate +separate functions: Uploading files for processing, and downloading reports. Reporting will be broken out into a separate microservice, as it has a defined scope and will allow us to provide resources for potentially long-running database queries without impacting other services. The architecture for processing files will depend on the file and how coupled the data are with existing processes. diff --git a/internal/api/api_client.go b/internal/api/api_client.go index 6f89f9e..194bb5d 100644 --- a/internal/api/api_client.go +++ b/internal/api/api_client.go @@ -22,10 +22,11 @@ func (e ClientError) Error() string { return string(e) } -func NewApiClient(httpClient HTTPClient, siriusUrl string) (*ApiClient, error) { +func NewApiClient(httpClient HTTPClient, siriusUrl string, backendUrl string) (*ApiClient, error) { return &ApiClient{ - http: httpClient, - siriusUrl: siriusUrl, + http: httpClient, + siriusUrl: siriusUrl, + backendUrl: backendUrl, }, nil } @@ -34,8 +35,9 @@ type HTTPClient interface { } type ApiClient struct { - http HTTPClient - siriusUrl string + http HTTPClient + siriusUrl string + backendUrl string } type StatusError struct { @@ -52,8 +54,8 @@ func (e StatusError) Data() interface{} { return e } -func (c *ApiClient) newSiriusRequest(ctx Context, method, path string, body io.Reader) (*http.Request, error) { - req, err := http.NewRequestWithContext(ctx.Context, method, c.siriusUrl+"/supervision-api/v1"+path, body) +func (c *ApiClient) newBackendRequest(ctx Context, method, path string, body io.Reader) (*http.Request, error) { + req, err := http.NewRequestWithContext(ctx.Context, method, c.backendUrl+path, body) if err != nil { return nil, err } diff --git a/internal/api/submit_download.go b/internal/api/download.go similarity index 86% rename from internal/api/submit_download.go rename to internal/api/download.go index c2987d6..7ad6b52 100644 --- a/internal/api/submit_download.go +++ b/internal/api/download.go @@ -7,7 +7,7 @@ import ( "net/http" ) -func (c *ApiClient) SubmitDownload(ctx Context, reportType string, reportJournalType string, reportScheduleType string, reportAccountType string, reportDebtType string, dateField string, dateFromField string, dateToField string, emailField string) error { +func (c *ApiClient) Download(ctx Context, reportType string, reportJournalType string, reportScheduleType string, reportAccountType string, reportDebtType string, dateField string, dateFromField string, dateToField string, emailField string) error { var body bytes.Buffer var dateTransformed *model.Date var toDateTransformed *model.Date @@ -43,7 +43,7 @@ func (c *ApiClient) SubmitDownload(ctx Context, reportType string, reportJournal return err } - req, err := c.newSiriusRequest(ctx, http.MethodPost, "/downloads", &body) + req, err := c.newBackendRequest(ctx, http.MethodGet, "/downloads", &body) if err != nil { return err diff --git a/internal/api/submit_download_test.go b/internal/api/download_test.go similarity index 69% rename from internal/api/submit_download_test.go rename to internal/api/download_test.go index 922964f..3ba78e5 100644 --- a/internal/api/submit_download_test.go +++ b/internal/api/download_test.go @@ -14,7 +14,7 @@ import ( func TestSubmitDownload(t *testing.T) { mockClient := SetUpTest() - client, _ := NewApiClient(mockClient, "http://localhost:3000") + client, _ := NewApiClient(mockClient, "http://localhost:3000", "") data := `{ "reportType": "AccountsReceivable", @@ -38,7 +38,7 @@ func TestSubmitDownload(t *testing.T) { }, nil } - err := client.SubmitDownload(getContext(nil), "AccountsReceivable", "", "", "BadDebtWriteOffReport", "", "11/05/2024", "01/04/2024", "31/03/2025", "SomeSortOfEmail@example.com") + err := client.Download(getContext(nil), "AccountsReceivable", "", "", "BadDebtWriteOffReport", "", "11/05/2024", "01/04/2024", "31/03/2025", "SomeSortOfEmail@example.com") assert.Equal(t, nil, err) } @@ -48,9 +48,9 @@ func TestSubmitDownloadUnauthorised(t *testing.T) { })) defer svr.Close() - client, _ := NewApiClient(http.DefaultClient, svr.URL) + client, _ := NewApiClient(http.DefaultClient, svr.URL, svr.URL) - err := client.SubmitDownload(getContext(nil), "AccountsReceivable", "", "", "BadDebtWriteOffReport", "", "11/05/2024", "01/04/2024", "31/03/2025", "SomeSortOfEmail@example.com") + err := client.Download(getContext(nil), "AccountsReceivable", "", "", "BadDebtWriteOffReport", "", "11/05/2024", "01/04/2024", "31/03/2025", "SomeSortOfEmail@example.com") assert.Equal(t, ErrUnauthorized.Error(), err.Error()) } @@ -61,20 +61,20 @@ func TestSubmitDownloadReturns500Error(t *testing.T) { })) defer svr.Close() - client, _ := NewApiClient(http.DefaultClient, svr.URL) + client, _ := NewApiClient(http.DefaultClient, svr.URL, svr.URL) - err := client.SubmitDownload(getContext(nil), "AccountsReceivable", "", "", "BadDebtWriteOffReport", "", "11/05/2024", "01/04/2024", "31/03/2025", "SomeSortOfEmail@example.com") + err := client.Download(getContext(nil), "AccountsReceivable", "", "", "BadDebtWriteOffReport", "", "11/05/2024", "01/04/2024", "31/03/2025", "SomeSortOfEmail@example.com") assert.Equal(t, StatusError{ Code: http.StatusInternalServerError, - URL: svr.URL + "/supervision-api/v1/downloads", - Method: http.MethodPost, + URL: svr.URL + "/downloads", + Method: http.MethodGet, }, err) } func TestSubmitDownloadReturnsBadRequestError(t *testing.T) { mockClient := SetUpTest() - client, _ := NewApiClient(mockClient, "http://localhost:3000") + client, _ := NewApiClient(mockClient, "http://localhost:3000", "") json := ` {"reasons":["StartDate","EndDate"]} @@ -89,7 +89,7 @@ func TestSubmitDownloadReturnsBadRequestError(t *testing.T) { }, nil } - err := client.SubmitDownload(getContext(nil), "AccountsReceivable", "", "", "BadDebtWriteOffReport", "", "11/05/2024", "01/04/2024", "31/03/2025", "SomeSortOfEmail@example.com") + err := client.Download(getContext(nil), "AccountsReceivable", "", "", "BadDebtWriteOffReport", "", "11/05/2024", "01/04/2024", "31/03/2025", "SomeSortOfEmail@example.com") expectedError := model.ValidationError{Message: "", Errors: model.ValidationErrors{"EndDate": map[string]string{"EndDate": "EndDate"}, "StartDate": map[string]string{"StartDate": "StartDate"}}} assert.Equal(t, expectedError, err) @@ -111,9 +111,9 @@ func TestSubmitDownloadReturnsValidationError(t *testing.T) { })) defer svr.Close() - client, _ := NewApiClient(http.DefaultClient, svr.URL) + client, _ := NewApiClient(http.DefaultClient, svr.URL, svr.URL) - err := client.SubmitDownload(getContext(nil), "", "", "", "", "", "", "", "", "") + err := client.Download(getContext(nil), "", "", "", "", "", "", "", "", "") expectedError := model.ValidationError{Message: "", Errors: model.ValidationErrors{"ReportType": map[string]string{"required": "Please select a report type"}}} assert.Equal(t, expectedError, err.(model.ValidationError)) } diff --git a/internal/model/journal_type.go b/internal/model/journal_type.go index dca9d03..eb8618e 100644 --- a/internal/model/journal_type.go +++ b/internal/model/journal_type.go @@ -3,7 +3,6 @@ package model var ReportJournalTypes = []ReportJournalType{ ReportTypeReceiptTransactions, ReportTypeNonReceiptTransactions, - ReportTypeMOTOCardPayments, } type ReportJournalType int @@ -12,7 +11,6 @@ const ( ReportTypeUnknown ReportJournalType = iota ReportTypeReceiptTransactions ReportTypeNonReceiptTransactions - ReportTypeMOTOCardPayments ) func (i ReportJournalType) String() string { @@ -25,8 +23,6 @@ func (i ReportJournalType) Translation() string { return "Receipt Transactions" case ReportTypeNonReceiptTransactions: return "Non Receipt Transactions" - case ReportTypeMOTOCardPayments: - return "Accounts Receivable" default: return "" } @@ -38,8 +34,6 @@ func (i ReportJournalType) Key() string { return "ReceiptTransactions" case ReportTypeNonReceiptTransactions: return "NonReceiptTransactions" - case ReportTypeMOTOCardPayments: - return "AccountsReceivable" default: return "" } diff --git a/internal/model/schedule_type.go b/internal/model/schedule_type.go index d8b7701..3753424 100644 --- a/internal/model/schedule_type.go +++ b/internal/model/schedule_type.go @@ -1,6 +1,7 @@ package model var ReportScheduleTypes = []ReportScheduleType{ + ReportTypeMOTOCardPayments, ReportTypeOnlineCardPayments, ReportOPGBACSTransfer, ReportSupervisionBACSTransfer, @@ -33,6 +34,7 @@ type ReportScheduleType int const ( ReportScheduleTypeUnknown ReportScheduleType = iota + ReportTypeMOTOCardPayments ReportTypeOnlineCardPayments ReportOPGBACSTransfer ReportSupervisionBACSTransfer @@ -67,6 +69,8 @@ func (i ReportScheduleType) String() string { func (i ReportScheduleType) Translation() string { switch i { + case ReportTypeMOTOCardPayments: + return "Accounts Receivable" case ReportTypeOnlineCardPayments: return "Online Card Payments" case ReportOPGBACSTransfer: @@ -126,6 +130,8 @@ func (i ReportScheduleType) Translation() string { func (i ReportScheduleType) Key() string { switch i { + case ReportTypeMOTOCardPayments: + return "Accounts Receivable" case ReportTypeOnlineCardPayments: return "OnlineCardPayments" case ReportOPGBACSTransfer: diff --git a/internal/server/download.go b/internal/server/download.go new file mode 100644 index 0000000..5e4c514 --- /dev/null +++ b/internal/server/download.go @@ -0,0 +1,50 @@ +package server + +import ( + "errors" + "github.com/opg-sirius-finance-admin/internal/api" + "github.com/opg-sirius-finance-admin/internal/model" + "github.com/opg-sirius-finance-admin/internal/util/util" + "net/http" +) + +type DownloadHandler struct { + router +} + +func (h *DownloadHandler) render(v AppVars, w http.ResponseWriter, r *http.Request) error { + ctx := getContext(r) + params := r.URL.Query() + + var ( + reportType = params.Get("reportType") + reportJournalType = params.Get("reportJournalType") + reportScheduleType = params.Get("reportScheduleType") + reportAccountType = params.Get("reportAccountType") + reportDebtType = params.Get("reportDebtType") + dateField = params.Get("dateField") + dateFromField = params.Get("dateFromField") + dateToField = params.Get("dateToField") + emailField = params.Get("emailField") + ) + + err := h.Client().Download(ctx, reportType, reportJournalType, reportScheduleType, reportAccountType, reportDebtType, dateField, dateFromField, dateToField, emailField) + + if err != nil { + var ( + valErr model.ValidationError + stErr api.StatusError + ) + if errors.As(err, &valErr) { + data := AppVars{Errors: util.RenameErrors(valErr.Errors)} + w.WriteHeader(http.StatusUnprocessableEntity) + err = h.execute(w, r, data) + } else if errors.As(err, &stErr) { + data := AppVars{Error: stErr.Error()} + w.WriteHeader(stErr.Code) + err = h.execute(w, r, data) + } + } + + return err +} diff --git a/internal/server/submit_download_test.go b/internal/server/download_test.go similarity index 82% rename from internal/server/submit_download_test.go rename to internal/server/download_test.go index 0154d91..b285b4d 100644 --- a/internal/server/submit_download_test.go +++ b/internal/server/download_test.go @@ -10,7 +10,7 @@ import ( "testing" ) -func TestSubmitManualInvoiceSuccess(t *testing.T) { +func TestDownloadSuccess(t *testing.T) { form := url.Values{ "reportType": {"AccountsReceivable"}, "reportJournalType": {""}, @@ -27,7 +27,7 @@ func TestSubmitManualInvoiceSuccess(t *testing.T) { ro := &mockRoute{client: client} w := httptest.NewRecorder() - r, _ := http.NewRequest(http.MethodPost, "/download", strings.NewReader(form.Encode())) + r, _ := http.NewRequest(http.MethodGet, "/download", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", "application/x-www-form-urlencoded") r.SetPathValue("clientId", "1") @@ -37,14 +37,14 @@ func TestSubmitManualInvoiceSuccess(t *testing.T) { appVars.EnvironmentVars.Prefix = "prefix" - sut := SubmitDownloadHandler{ro} + sut := DownloadHandler{ro} err := sut.render(appVars, w, r) assert.Nil(t, err) } -func TestSubmitDownloadValidationErrors(t *testing.T) { +func TestDownloadValidationErrors(t *testing.T) { assert := assert.New(t) client := &mockApiClient{} ro := &mockRoute{client: client} @@ -60,7 +60,7 @@ func TestSubmitDownloadValidationErrors(t *testing.T) { } w := httptest.NewRecorder() - r, _ := http.NewRequest(http.MethodPost, "/invoices", nil) + r, _ := http.NewRequest(http.MethodGet, "/download", nil) r.Header.Add("Content-Type", "application/x-www-form-urlencoded") r.SetPathValue("clientId", "1") @@ -68,7 +68,7 @@ func TestSubmitDownloadValidationErrors(t *testing.T) { Path: "/add", } - sut := SubmitDownloadHandler{ro} + sut := DownloadHandler{ro} err := sut.render(appVars, w, r) assert.Nil(err) assert.Equal("422 Unprocessable Entity", w.Result().Status) diff --git a/internal/server/environment_vars.go b/internal/server/environment_vars.go index dea975a..6f4f16f 100644 --- a/internal/server/environment_vars.go +++ b/internal/server/environment_vars.go @@ -9,6 +9,7 @@ type EnvironmentVars struct { WebDir string SiriusURL string SiriusPublicURL string + BackendUrl string Prefix string } @@ -19,6 +20,7 @@ func NewEnvironmentVars() EnvironmentVars { SiriusURL: getEnv("SIRIUS_URL", "http://host.docker.internal:8080"), SiriusPublicURL: getEnv("SIRIUS_PUBLIC_URL", ""), Prefix: getEnv("PREFIX", ""), + BackendUrl: getEnv("BACKEND_URL", ""), } } diff --git a/internal/server/server.go b/internal/server/server.go index d623966..c58a597 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -14,7 +14,7 @@ import ( ) type ApiClient interface { - SubmitDownload(api.Context, string, string, string, string, string, string, string, string, string) error + Download(api.Context, string, string, string, string, string, string, string, string, string) error } type router interface { @@ -40,7 +40,7 @@ func New(logger *slog.Logger, client ApiClient, templates map[string]*template.T handleMux("GET /uploads", &GetUploadsHandler{&route{client: client, tmpl: templates["uploads.gotmpl"], partial: "uploads"}}) handleMux("GET /annual-invoicing-letters", &GetAnnualInvoicingLettersHandler{&route{client: client, tmpl: templates["annual_invoicing_letters.gotmpl"], partial: "annual-invoicing-letters"}}) - handleMux("POST /downloads", &SubmitDownloadHandler{&route{client: client, tmpl: templates["downloads.gotmpl"], partial: "error-summary"}}) + handleMux("GET /download", &DownloadHandler{&route{client: client, tmpl: templates["downloads.gotmpl"], partial: "error-summary"}}) mux.Handle("/health-check", healthCheck()) diff --git a/internal/server/server_test.go b/internal/server/server_test.go index adfcd01..2d3f45c 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -51,6 +51,6 @@ type mockApiClient struct { error error //nolint:golint,unused } -func (m mockApiClient) SubmitDownload(context api.Context, s string, s2 string, s3 string, s4 string, s5 string, s6 string, s7 string, s8 string, s9 string) error { +func (m mockApiClient) Download(context api.Context, s string, s2 string, s3 string, s4 string, s5 string, s6 string, s7 string, s8 string, s9 string) error { return m.error } diff --git a/internal/server/submit_download.go b/internal/server/submit_download.go deleted file mode 100644 index 65a2e5e..0000000 --- a/internal/server/submit_download.go +++ /dev/null @@ -1,49 +0,0 @@ -package server - -import ( - "errors" - "github.com/opg-sirius-finance-admin/internal/api" - "github.com/opg-sirius-finance-admin/internal/model" - "github.com/opg-sirius-finance-admin/internal/util/util" - "net/http" -) - -type SubmitDownloadHandler struct { - router -} - -func (h *SubmitDownloadHandler) render(v AppVars, w http.ResponseWriter, r *http.Request) error { - ctx := getContext(r) - - var ( - reportType = r.PostFormValue("reportType") - reportJournalType = r.PostFormValue("reportJournalType") - reportScheduleType = r.PostFormValue("reportScheduleType") - reportAccountType = r.PostFormValue("reportAccountType") - reportDebtType = r.PostFormValue("reportDebtType") - dateField = r.PostFormValue("dateField") - dateFromField = r.PostFormValue("dateFromField") - dateToField = r.PostFormValue("dateToField") - emailField = r.PostFormValue("emailField") - ) - - err := h.Client().SubmitDownload(ctx, reportType, reportJournalType, reportScheduleType, reportAccountType, reportDebtType, dateField, dateFromField, dateToField, emailField) - - if err != nil { - var ( - valErr model.ValidationError - stErr api.StatusError - ) - if errors.As(err, &valErr) { - data := AppVars{Errors: util.RenameErrors(valErr.Errors)} - w.WriteHeader(http.StatusUnprocessableEntity) - err = h.execute(w, r, data) - } else if errors.As(err, &stErr) { - data := AppVars{Error: stErr.Error()} - w.WriteHeader(stErr.Code) - err = h.execute(w, r, data) - } - } - - return err -} diff --git a/internal/util/util/translate.go b/internal/util/util/translate.go index 3d56b9a..fb35e9f 100644 --- a/internal/util/util/translate.go +++ b/internal/util/util/translate.go @@ -19,10 +19,10 @@ var validationMappings = map[string]map[string]pair{ "date-in-the-past": pair{"Date", "The report date must be today or in the past"}, }, "FromDate": { - "FromDate": pair{"FromDate", "From date must be before to date"}, + "FromDate": pair{"FromDate", "Date From must be before Date To"}, }, "ToDate": { - "ToDate": pair{"ToDate", "To date must be after from date"}, + "ToDate": pair{"ToDate", "Date To must be after Date From"}, }, } diff --git a/main.go b/main.go index fc8c479..c15d784 100644 --- a/main.go +++ b/main.go @@ -39,7 +39,7 @@ func run(ctx context.Context, logger *slog.Logger) error { } envVars := server.NewEnvironmentVars() - client, err := api.NewApiClient(http.DefaultClient, envVars.SiriusURL) + client, err := api.NewApiClient(http.DefaultClient, envVars.SiriusURL, envVars.BackendUrl) if err != nil { return err } diff --git a/web/template/downloads.gotmpl b/web/template/downloads.gotmpl index 5ba3d99..17005bb 100644 --- a/web/template/downloads.gotmpl +++ b/web/template/downloads.gotmpl @@ -11,8 +11,8 @@
From 87a68035d181afd9128bbaa00aee6406a153df8f Mon Sep 17 00:00:00 2001 From: nicholassully Date: Tue, 13 Aug 2024 13:36:29 +0100 Subject: [PATCH 3/7] pfs-116 renaming fields --- internal/api/download.go | 16 ++++++++-------- internal/api/download_test.go | 8 ++++---- internal/model/download.go | 2 +- internal/server/download.go | 10 +++++----- internal/server/download_test.go | 8 ++++---- web/template/downloads.gotmpl | 8 ++++---- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/internal/api/download.go b/internal/api/download.go index 7ad6b52..6731413 100644 --- a/internal/api/download.go +++ b/internal/api/download.go @@ -7,24 +7,24 @@ import ( "net/http" ) -func (c *ApiClient) Download(ctx Context, reportType string, reportJournalType string, reportScheduleType string, reportAccountType string, reportDebtType string, dateField string, dateFromField string, dateToField string, emailField string) error { +func (c *ApiClient) Download(ctx Context, reportType string, reportJournalType string, reportScheduleType string, reportAccountType string, reportDebtType string, dateOfTransaction string, dateFrom string, dateTo string, email string) error { var body bytes.Buffer var dateTransformed *model.Date var toDateTransformed *model.Date var fromDateTransformed *model.Date - if dateField != "" { - raisedDateFormatted := model.NewDate(dateField) + if dateOfTransaction != "" { + raisedDateFormatted := model.NewDate(dateOfTransaction) dateTransformed = &raisedDateFormatted } - if dateToField != "" { - startDateFormatted := model.NewDate(dateToField) + if dateTo != "" { + startDateFormatted := model.NewDate(dateTo) toDateTransformed = &startDateFormatted } - if dateFromField != "" { - endDateFormatted := model.NewDate(dateFromField) + if dateFrom != "" { + endDateFormatted := model.NewDate(dateFrom) fromDateTransformed = &endDateFormatted } @@ -37,7 +37,7 @@ func (c *ApiClient) Download(ctx Context, reportType string, reportJournalType s DateField: dateTransformed, ToDateField: toDateTransformed, FromDateField: fromDateTransformed, - Email: emailField, + Email: email, }) if err != nil { return err diff --git a/internal/api/download_test.go b/internal/api/download_test.go index 3ba78e5..9436ae0 100644 --- a/internal/api/download_test.go +++ b/internal/api/download_test.go @@ -22,10 +22,10 @@ func TestSubmitDownload(t *testing.T) { "reportScheduleType": "", "reportAccountType": "BadDebtWriteOffReport", "reportDebtType": "", - "dateField": "11/05/2024", - "dateFromField": "01/04/2024", - "dateToField": "31/03/2025", - "emailField": "SomeSortOfEmail@example.com", + "dateOfTransaction": "11/05/2024", + "dateFrom": "01/04/2024", + "dateTo": "31/03/2025", + "email": "SomeSortOfEmail@example.com", } ` diff --git a/internal/model/download.go b/internal/model/download.go index 2aad705..727e0e0 100644 --- a/internal/model/download.go +++ b/internal/model/download.go @@ -6,7 +6,7 @@ type Download struct { ReportScheduleType string `json:"reportScheduleType"` ReportAccountType string `json:"reportAccountType"` ReportDebtType string `json:"reportDebtType"` - DateField *Date `json:"dateField,omitempty"` + DateField *Date `json:"dateOfTransaction,omitempty"` ToDateField *Date `json:"toDateField,omitempty"` FromDateField *Date `json:"fromDateField,omitempty"` Email string `json:"email"` diff --git a/internal/server/download.go b/internal/server/download.go index 5e4c514..b82bfc7 100644 --- a/internal/server/download.go +++ b/internal/server/download.go @@ -22,13 +22,13 @@ func (h *DownloadHandler) render(v AppVars, w http.ResponseWriter, r *http.Reque reportScheduleType = params.Get("reportScheduleType") reportAccountType = params.Get("reportAccountType") reportDebtType = params.Get("reportDebtType") - dateField = params.Get("dateField") - dateFromField = params.Get("dateFromField") - dateToField = params.Get("dateToField") - emailField = params.Get("emailField") + dateOfTransaction = params.Get("dateOfTransaction") + dateFrom = params.Get("dateFrom") + dateTo = params.Get("dateTo") + email = params.Get("email") ) - err := h.Client().Download(ctx, reportType, reportJournalType, reportScheduleType, reportAccountType, reportDebtType, dateField, dateFromField, dateToField, emailField) + err := h.Client().Download(ctx, reportType, reportJournalType, reportScheduleType, reportAccountType, reportDebtType, dateOfTransaction, dateFrom, dateTo, email) if err != nil { var ( diff --git a/internal/server/download_test.go b/internal/server/download_test.go index b285b4d..f741fdf 100644 --- a/internal/server/download_test.go +++ b/internal/server/download_test.go @@ -17,10 +17,10 @@ func TestDownloadSuccess(t *testing.T) { "reportScheduleType": {""}, "reportAccountType": {"BadDebtWriteOffReport"}, "reportDebtType": {""}, - "dateField": {"11/05/2024"}, - "dateFromField": {"01/04/2024"}, - "dateToField": {"31/03/2025"}, - "emailField": {"SomeSortOfEmail@example.com"}, + "dateOfTransaction": {"11/05/2024"}, + "dateFrom": {"01/04/2024"}, + "dateTo": {"31/03/2025"}, + "email": {"SomeSortOfEmail@example.com"}, } client := mockApiClient{} diff --git a/web/template/downloads.gotmpl b/web/template/downloads.gotmpl index 17005bb..c996de7 100644 --- a/web/template/downloads.gotmpl +++ b/web/template/downloads.gotmpl @@ -96,7 +96,7 @@ Date - +
@@ -106,7 +106,7 @@ Date from - +