102 lines
5.3 KiB
Go
102 lines
5.3 KiB
Go
package converters
|
|
|
|
import (
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/alipay"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/beancount"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/camt"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/converter"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/datatable"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/default"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/dsv"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/feidee"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/fireflyIII"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/gnucash"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/iif"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/jdcom"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/mt"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/ofx"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/qif"
|
|
"github.com/mayswind/ezbookkeeping/pkg/converters/wechat"
|
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
|
)
|
|
|
|
// GetTransactionDataExporter returns the transaction data exporter according to the file type
|
|
func GetTransactionDataExporter(fileType string) converter.TransactionDataExporter {
|
|
if fileType == "csv" {
|
|
return _default.DefaultTransactionDataCSVFileConverter
|
|
} else if fileType == "tsv" {
|
|
return _default.DefaultTransactionDataTSVFileConverter
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// GetTransactionDataImporter returns the transaction data importer according to the file type
|
|
func GetTransactionDataImporter(fileType string) (converter.TransactionDataImporter, error) {
|
|
if fileType == "ezbookkeeping_csv" {
|
|
return _default.DefaultTransactionDataCSVFileConverter, nil
|
|
} else if fileType == "ezbookkeeping_tsv" {
|
|
return _default.DefaultTransactionDataTSVFileConverter, nil
|
|
} else if fileType == "ezbookkeeping_json" {
|
|
return _default.DefaultTransactionDataJsonFileImporter, nil
|
|
} else if fileType == "ofx" {
|
|
return ofx.OFXTransactionDataImporter, nil
|
|
} else if fileType == "qfx" {
|
|
return ofx.OFXTransactionDataImporter, nil
|
|
} else if fileType == "qif_ymd" {
|
|
return qif.QifYearMonthDayTransactionDataImporter, nil
|
|
} else if fileType == "qif_mdy" {
|
|
return qif.QifMonthDayYearTransactionDataImporter, nil
|
|
} else if fileType == "qif_dmy" {
|
|
return qif.QifDayMonthYearTransactionDataImporter, nil
|
|
} else if fileType == "iif" {
|
|
return iif.IifTransactionDataFileImporter, nil
|
|
} else if fileType == "camt052" {
|
|
return camt.Camt052TransactionDataImporter, nil
|
|
} else if fileType == "camt053" {
|
|
return camt.Camt053TransactionDataImporter, nil
|
|
} else if fileType == "mt940" {
|
|
return mt.MT940TransactionDataFileImporter, nil
|
|
} else if fileType == "gnucash" {
|
|
return gnucash.GnuCashTransactionDataImporter, nil
|
|
} else if fileType == "firefly_iii_csv" {
|
|
return fireflyIII.FireflyIIITransactionDataCsvFileImporter, nil
|
|
} else if fileType == "beancount" {
|
|
return beancount.BeancountTransactionDataImporter, nil
|
|
} else if fileType == "feidee_mymoney_csv" {
|
|
return feidee.FeideeMymoneyAppTransactionDataCsvFileImporter, nil
|
|
} else if fileType == "feidee_mymoney_xls" {
|
|
return feidee.FeideeMymoneyWebTransactionDataXlsFileImporter, nil
|
|
} else if fileType == "feidee_mymoney_elecloud_xlsx" {
|
|
return feidee.FeideeMymoneyElecloudTransactionDataXlsxFileImporter, nil
|
|
} else if fileType == "alipay_app_csv" {
|
|
return alipay.AlipayAppTransactionDataCsvFileImporter, nil
|
|
} else if fileType == "alipay_web_csv" {
|
|
return alipay.AlipayWebTransactionDataCsvFileImporter, nil
|
|
} else if fileType == "wechat_pay_app_xlsx" {
|
|
return wechat.WeChatPayTransactionDataXlsxFileImporter, nil
|
|
} else if fileType == "wechat_pay_app_csv" {
|
|
return wechat.WeChatPayTransactionDataCsvFileImporter, nil
|
|
} else if fileType == "jdcom_finance_app_csv" {
|
|
return jdcom.JDComFinanceTransactionDataCsvFileImporter, nil
|
|
} else {
|
|
return nil, errs.ErrImportFileTypeNotSupported
|
|
}
|
|
}
|
|
|
|
// IsCustomDelimiterSeparatedValuesFileType returns whether the file type is the delimiter-separated values file type
|
|
func IsCustomDelimiterSeparatedValuesFileType(fileType string) bool {
|
|
return dsv.IsDelimiterSeparatedValuesFileType(fileType)
|
|
}
|
|
|
|
// CreateNewDelimiterSeparatedValuesDataParser returns a new delimiter-separated values data parser according to the file type and encoding
|
|
func CreateNewDelimiterSeparatedValuesDataParser(fileType string, fileEncoding string) (dsv.CustomTransactionDataDsvFileParser, error) {
|
|
return dsv.CreateNewCustomTransactionDataDsvFileParser(fileType, fileEncoding)
|
|
}
|
|
|
|
// CreateNewDelimiterSeparatedValuesDataImporter returns a new delimiter-separated values data importer according to the file type and encoding
|
|
func CreateNewDelimiterSeparatedValuesDataImporter(fileType string, fileEncoding string, columnIndexMapping map[datatable.TransactionDataTableColumn]int, transactionTypeNameMapping map[string]models.TransactionType, hasHeaderLine bool, timeFormat string, timezoneFormat string, amountDecimalSeparator string, amountDigitGroupingSymbol string, geoLocationSeparator string, geoLocationOrder string, transactionTagSeparator string) (converter.TransactionDataImporter, error) {
|
|
return dsv.CreateNewCustomTransactionDataDsvFileImporter(fileType, fileEncoding, columnIndexMapping, transactionTypeNameMapping, hasHeaderLine, timeFormat, timezoneFormat, amountDecimalSeparator, amountDigitGroupingSymbol, geoLocationSeparator, geoLocationOrder, transactionTagSeparator)
|
|
}
|