From 25674c04c8f29355db0465aced3c2ea53e0311fa Mon Sep 17 00:00:00 2001 From: MaysWind Date: Wed, 11 Sep 2024 02:07:42 +0800 Subject: [PATCH] allow import file without sub category name --- .../data_table_transaction_data_converter.go | 6 ------ ...g_transaction_data_plain_text_converter_test.go | 14 -------------- 2 files changed, 20 deletions(-) diff --git a/pkg/converters/data_table_transaction_data_converter.go b/pkg/converters/data_table_transaction_data_converter.go index e91dafd5..f89f09be 100644 --- a/pkg/converters/data_table_transaction_data_converter.go +++ b/pkg/converters/data_table_transaction_data_converter.go @@ -288,12 +288,6 @@ func (c *DataTableTransactionDataImporter) parseImportedData(ctx core.Context, u } subCategoryName = dataRow.GetData(subCategoryColumnIdx) - - if subCategoryName == "" { - log.Errorf(ctx, "[data_table_transaction_data_converter.parseImportedData] sub category type is empty in data row \"index:%d\" for user \"uid:%d\"", dataRowIndex, user.Uid) - return nil, nil, nil, nil, errs.ErrSubCategoryNameCannotBeBlank - } - subCategory, exists := categoryMap[subCategoryName] if !exists { diff --git a/pkg/converters/ezbookkeeping_transaction_data_plain_text_converter_test.go b/pkg/converters/ezbookkeeping_transaction_data_plain_text_converter_test.go index 5617ffe6..294eada9 100644 --- a/pkg/converters/ezbookkeeping_transaction_data_plain_text_converter_test.go +++ b/pkg/converters/ezbookkeeping_transaction_data_plain_text_converter_test.go @@ -246,20 +246,6 @@ func TestEzBookKeepingPlainFileConverterParseImportedData_ParseInvalidTimezone(t assert.NotNil(t, err) } -func TestEzBookKeepingPlainFileConverterParseImportedData_ParseInvalidSubCategoryName(t *testing.T) { - converter := EzBookKeepingTransactionDataCSVFileConverter - context := core.NewNullContext() - - user := &models.User{ - Uid: 1234567890, - DefaultCurrency: "CNY", - } - - _, _, _, _, err := converter.ParseImportedData(context, user, []byte("Time,Type,Sub Category,Account,Amount,Account2,Account2 Amount\n"+ - "2024-09-01 12:34:56,Expense,,Test Account,123.45,,"), 0, nil, nil, nil) - assert.NotNil(t, err) -} - func TestEzBookKeepingPlainFileConverterParseImportedData_ParseInvalidAccountName(t *testing.T) { converter := EzBookKeepingTransactionDataCSVFileConverter context := core.NewNullContext()