Skip to content

Master data import

A master data import is a recurring Hangfire job. It reads the master data from a source (CSV file, ODBC or SQL query, ERP interface), turns each row into a record with a mapping script and reconciles the result with the existing master data.

Which sources are available depends on the ERP plugin. The generic plugins read CSV files, ODBC data sources and SQL Server databases. This page mainly describes the import from CSV files.

Each import is an entry in the table conf.IrRecurringJobs. It is set up during commissioning by enio AG or a partner.

FieldMeaning
HangfireIdUnique ID of the job, for example ch.invoicer.mstr.suppliers
DescriptionDescription shown under Administration > Job-Ausführung
EnabledWhether the job is active
CronExpressionWhen the job runs, for example 0 6 * * * for daily at 6 am
TimeZoneIdTime zone for the cron expression
ClassIdentifierClass that runs the import, for example enio.erp.Plugin.FromCsv.Import.Import_Supplier_From_File
MethodNameMethod of the class, for imports usually DoImport
MethodArgumentIdentifierType of the configuration, for example enio.erp.Plugin.FromCsv.Import.ImportFromFileBaseArgument
ConfigurationImport configuration as JSON (see below)
ObjectMappingCodeThe mapping script (see below)
{
"SourceFilePath": "\\\\<server>\\export\\suppliers.csv",
"SourceFileEncoding": "utf-8",
"Separator": ";",
"HasHeaderRow": true,
"OuColumnIndex": 0,
"Source": "ERP",
"MappingKeys": ["IrOrganizationUnitId", "Number"],
"DeleteNotDeliveredRecords": true,
"TraceLevel": "Default"
}
SettingDefaultMeaning
SourceFilePathPath to the file. Possible are a file path, a network share or an address with http.
Host, Port, Username, PasswordFor files on an SFTP server: Host starts with sftp://.
SourceFileEncodingServer defaultCharacter set, for example utf-8, utf-8bom or windows-1252
Separator;Separator between columns
HasHeaderRowfalseWhether the first row contains column headings. It is then skipped.
CsvHelperModeRFC4180Handling of quotes: RFC4180, Escape or NoEscape
IgnoreEmptyFilefalseSkip an empty file without error
IgnoreBadDatafalseTolerate badly formatted rows
OnlyTakeNewestFileOfFolderfalseSourceFilePath is a folder. The import takes the newest file in it.
FileNameIncludesTimeStampfalseThe file name contains a date (format in FileNameIncludesTimeStampFormat, default yyyyMMdd).
OuColumnIndex0Column (counted from 0) with the external ID of the organization unit
UseOUIdFixed external ID of the organization unit for all rows. Replaces OuColumnIndex.
SourceExternalSource of the records, see Master data
MappingKeysFields by which the import recognizes existing records, see Master data
IgnorePropertiesFields the import never overwrites in existing records, for example because they are maintained in invoiceR
DeleteNotDeliveredRecordstrueMark records that are no longer delivered as deleted
ReactivateDeletedRecordsfalseReactivate deleted records when they are delivered again
MappingFilePath, MappingFileEncodingLoad the mapping script from a file or address instead of ObjectMappingCode
BatchSize999999After how many rows intermediate saves happen
TraceLevelDefaultWith Verbose the job writes every row to the log.

The mapping script is C# code. It runs for every row and fills the new record. The following is available in the script:

VariableContent
wordsThe columns of the current row as text array, counted from 0
entityFromImportThe new record that the script fills. Organization unit and tenant are already set.
cultureInfoSwiss regional settings, for example to convert numbers and dates
importDynamicFor imports from databases, the row as an object with the column names

The script must return the record with return. If it returns null, the import skips the row.

Example for suppliers from a CSV file in the format below:

entityFromImport.Number = words[1];
entityFromImport.Name = words[2];
entityFromImport.Address1 = words[3];
entityFromImport.Zip = words[6];
entityFromImport.City = words[7];
entityFromImport.UID = words[8];
entityFromImport.Country = words[11];
entityFromImport.DefaultTermOfPayment = words[12];
entityFromImport.DefaultVatCode = words[13];
if (string.IsNullOrWhiteSpace(entityFromImport.Number))
return null;
return entityFromImport;

Example for payment methods from a database query, where the script derives the type from the IBAN:

using System;
using System.Linq;
using web_manager.Enio;
entityFromImport.Number = importDynamic.LaufNummer.ToString();
entityFromImport.SupplierNumber = importDynamic.KreditorNummer.ToString();
entityFromImport.IBAN = importDynamic.IBAN.ToString().Replace(" ", "");
entityFromImport.Account = entityFromImport.IBAN;
entityFromImport.Country = importDynamic.LandCode.ToString();
entityFromImport.Type = string.IsNullOrWhiteSpace(entityFromImport.IBAN)
? PaymentMethodType.BankAccount
: PaymentMethodType.BankIBAN;
return entityFromImport;

If your ERP delivers the master data as CSV files, we recommend the following formats. The column order is free; it is assigned in the mapping script. The first column always contains the external ID of the organization unit (company in the ERP).

ColumnTypeRemarkRequired
MandantTextExternal ID of the organization unityes
NumberTextUnique supplier numberyes
NameTextyes
Address1TextAddress line 1no
Address2TextAddress line 2no
Address3TextAddress line 3no
ZipTextPostal codeno
CityTextCityno
UIDTextBusiness identification numberno
EmailTextno
PhoneTextPhone numberno
CountryTextISO country code (CH, DE, LI, …)no
DefaultTermOfPaymentTextDefault terms of payment (number from the terms of payment)no
DefaultVatCodeTextDefault VAT code (code from the VAT codes)no
ColumnTypeRemarkRequired
MandantTextExternal ID of the organization unityes
NumberTextUnique number of the payment methodyes
SupplierNumberTextSupplier number from the suppliersyes
NameTextName of the payment method, for example of the bankyes
AddressTextAddressno
ZipTextPostal codeno
CityTextCityno
CountryTextISO country codeno
AccountTextAccount number for postal connectionsfor postal connections
IBANTextIBANfor bank connections with IBAN
BICCodeTextBIC according to ISO 9362no
SwiftNumberTextSWIFTno
ColumnTypeRemarkRequired
MandantTextExternal ID of the organization unityes
NumberTextUnique account numberyes
DescriptionTextDescriptionno
VATCodeTextDefault VAT code for the accountno
IsBalanceSheetAccountYes/No1 = balance sheet accountno
ColumnTypeRemarkRequired
MandantTextExternal ID of the organization unityes
NumberTextUnique cost center numberyes
DescriptionTextDescriptionno
ColumnTypeRemarkRequired
MandantTextExternal ID of the organization unityes
AccountNumberTextAccount number from the accountsyes
CostCenterNumberTextCost center number from the cost centersyes
ColumnTypeFormatRemarkRequired
MandantTextExternal ID of the organization unityes
NumberTextUnique number of the terms of paymentyes
DescriptionTextDescriptionno
NetPeriodNumber0Net payment period in daysyes
DiscountPeriod1Number0Period for discount 1 in daysno
DiscountPercent1Number0.00Discount 1 in percentno
DiscountPeriod2Number0Period for discount 2 in daysno
DiscountPercent2Number0.00Discount 2 in percentno
ColumnTypeFormatRemarkRequired
MandantTextExternal ID of the organization unityes
CodeTextVAT codeyes
RateNumber0.00VAT rateyes
DescriptionTextDescriptionno
CountryCodeTextISO country codeno
ColumnTypeRemarkRequired
MandantTextExternal ID of the organization unityes
NumberTextUnique project numberyes
NameTextNameyes