vendor import ref pepper
static void VendorImport(Args _args)
{
Dialog dialog;
Filename filename;
DialogField dialogFileName;
InboundMerchantTable vendTable;
InboundMerchantCommunication vendAddress;
EcomMerchantContact vendContact;
COMVariantType type;
SysExcelCells cells;
SysExcelWorkbook workbook;
SysExcelWorkbooks workbooks;
SysExcelWorksheet worksheet;
SysExcelWorksheets worksheets;
SysExcelApplication application;
VendAccount vendAccount;
Name vendName;
CurrencyCode currency;
VendGroupId vendGroupId;
DlvTermId dlvTermId;
PaymTermId paymTermId;
PaymMode paymMode;
EcomBusinessModel ecomBusinessModel;
Email stockIntimationEmail;
str vendBankAccountId;
VendBank vendBank;
Name bankName;
SWIFTNo SWIFTNo;
BankIBAN bankIBAN;
str routingNum;
str ifsc, beneficiaryName;
str purpose;
Addressing street;
LogisticsAddressCity city;
LogisticsAddressStateId state;
LogisticsAddressZipCodeId zipCode;
LogisticsAddressCountryRegionId county;
TaxRegistrationNumber_IN vatRegistration;
TaxRegistrationNumber_IN cstRegistration;
TaxRegistrationNumber_IN serviceTaxRegistration;
TaxRegistrationNumber_IN tanRegistration;
TaxGroup salesTaxGroup;
TaxGroup whtTaxGroup;
PANNumber_IN PANNumber;
ContactPersonName contactPersonName;
ContactPersonName addContactPersonName;
Phone contactPhone, contactPhone2;
Email contactEmail;
Email POEmail;
Email PREmail;
int processed, failed, totalRecords = 1000, row = 1;
SysOperationProgress simpleProgress;
#AviFiles
;
dialog = new Dialog("Import payment");
dialogFileName = dialog.addField(extendedTypeStr(Filenameopen), "File path");
dialog.run();
if (dialog.run())
{
filename = dialogFileName.value();
}
simpleProgress = SysOperationProgress::newGeneral(#aviUpdate, 'Importing payment lines.', totalRecords);
application = SysExcelApplication::construct();
workbooks = application.workbooks();
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File not found");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
//Iterate through cells and get the values
ttsBegin;
do
{
//Incrementing the row line to next Row
row++;
vendAccount = COMVariant2Str(cells.item(row, 1).value());
vendName = COMVariant2Str(cells.item(row, 2).value());
currency = COMVariant2Str(cells.item(row, 3).value());
vendGroupId = COMVariant2Str(cells.item(row, 4).value());
dlvTermId = COMVariant2Str(cells.item(row, 5).value());
paymTermId = COMVariant2Str(cells.item(row, 6).value());
paymMode = COMVariant2Str(cells.item(row, 7).value());
ecomBusinessModel = str2enum(ecomBusinessModel, COMVariant2Str(cells.item(row, 8).value()));
stockIntimationEmail = COMVariant2Str(cells.item(row, 9).value());
vendBankAccountId = COMVariant2Str(cells.item(row, 10).value());
vendBank = COMVariant2Str(cells.item(row, 11).value());
bankName = COMVariant2Str(cells.item(row, 12).value());
SWIFTNo = COMVariant2Str(cells.item(row, 13).value());
bankIBAN = COMVariant2Str(cells.item(row, 14).value());
routingNum = COMVariant2Str(cells.item(row, 15).value());
ifsc = COMVariant2Str(cells.item(row, 16).value());
purpose = COMVariant2Str(cells.item(row, 17).value());
street = COMVariant2Str(cells.item(row, 18).value());
city = COMVariant2Str(cells.item(row, 19).value());
state = COMVariant2Str(cells.item(row, 20).value());
zipCode = COMVariant2Str(cells.item(row, 21).value());
county = COMVariant2Str(cells.item(row, 22).value());
vatRegistration = COMVariant2Str(cells.item(row, 23).value());
cstRegistration = COMVariant2Str(cells.item(row, 24).value());
serviceTaxRegistration = COMVariant2Str(cells.item(row, 25).value());
tanRegistration = COMVariant2Str(cells.item(row, 26).value());
salesTaxGroup = COMVariant2Str(cells.item(row, 27).value());
whtTaxGroup = COMVariant2Str(cells.item(row, 28).value());
PANNumber = COMVariant2Str(cells.item(row, 29).value());
contactPersonName = COMVariant2Str(cells.item(row, 30).value());
addContactPersonName = COMVariant2Str(cells.item(row, 31).value());
contactPhone = COMVariant2Str(cells.item(row, 32).value());
contactPhone2 = COMVariant2Str(cells.item(row, 33).value());
contactEmail = COMVariant2Str(cells.item(row, 34).value());
POEmail = COMVariant2Str(cells.item(row, 35).value());
PREmail = COMVariant2Str(cells.item(row, 36).value());
beneficiaryName = COMVariant2Str(cells.item(row, 37).value());
vendTable.clear();
vendTable.initValue();
vendTable.MerchantId = vendAccount;
vendTable.Name = vendName;
vendTable.Currency = currency;
vendTable.TermsOfPayment = paymTermId;
vendTable.MethodOfPayment = paymMode;
vendTable.EcomBusinessModel = ecomBusinessModel;
vendTable.VendBankAccountNum = vendBankAccountId;
vendTable.VendBankAccountId = vendBank;
vendTable.VendBankName = bankName;
vendTable.SWIFTNo = SWIFTNo;
vendTable.IFSCCode = ifsc;
vendTable.IBAN = bankIBAN;
vendTable.BankRegistrationNum = routingNum;
vendTable.PANNumber = PANNumber;
vendTable.TDSGroup = whtTaxGroup;
vendTable.isVendorOnly = true;
vendTable.BeneficiaryName = beneficiaryName;
vendTable.ContactFirstName = contactPersonName;
vendTable.Email = contactEmail;
vendTable.Phone = contactPhone;
vendTable.Phone2 = contactPhone2;
vendTable.StockIntimationEmail = stockIntimationEmail;
vendTable.PurchaseIntimationEmail= POEmail;
vendTable.insert();
vendAddress.clear();
vendAddress.initValue();
vendAddress.InboundMerchantTable= vendTable.RecId;
vendAddress.AddressId = vendTable.MerchantId + "_1";
vendAddress.Address = street;
vendAddress.City = city;
vendAddress.StateId = state;
vendAddress.ZipCode = zipCode;
vendAddress.CountryRegionId = county;
vendAddress.SalesTaxRegistrationNumber = cstRegistration;
vendAddress.TIN = vatRegistration;
vendAddress.ServiceTaxRegistrationNumber = serviceTaxRegistration;
vendAddress.TANRegistrationNumber = tanRegistration;
vendAddress.Email = contactEmail;
vendAddress.Phone = contactPhone;
vendAddress.insert();
vendContact.clear();
vendContact.initValue();
vendContact.InboundMerchantTable = vendTable.RecId;
vendContact.FirstName = addContactPersonName;
vendContact.Email = contactEmail;
vendContact.Phone = contactPhone;
vendContact.Phone1 = contactPhone2;
vendContact.insert();
simpleProgress.incCount();
simpleprogress.setText(strfmt("Vendor no.: %1 Rows: %2", vendAccount, row));
simpleprogress.update(true);
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
ttsCommit;
// quits the application
application.quit();
info(strFmt("Total: %1 Processed: %2 Failed: %3", row, processed, failed));
}