diff --git a/pkg/api/data_managements.go b/pkg/api/data_managements.go index 7acca331..3312fadc 100644 --- a/pkg/api/data_managements.go +++ b/pkg/api/data_managements.go @@ -216,7 +216,7 @@ func (a *DataManagementsApi) getExportedFileContent(c *core.Context, fileType st dataExporter = a.ezBookKeepingCsvExporter } - result, err := dataExporter.ToExportedContent(uid, timezone, allTransactions, accountMap, categoryMap, tagMap, tagIndexs) + result, err := dataExporter.ToExportedContent(uid, allTransactions, accountMap, categoryMap, tagMap, tagIndexs) if err != nil { log.ErrorfWithRequestId(c, "[data_managements.ExportDataHandler] failed to get csv format exported data for \"uid:%d\", because %s", uid, err.Error()) diff --git a/pkg/cli/user_data.go b/pkg/cli/user_data.go index ae226769..67b6a559 100644 --- a/pkg/cli/user_data.go +++ b/pkg/cli/user_data.go @@ -574,7 +574,7 @@ func (l *UserDataCli) ExportTransaction(c *cli.Context, username string, fileTyp dataExporter = l.ezBookKeepingCsvExporter } - result, err := dataExporter.ToExportedContent(uid, time.Local, allTransactions, accountMap, categoryMap, tagMap, tagIndexs) + result, err := dataExporter.ToExportedContent(uid, allTransactions, accountMap, categoryMap, tagMap, tagIndexs) if err != nil { log.BootErrorf("[user_data.ExportTransaction] failed to get csv format exported data for \"%s\", because %s", username, err.Error()) diff --git a/pkg/converters/data_converter.go b/pkg/converters/data_converter.go index bb5c3bd2..999f3f5f 100644 --- a/pkg/converters/data_converter.go +++ b/pkg/converters/data_converter.go @@ -1,13 +1,11 @@ package converters import ( - "time" - "github.com/mayswind/ezbookkeeping/pkg/models" ) // DataConverter defines the structure of data exporter type DataConverter interface { // ToExportedContent returns the exported data - ToExportedContent(uid int64, timezone *time.Location, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) + ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) } diff --git a/pkg/converters/ezbookkeeping_csv_file.go b/pkg/converters/ezbookkeeping_csv_file.go index f1decd05..f0dc45f7 100644 --- a/pkg/converters/ezbookkeeping_csv_file.go +++ b/pkg/converters/ezbookkeeping_csv_file.go @@ -1,8 +1,6 @@ package converters import ( - "time" - "github.com/mayswind/ezbookkeeping/pkg/models" ) @@ -12,6 +10,6 @@ type EzBookKeepingCSVFileExporter struct { } // ToExportedContent returns the exported CSV data -func (e *EzBookKeepingCSVFileExporter) ToExportedContent(uid int64, timezone *time.Location, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) { - return e.toExportedContent(uid, ",", timezone, transactions, accountMap, categoryMap, tagMap, allTagIndexs) +func (e *EzBookKeepingCSVFileExporter) ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) { + return e.toExportedContent(uid, ",", transactions, accountMap, categoryMap, tagMap, allTagIndexs) } diff --git a/pkg/converters/ezbookkeeping_plain_file.go b/pkg/converters/ezbookkeeping_plain_file.go index db9ce8c4..da044154 100644 --- a/pkg/converters/ezbookkeeping_plain_file.go +++ b/pkg/converters/ezbookkeeping_plain_file.go @@ -17,7 +17,7 @@ const headerLine = "Time,Timezone,Type,Category,Sub Category,Account,Account Cur const dataLineFormat = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n" // toExportedContent returns the exported plain data -func (e *EzBookKeepingPlainFileExporter) toExportedContent(uid int64, separator string, timezone *time.Location, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) { +func (e *EzBookKeepingPlainFileExporter) toExportedContent(uid int64, separator string, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) { var ret strings.Builder ret.Grow(len(transactions) * 100) diff --git a/pkg/converters/ezbookkeeping_tsv_file.go b/pkg/converters/ezbookkeeping_tsv_file.go index 811a6302..daf72b51 100644 --- a/pkg/converters/ezbookkeeping_tsv_file.go +++ b/pkg/converters/ezbookkeeping_tsv_file.go @@ -1,8 +1,6 @@ package converters import ( - "time" - "github.com/mayswind/ezbookkeeping/pkg/models" ) @@ -12,6 +10,6 @@ type EzBookKeepingTSVFileExporter struct { } // ToExportedContent returns the exported TSV data -func (e *EzBookKeepingTSVFileExporter) ToExportedContent(uid int64, timezone *time.Location, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) { - return e.toExportedContent(uid, "\t", timezone, transactions, accountMap, categoryMap, tagMap, allTagIndexs) +func (e *EzBookKeepingTSVFileExporter) ToExportedContent(uid int64, transactions []*models.Transaction, accountMap map[int64]*models.Account, categoryMap map[int64]*models.TransactionCategory, tagMap map[int64]*models.TransactionTag, allTagIndexs map[int64][]int64) ([]byte, error) { + return e.toExportedContent(uid, "\t", transactions, accountMap, categoryMap, tagMap, allTagIndexs) }