import latest wechat pay billing file format
This commit is contained in:
@@ -69,6 +69,8 @@ func GetTransactionDataImporter(fileType string) (converter.TransactionDataImpor
|
|||||||
return alipay.AlipayAppTransactionDataCsvFileImporter, nil
|
return alipay.AlipayAppTransactionDataCsvFileImporter, nil
|
||||||
} else if fileType == "alipay_web_csv" {
|
} else if fileType == "alipay_web_csv" {
|
||||||
return alipay.AlipayWebTransactionDataCsvFileImporter, nil
|
return alipay.AlipayWebTransactionDataCsvFileImporter, nil
|
||||||
|
} else if fileType == "wechat_pay_app_xlsx" {
|
||||||
|
return wechat.WeChatPayTransactionDataXlsxFileImporter, nil
|
||||||
} else if fileType == "wechat_pay_app_csv" {
|
} else if fileType == "wechat_pay_app_csv" {
|
||||||
return wechat.WeChatPayTransactionDataCsvFileImporter, nil
|
return wechat.WeChatPayTransactionDataCsvFileImporter, nil
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -15,22 +15,6 @@ import (
|
|||||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
var wechatPayTransactionSupportedColumns = map[datatable.TransactionDataTableColumn]bool{
|
|
||||||
datatable.TRANSACTION_DATA_TABLE_TRANSACTION_TIME: true,
|
|
||||||
datatable.TRANSACTION_DATA_TABLE_TRANSACTION_TYPE: true,
|
|
||||||
datatable.TRANSACTION_DATA_TABLE_SUB_CATEGORY: true,
|
|
||||||
datatable.TRANSACTION_DATA_TABLE_ACCOUNT_NAME: true,
|
|
||||||
datatable.TRANSACTION_DATA_TABLE_AMOUNT: true,
|
|
||||||
datatable.TRANSACTION_DATA_TABLE_RELATED_ACCOUNT_NAME: true,
|
|
||||||
datatable.TRANSACTION_DATA_TABLE_DESCRIPTION: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
var wechatPayTransactionTypeNameMapping = map[models.TransactionType]string{
|
|
||||||
models.TRANSACTION_TYPE_INCOME: "收入",
|
|
||||||
models.TRANSACTION_TYPE_EXPENSE: "支出",
|
|
||||||
models.TRANSACTION_TYPE_TRANSFER: "/",
|
|
||||||
}
|
|
||||||
|
|
||||||
// wechatPayTransactionDataCsvFileImporter defines the structure of wechatPay csv importer for transaction data
|
// wechatPayTransactionDataCsvFileImporter defines the structure of wechatPay csv importer for transaction data
|
||||||
type wechatPayTransactionDataCsvFileImporter struct {
|
type wechatPayTransactionDataCsvFileImporter struct {
|
||||||
fileHeaderLineBeginning string
|
fileHeaderLineBeginning string
|
||||||
|
|||||||
@@ -29,6 +29,22 @@ const wechatPayTransactionDataCategoryTransferFromWeChatWallet = "零钱提现"
|
|||||||
|
|
||||||
const wechatPayTransactionDataStatusRefundName = "退款"
|
const wechatPayTransactionDataStatusRefundName = "退款"
|
||||||
|
|
||||||
|
var wechatPayTransactionSupportedColumns = map[datatable.TransactionDataTableColumn]bool{
|
||||||
|
datatable.TRANSACTION_DATA_TABLE_TRANSACTION_TIME: true,
|
||||||
|
datatable.TRANSACTION_DATA_TABLE_TRANSACTION_TYPE: true,
|
||||||
|
datatable.TRANSACTION_DATA_TABLE_SUB_CATEGORY: true,
|
||||||
|
datatable.TRANSACTION_DATA_TABLE_ACCOUNT_NAME: true,
|
||||||
|
datatable.TRANSACTION_DATA_TABLE_AMOUNT: true,
|
||||||
|
datatable.TRANSACTION_DATA_TABLE_RELATED_ACCOUNT_NAME: true,
|
||||||
|
datatable.TRANSACTION_DATA_TABLE_DESCRIPTION: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
var wechatPayTransactionTypeNameMapping = map[models.TransactionType]string{
|
||||||
|
models.TRANSACTION_TYPE_INCOME: "收入",
|
||||||
|
models.TRANSACTION_TYPE_EXPENSE: "支出",
|
||||||
|
models.TRANSACTION_TYPE_TRANSFER: "/",
|
||||||
|
}
|
||||||
|
|
||||||
// weChatPayTransactionDataRowParser defines the structure of wechat pay transaction data row parser
|
// weChatPayTransactionDataRowParser defines the structure of wechat pay transaction data row parser
|
||||||
type weChatPayTransactionDataRowParser struct {
|
type weChatPayTransactionDataRowParser struct {
|
||||||
existedOriginalDataColumns map[string]bool
|
existedOriginalDataColumns map[string]bool
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package wechat
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/converters/converter"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/converters/datatable"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/converters/excel"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
|
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
// wechatPayTransactionDataXlsxFileImporter defines the structure of wechatPay xlsx importer for transaction data
|
||||||
|
type wechatPayTransactionDataXlsxFileImporter struct {
|
||||||
|
dataHeaderStartContentBeginning string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize a webchat pay transaction data xlsx file importer singleton instance
|
||||||
|
var (
|
||||||
|
WeChatPayTransactionDataXlsxFileImporter = &wechatPayTransactionDataXlsxFileImporter{}
|
||||||
|
)
|
||||||
|
|
||||||
|
// ParseImportedData returns the imported data by parsing the wechat pay transaction csv data
|
||||||
|
func (c *wechatPayTransactionDataXlsxFileImporter) ParseImportedData(ctx core.Context, user *models.User, data []byte, defaultTimezoneOffset int16, accountMap map[string]*models.Account, expenseCategoryMap map[string]map[string]*models.TransactionCategory, incomeCategoryMap map[string]map[string]*models.TransactionCategory, transferCategoryMap map[string]map[string]*models.TransactionCategory, tagMap map[string]*models.TransactionTag) (models.ImportedTransactionSlice, []*models.Account, []*models.TransactionCategory, []*models.TransactionCategory, []*models.TransactionCategory, []*models.TransactionTag, error) {
|
||||||
|
xlsxDataTable, err := excel.CreateNewExcelOOXMLFileBasicDataTable(data, false)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, nil, nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
dataTable, err := createNewWeChatPayTransactionBasicDataTable(ctx, xlsxDataTable)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, nil, nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
commonDataTable := datatable.CreateNewCommonDataTableFromBasicDataTable(dataTable)
|
||||||
|
|
||||||
|
if !commonDataTable.HasColumn(wechatPayTransactionTimeColumnName) ||
|
||||||
|
!commonDataTable.HasColumn(wechatPayTransactionCategoryColumnName) ||
|
||||||
|
!commonDataTable.HasColumn(wechatPayTransactionTypeColumnName) ||
|
||||||
|
!commonDataTable.HasColumn(wechatPayTransactionAmountColumnName) ||
|
||||||
|
!commonDataTable.HasColumn(wechatPayTransactionStatusColumnName) {
|
||||||
|
log.Errorf(ctx, "[wechat_pay_transaction_data_xlsx_file_importer.ParseImportedData] cannot parse wechat pay xlsx data, because missing essential columns in header row")
|
||||||
|
return nil, nil, nil, nil, nil, nil, errs.ErrMissingRequiredFieldInHeaderRow
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionRowParser := createWeChatPayTransactionDataRowParser(dataTable.HeaderColumnNames())
|
||||||
|
transactionDataTable := datatable.CreateNewTransactionDataTableFromCommonDataTable(commonDataTable, wechatPayTransactionSupportedColumns, transactionRowParser)
|
||||||
|
dataTableImporter := converter.CreateNewSimpleImporterWithTypeNameMapping(wechatPayTransactionTypeNameMapping)
|
||||||
|
|
||||||
|
return dataTableImporter.ParseImportedData(ctx, user, transactionDataTable, defaultTimezoneOffset, accountMap, expenseCategoryMap, incomeCategoryMap, transferCategoryMap, tagMap)
|
||||||
|
}
|
||||||
+14
-2
@@ -241,9 +241,21 @@ export const SUPPORTED_IMPORT_FILE_TYPES: ImportFileType[] = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'wechat_pay_app_csv',
|
type: 'wechat_pay_app',
|
||||||
name: 'WeChat Pay Billing File',
|
name: 'WeChat Pay Billing File',
|
||||||
extensions: '.csv',
|
extensions: '.xlsx,.csv',
|
||||||
|
subTypes: [
|
||||||
|
{
|
||||||
|
type: 'wechat_pay_app_xlsx',
|
||||||
|
name: 'Excel Workbook File',
|
||||||
|
extensions: '.xlsx',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'wechat_pay_app_csv',
|
||||||
|
name: 'CSV (Comma-separated values) File',
|
||||||
|
extensions: '.csv',
|
||||||
|
}
|
||||||
|
],
|
||||||
document: {
|
document: {
|
||||||
supportMultiLanguages: 'zh-Hans',
|
supportMultiLanguages: 'zh-Hans',
|
||||||
anchor: '如何获取微信支付账单文件'
|
anchor: '如何获取微信支付账单文件'
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "How to import this file?",
|
"How to import this file?": "How to import this file?",
|
||||||
"How to export this file?": "Wie exportiere ich diese Datei?",
|
"How to export this file?": "Wie exportiere ich diese Datei?",
|
||||||
"ezbookkeeping Data Export File": "ezBookkeeping-Datenexportdatei",
|
"ezbookkeeping Data Export File": "ezBookkeeping-Datenexportdatei",
|
||||||
|
"Excel Workbook File": "Excel Workbook File",
|
||||||
"Open Financial Exchange (OFX) File": "Open Financial Exchange (OFX)-Datei",
|
"Open Financial Exchange (OFX) File": "Open Financial Exchange (OFX)-Datei",
|
||||||
"Quicken Financial Exchange (QFX) File": "Quicken Financial Exchange (QFX)-Datei",
|
"Quicken Financial Exchange (QFX) File": "Quicken Financial Exchange (QFX)-Datei",
|
||||||
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF)-Datei",
|
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF)-Datei",
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "How to import this file?",
|
"How to import this file?": "How to import this file?",
|
||||||
"How to export this file?": "How to export this file?",
|
"How to export this file?": "How to export this file?",
|
||||||
"ezbookkeeping Data Export File": "ezbookkeeping Data Export File",
|
"ezbookkeeping Data Export File": "ezbookkeeping Data Export File",
|
||||||
|
"Excel Workbook File": "Excel Workbook File",
|
||||||
"Open Financial Exchange (OFX) File": "Open Financial Exchange (OFX) File",
|
"Open Financial Exchange (OFX) File": "Open Financial Exchange (OFX) File",
|
||||||
"Quicken Financial Exchange (QFX) File": "Quicken Financial Exchange (QFX) File",
|
"Quicken Financial Exchange (QFX) File": "Quicken Financial Exchange (QFX) File",
|
||||||
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF) File",
|
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF) File",
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "How to import this file?",
|
"How to import this file?": "How to import this file?",
|
||||||
"How to export this file?": "¿Cómo exportar este archivo?",
|
"How to export this file?": "¿Cómo exportar este archivo?",
|
||||||
"ezbookkeeping Data Export File": "Archivo de exportación de datos de ezBookkeeping",
|
"ezbookkeeping Data Export File": "Archivo de exportación de datos de ezBookkeeping",
|
||||||
|
"Excel Workbook File": "Excel Workbook File",
|
||||||
"Open Financial Exchange (OFX) File": "Abrir archivo de intercambio financiero (OFX)",
|
"Open Financial Exchange (OFX) File": "Abrir archivo de intercambio financiero (OFX)",
|
||||||
"Quicken Financial Exchange (QFX) File": "Archivo Quicken Financial Exchange (QFX)",
|
"Quicken Financial Exchange (QFX) File": "Archivo Quicken Financial Exchange (QFX)",
|
||||||
"Quicken Interchange Format (QIF) File": "Archivo de formato de intercambio Quicken (QIF)",
|
"Quicken Interchange Format (QIF) File": "Archivo de formato de intercambio Quicken (QIF)",
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "How to import this file?",
|
"How to import this file?": "How to import this file?",
|
||||||
"How to export this file?": "Come esportare questo file?",
|
"How to export this file?": "Come esportare questo file?",
|
||||||
"ezbookkeeping Data Export File": "File esportazione dati ezBookkeeping",
|
"ezbookkeeping Data Export File": "File esportazione dati ezBookkeeping",
|
||||||
|
"Excel Workbook File": "Excel Workbook File",
|
||||||
"Open Financial Exchange (OFX) File": "File Open Financial Exchange (OFX)",
|
"Open Financial Exchange (OFX) File": "File Open Financial Exchange (OFX)",
|
||||||
"Quicken Financial Exchange (QFX) File": "File Quicken Financial Exchange (QFX)",
|
"Quicken Financial Exchange (QFX) File": "File Quicken Financial Exchange (QFX)",
|
||||||
"Quicken Interchange Format (QIF) File": "File Quicken Interchange Format (QIF)",
|
"Quicken Interchange Format (QIF) File": "File Quicken Interchange Format (QIF)",
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "How to import this file?",
|
"How to import this file?": "How to import this file?",
|
||||||
"How to export this file?": "このファイルをエクスポートする方法",
|
"How to export this file?": "このファイルをエクスポートする方法",
|
||||||
"ezbookkeeping Data Export File": "ezbookkeepingデータエクスポートファイル",
|
"ezbookkeeping Data Export File": "ezbookkeepingデータエクスポートファイル",
|
||||||
|
"Excel Workbook File": "Excel Workbook File",
|
||||||
"Open Financial Exchange (OFX) File": "Open Financial Exchange (OFX) ファイル",
|
"Open Financial Exchange (OFX) File": "Open Financial Exchange (OFX) ファイル",
|
||||||
"Quicken Financial Exchange (QFX) File": "Quicken Financial Exchange (QFX) ファイル",
|
"Quicken Financial Exchange (QFX) File": "Quicken Financial Exchange (QFX) ファイル",
|
||||||
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF) ファイル",
|
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF) ファイル",
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "Como importar este arquivo?",
|
"How to import this file?": "Como importar este arquivo?",
|
||||||
"How to export this file?": "Como exportar este arquivo?",
|
"How to export this file?": "Como exportar este arquivo?",
|
||||||
"ezbookkeeping Data Export File": "Arquivo de Exportação de Dados ezbookkeeping",
|
"ezbookkeeping Data Export File": "Arquivo de Exportação de Dados ezbookkeeping",
|
||||||
|
"Excel Workbook File": "Excel Workbook File",
|
||||||
"Open Financial Exchange (OFX) File": "Arquivo Open Financial Exchange (OFX)",
|
"Open Financial Exchange (OFX) File": "Arquivo Open Financial Exchange (OFX)",
|
||||||
"Quicken Financial Exchange (QFX) File": "Arquivo Quicken Financial Exchange (QFX)",
|
"Quicken Financial Exchange (QFX) File": "Arquivo Quicken Financial Exchange (QFX)",
|
||||||
"Quicken Interchange Format (QIF) File": "Arquivo Quicken Interchange Format (QIF)",
|
"Quicken Interchange Format (QIF) File": "Arquivo Quicken Interchange Format (QIF)",
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "How to import this file?",
|
"How to import this file?": "How to import this file?",
|
||||||
"How to export this file?": "Как экспортировать этот файл?",
|
"How to export this file?": "Как экспортировать этот файл?",
|
||||||
"ezbookkeeping Data Export File": "Файл экспорта данных ezbookkeeping",
|
"ezbookkeeping Data Export File": "Файл экспорта данных ezbookkeeping",
|
||||||
|
"Excel Workbook File": "Excel Workbook File",
|
||||||
"Open Financial Exchange (OFX) File": "Файл Open Financial Exchange (OFX)",
|
"Open Financial Exchange (OFX) File": "Файл Open Financial Exchange (OFX)",
|
||||||
"Quicken Financial Exchange (QFX) File": "Файл Quicken Financial Exchange (QFX)",
|
"Quicken Financial Exchange (QFX) File": "Файл Quicken Financial Exchange (QFX)",
|
||||||
"Quicken Interchange Format (QIF) File": "Файл Quicken Interchange Format (QIF)",
|
"Quicken Interchange Format (QIF) File": "Файл Quicken Interchange Format (QIF)",
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "How to import this file?",
|
"How to import this file?": "How to import this file?",
|
||||||
"How to export this file?": "Як експортувати цей файл?",
|
"How to export this file?": "Як експортувати цей файл?",
|
||||||
"ezbookkeeping Data Export File": "Файл експорту даних ezbookkeeping",
|
"ezbookkeeping Data Export File": "Файл експорту даних ezbookkeeping",
|
||||||
|
"Excel Workbook File": "Excel Workbook File",
|
||||||
"Open Financial Exchange (OFX) File": "Файл Open Financial Exchange (OFX)",
|
"Open Financial Exchange (OFX) File": "Файл Open Financial Exchange (OFX)",
|
||||||
"Quicken Financial Exchange (QFX) File": "Файл Quicken Financial Exchange (QFX)",
|
"Quicken Financial Exchange (QFX) File": "Файл Quicken Financial Exchange (QFX)",
|
||||||
"Quicken Interchange Format (QIF) File": "Файл Quicken Interchange Format (QIF)",
|
"Quicken Interchange Format (QIF) File": "Файл Quicken Interchange Format (QIF)",
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "How to import this file?",
|
"How to import this file?": "How to import this file?",
|
||||||
"How to export this file?": "Làm thế nào để xuất tệp này?",
|
"How to export this file?": "Làm thế nào để xuất tệp này?",
|
||||||
"ezbookkeeping Data Export File": "Tệp xuất dữ liệu ezbookkeeping",
|
"ezbookkeeping Data Export File": "Tệp xuất dữ liệu ezbookkeeping",
|
||||||
|
"Excel Workbook File": "Excel Workbook File",
|
||||||
"Open Financial Exchange (OFX) File": "Tệp Open Financial Exchange (OFX)",
|
"Open Financial Exchange (OFX) File": "Tệp Open Financial Exchange (OFX)",
|
||||||
"Quicken Financial Exchange (QFX) File": "Tệp Quicken Financial Exchange (QFX)",
|
"Quicken Financial Exchange (QFX) File": "Tệp Quicken Financial Exchange (QFX)",
|
||||||
"Quicken Interchange Format (QIF) File": "Tệp Quicken Interchange Format (QIF)",
|
"Quicken Interchange Format (QIF) File": "Tệp Quicken Interchange Format (QIF)",
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "如何导入该文件?",
|
"How to import this file?": "如何导入该文件?",
|
||||||
"How to export this file?": "如何导出该文件?",
|
"How to export this file?": "如何导出该文件?",
|
||||||
"ezbookkeeping Data Export File": "ezbookkeeping 数据导出文件",
|
"ezbookkeeping Data Export File": "ezbookkeeping 数据导出文件",
|
||||||
|
"Excel Workbook File": "Excel 工作簿文件",
|
||||||
"Open Financial Exchange (OFX) File": "开放式金融交换 (OFX) 文件",
|
"Open Financial Exchange (OFX) File": "开放式金融交换 (OFX) 文件",
|
||||||
"Quicken Financial Exchange (QFX) File": "Quicken Financial Exchange (QFX) 文件",
|
"Quicken Financial Exchange (QFX) File": "Quicken Financial Exchange (QFX) 文件",
|
||||||
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF) 文件",
|
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF) 文件",
|
||||||
|
|||||||
@@ -1722,6 +1722,7 @@
|
|||||||
"How to import this file?": "如何匯入此檔案?",
|
"How to import this file?": "如何匯入此檔案?",
|
||||||
"How to export this file?": "如何匯出此檔案?",
|
"How to export this file?": "如何匯出此檔案?",
|
||||||
"ezbookkeeping Data Export File": "ezbookkeeping 資料匯出檔案",
|
"ezbookkeeping Data Export File": "ezbookkeeping 資料匯出檔案",
|
||||||
|
"Excel Workbook File": "Excel 工作簿檔案",
|
||||||
"Open Financial Exchange (OFX) File": "開放式金融交換 (OFX) 檔案",
|
"Open Financial Exchange (OFX) File": "開放式金融交換 (OFX) 檔案",
|
||||||
"Quicken Financial Exchange (QFX) File": "Quicken Financial Exchange (QFX) 檔案",
|
"Quicken Financial Exchange (QFX) File": "Quicken Financial Exchange (QFX) 檔案",
|
||||||
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF) 檔案",
|
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF) 檔案",
|
||||||
|
|||||||
Reference in New Issue
Block a user