public DanishFormatFieldBase CreateDanishFormatField(CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, Uniconta.DataModel.Creditor creditor, Company company, bool glJournalGenerated = false) { var danishFields = new DanskBankFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); danishFields.TransTypeCommand = DanskeBankPayFormat.TRANSTYPE_CMBO; switch (tran._PaymentMethod) { case PaymentTypes.PaymentMethod3: //FIK71 SharedFIKPayment(danishFields, tran); danishFields.ToAccountNumber = string.Format("IK{0}", danishFields.ToAccountNumber); danishFields.PaymentId = danishFields.PaymentId.PadLeft(15, '0'); break; case PaymentTypes.PaymentMethod4: //FIK73 SharedFIKPayment(danishFields, tran); danishFields.ToAccountNumber = string.Format("IK{0}", danishFields.ToAccountNumber); break; case PaymentTypes.PaymentMethod5: //FIK75 SharedFIKPayment(danishFields, tran); danishFields.ToAccountNumber = string.Format("IK{0}", danishFields.ToAccountNumber); danishFields.PaymentId = danishFields.PaymentId.PadLeft(16, '0'); break; case PaymentTypes.PaymentMethod6: //FIK04 SharedFIKPayment(danishFields, tran); danishFields.ToAccountNumber = string.Format("IK{0}", danishFields.ToAccountNumber); danishFields.PaymentId = danishFields.PaymentId.PadLeft(16, '0'); break; case PaymentTypes.VendorBankAccount: BBANIBANPaymentType(danishFields, tran); break; case PaymentTypes.IBAN: BBANIBANPaymentType(danishFields, tran); danishFields.ToAccountNumber = danishFields.ReceiverIBAN; break; } danishFields.Amount = Math.Round(tran.PaymentAmount, 2); danishFields.ClearingTypeChannel = "N"; danishFields.NotUsed = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; danishFields.LetterToSend = "N"; danishFields.NotUsed02 = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; var internalAdvText = StandardPaymentFunctions.InternalMessage(paymentFormat._OurMessage, tran, company, creditor); danishFields.TextToSender = internalAdvText.Length > 20 ? internalAdvText.Substring(0, 20) : internalAdvText; danishFields.Blanks = string.Empty; danishFields.DebtorId = string.Empty; danishFields.OwnVoucherNumber = danishFields.TextToSender; var externalAdvText = StandardPaymentFunctions.ExternalMessage(paymentFormat._Message, tran, company, creditor); var message = externalAdvText; danishFields.TextToBeneficiary = message.Length > 20 ? message.Substring(0, 20) : message; //Extended notification if (paymentFormat._ExtendedText) { if (message == null || message.Length <= 20) { message = string.Empty; } } else { message = string.Empty; } int maxStrLen = 35; int maxLines = 41; if (tran._PaymentMethod == PaymentTypes.PaymentMethod4 || tran._PaymentMethod == PaymentTypes.PaymentMethod5 || tran._PaymentMethod == PaymentTypes.VendorBankAccount) { message = NETSNorge.processString(message, maxStrLen * maxLines, false); } else { message = NETSNorge.processString(string.Empty, maxStrLen * maxLines, false); } List <string> messageList = new List <string>(); if (message != string.Empty) { if (message.Length > maxLines * maxStrLen) { message = message.Substring(0, maxLines * maxStrLen); } messageList = message.Select((x, i) => i) .Where(i => i % maxStrLen == 0) .Select(i => message.Substring(i, message.Length - i >= maxStrLen ? maxStrLen : message.Length - i)).ToList <string>(); } danishFields.Messages = messageList; danishFields.NotUsed03 = new List <string>() { string.Empty, string.Empty, string.Empty }; if (glJournalGenerated == true) { danishFields.ZipCodeOfReceiver = string.Empty; danishFields.CityOfReceiver = string.Empty; } else { var credZip = tran.Creditor.ZipCode ?? string.Empty; var credCity = tran.Creditor.City ?? string.Empty; danishFields.ZipCodeOfReceiver = credZip.Length > 4 ? credZip.Substring(0, 4) : credZip; danishFields.CityOfReceiver = credCity.Length > 28 ? credCity.Substring(0, 28) : credCity; } danishFields.NotUsed04 = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; danishFields.DebtorsIdentificationOfThePayment = string.Empty; danishFields.Reference = tran.PaymentEndToEndId.ToString(); danishFields.Orderingofelectronicaladvice = string.Empty; danishFields.UniquePaymRef = tran.PaymentEndToEndId.ToString(); return(danishFields); }
public DanishFormatFieldBase CreateForeignFormatField(CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, Uniconta.DataModel.Creditor creditor, Company company, bool glJournalGenerated = false) { var danishFields = new DanskBankFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); SharedForeignReceiverBankInfo(danishFields, tran); danishFields.TransTypeCommand = DanskeBankPayFormat.TRANSTYPE_CMUO; danishFields.ToAccountNumber = danishFields.ToAccountNumber == string.Empty ? danishFields.ReceiverIBAN : danishFields.ToAccountNumber; danishFields.Amount = Math.Round(tran.PaymentAmount, 2); danishFields.CurencyOfEquivalentAmount = string.Empty; danishFields.TransferType = 1; //Changed from formtype if (glJournalGenerated) { danishFields.NameOfReceiver = ShortenWordToCriteria(string.Empty, 35); danishFields.AddressOfReceiver = ShortenWordToCriteria(string.Empty, 35); danishFields.AddressOfReceiver2 = ShortenWordToCriteria(string.Empty, 35); } else { danishFields.NameOfReceiver = ShortenWordToCriteria(tran.Creditor.Name, 35); danishFields.AddressOfReceiver = ShortenWordToCriteria(string.Format("{0}, {1} {2}", tran.Creditor.Address1, tran.Creditor.ZipCode, tran.Creditor.City), 35); danishFields.AddressOfReceiver2 = ShortenWordToCriteria(tran.Creditor.Address2, 35); } danishFields.Blanks = string.Empty; danishFields.ReceiverBankInfo = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty }; danishFields.CostAccountTransfer = 1; //1=To be shared var invoiceNumber = tran.invoiceNumbers == null?tran.Invoice.ToString() : tran.invoiceNumbers.ToString(); invoiceNumber = invoiceNumber == "0" ? string.Empty : string.Format("INV:{0}", invoiceNumber); var externalAdvText = StandardPaymentFunctions.ExternalMessage(paymentFormat._Message, tran, company, creditor); var message = externalAdvText; int maxStrLen = 35; int maxLines = 4; message = NETSNorge.processString(message, maxStrLen * maxLines, false); List <string> messageList = new List <string>(); if (message != string.Empty) { if (message.Length > maxLines * maxStrLen) { message = message.Substring(0, maxLines * maxStrLen); } messageList = message.Select((x, i) => i) .Where(i => i % maxStrLen == 0) .Select(i => message.Substring(i, message.Length - i >= maxStrLen ? maxStrLen : message.Length - i)).ToList <string>(); } danishFields.Messages = messageList; danishFields.NotUsed = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; var internalAdvText = StandardPaymentFunctions.InternalMessage(paymentFormat._OurMessage, tran, company, creditor); danishFields.TextToSender = internalAdvText.Length > 20 ? internalAdvText.Substring(0, 20) : internalAdvText; danishFields.NotUsed02 = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; danishFields.ExchangeRateType = string.Empty; danishFields.Branch = string.Empty; danishFields.NotUsed03 = new List <string>() { string.Empty, string.Empty, string.Empty }; danishFields.NotUsed04 = new List <string>() { string.Empty, string.Empty }; danishFields.Blanks2 = string.Empty; danishFields.Blanks3 = string.Empty; danishFields.Reference = tran.PaymentEndToEndId.ToString(); danishFields.Orderingofelectronicaladvice = string.Empty; danishFields.UniquePaymRef = tran.PaymentEndToEndId.ToString(); return(danishFields); }