public DanishFormatFieldBase CreateDomesticFormatField(CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, Uniconta.DataModel.Creditor creditor, Company company, bool glJournalGenerated = false) { var danishFields = new SDCFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); DomesticPaymentType(danishFields, tran); danishFields.TransTypeCommand = SDCPayFormat.RECORDTYPE_3; var paymentAmount = Math.Round(tran.PaymentAmount, 2); var paymentAmountSTR = paymentAmount.ToString("F"); danishFields.AmountSTR = NETSNorge.processString(paymentAmountSTR, 15, true); danishFields.Receipt = "N"; var internalAdvText = StandardPaymentFunctions.InternalMessage(paymentFormat._OurMessage, tran, company, creditor); danishFields.OwnVoucherNumber = NETSNorge.processString(internalAdvText, 20, false); var externalAdvText = StandardPaymentFunctions.ExternalMessage(paymentFormat._Message, tran, company, creditor); danishFields.Blanks = NETSNorge.processString(string.Empty, 4, false); danishFields.BeneficiaryAdviceText = NETSNorge.processString(externalAdvText, 20, false); 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 SDCFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); SharedForeignReceiverBankInfo(danishFields, tran); danishFields.TransTypeCommand = SDCPayFormat.RECORDTYPE_K037; danishFields.TransferTypeStr = "001"; danishFields.ToAccountNumber = danishFields.ToAccountNumber == string.Empty ? danishFields.ReceiverIBAN : danishFields.ToAccountNumber; danishFields.ToAccountNumber = NETSNorge.processString(danishFields.ToAccountNumber, 35, false); var paymentAmount = Math.Round(tran.PaymentAmount, 2); var paymentAmountSTR = paymentAmount.ToString("F"); danishFields.AmountSTR = NETSNorge.processString(paymentAmountSTR, 14, true); danishFields.TransferCurrency = danishFields.Currency; danishFields.Blanks = NETSNorge.processString(string.Empty, 14, false); if (glJournalGenerated) { danishFields.NameOfReceiver = NETSNorge.processString(string.Empty, 35, false); danishFields.AddressOfReceiver = NETSNorge.processString(string.Empty, 35, false); danishFields.AddressOfReceiver2 = NETSNorge.processString(string.Empty, 35, false); } else { danishFields.NameOfReceiver = NETSNorge.processString(tran.Creditor.Name, 35, false); danishFields.AddressOfReceiver = NETSNorge.processString(tran.Creditor.Address1 + ", " + tran.Creditor.ZipCode + " " + tran.Creditor.City, 35, false); danishFields.AddressOfReceiver2 = NETSNorge.processString(tran.Creditor.Address2, 35, false); } danishFields.Blanks2 = NETSNorge.processString(string.Empty, 35, false); danishFields.ReceiverAccountInfo = new List <string>() { NETSNorge.processString(danishFields.SwiftAddress, 35, false), NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(string.Empty, 35, false) }; var externalAdvText = StandardPaymentFunctions.ExternalMessage(paymentFormat._Message, tran, company, creditor); var message = NETSNorge.processString(externalAdvText, 140, false); int maxStrLen = 35; int maxLines = 4; 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.DescriptionOfPayment = messageList; danishFields.Messages = new List <string>() { NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(string.Empty, 35, false) }; danishFields.ExchRateType = "N"; //N=Noteringskurs, A=Aftaltkurs, T=Terminkurs danishFields.ExchRateTermContract = NETSNorge.processString(string.Empty, 10, false); danishFields.ExchRateTerm = NETSNorge.processString(string.Empty, 14, false); danishFields.ChargeAccountSeparate = "N"; danishFields.ChargeAccount = NETSNorge.processString(string.Empty, 14, false); danishFields.ChargeType = "1"; // 1 = betales i DK af afsender, i udlandet af modtager(SHA). 2 = betales af afsender (OUR), 3 = betales af modtager(BEN) danishFields.EmptyFields = new List <string>() { NETSNorge.processString(string.Empty, 1, false), NETSNorge.processString(string.Empty, 2, false), NETSNorge.processString(string.Empty, 4, false), NETSNorge.processString(string.Empty, 6, false), NETSNorge.processString(string.Empty, 140, false), }; danishFields.UniquePaymRef = tran.PaymentEndToEndId.ToString(); return(danishFields); }
public DanishFormatFieldBase CreateFIKFormatField(CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, Uniconta.DataModel.Creditor creditor, Company company, bool glJournalGenerated = false) { var danishFields = new SDCFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); SharedFIKPayment(danishFields, tran); switch (tran._PaymentMethod) { case PaymentTypes.PaymentMethod3: //FIK71 danishFields.TransTypeCommand = SDCPayFormat.RECORDTYPE_K020; danishFields.ToAccountNumber = danishFields.ToAccountNumber.PadLeft(8, '0'); danishFields.PaymentId = danishFields.PaymentId.PadLeft(15, '0'); break; case PaymentTypes.PaymentMethod4: //FIK73 danishFields.TransTypeCommand = SDCPayFormat.RECORDTYPE_K073; danishFields.ToAccountNumber = danishFields.ToAccountNumber.PadLeft(8, '0'); break; case PaymentTypes.PaymentMethod5: //FIK75 danishFields.TransTypeCommand = SDCPayFormat.RECORDTYPE_K075; danishFields.ToAccountNumber = danishFields.ToAccountNumber.PadLeft(8, '0'); danishFields.PaymentId = danishFields.PaymentId.PadLeft(16, '0'); break; case PaymentTypes.PaymentMethod6: //FIK04 danishFields.TransTypeCommand = SDCPayFormat.RECORDTYPE_K006; danishFields.ToAccountNumber = danishFields.ToAccountNumber.PadLeft(10, '0'); danishFields.PaymentId = danishFields.PaymentId.PadLeft(19, '0'); break; } var paymentAmount = Math.Round(tran.PaymentAmount, 2); var paymentAmountSTR = paymentAmount.ToString("F"); danishFields.AmountSTR = NETSNorge.processString(paymentAmountSTR, 15, true);; danishFields.Receipt = "N"; var internalAdvText = StandardPaymentFunctions.InternalMessage(paymentFormat._OurMessage, tran, company, creditor); danishFields.OwnVoucherNumber = NETSNorge.processString(internalAdvText, 20, false); if (danishFields.FormType == BankFormatBase.FIK04 || danishFields.FormType == BankFormatBase.FIK73) { danishFields.OtherSender = new List <string>() { NETSNorge.processString("N", 1, false), NETSNorge.processString(string.Empty, 18, false), NETSNorge.processString(string.Empty, 32, false), NETSNorge.processString(string.Empty, 32, false), NETSNorge.processString(string.Empty, 4, false), }; } if (danishFields.FormType == BankFormatBase.FIK73 || danishFields.FormType == BankFormatBase.FIK75 || danishFields.FormType == BankFormatBase.FIK04) { //Message to Beneficiary >> var externalAdvText = StandardPaymentFunctions.ExternalMessage(paymentFormat._Message, tran, company, creditor); danishFields.ReceiverAccountStatement = NETSNorge.processString(externalAdvText, 35, false); var message = externalAdvText; var maxStrLen = 35; var numLines = message.Length / (double)maxStrLen; var maxLines = (int)Math.Ceiling(numLines); maxLines = maxLines > 40 ? 40 : maxLines; message = NETSNorge.processString(message, maxLines * maxStrLen, 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.AdviceText = messageList; var maxLinesSTR = maxLines.ToString(); danishFields.AdviceTextLines = maxLinesSTR.PadLeft(3, '0'); //Message to Beneficiary << } else { danishFields.AdviceTextLines = string.Empty; } danishFields.UniquePaymRef = tran.PaymentEndToEndId.ToString(); return(danishFields); }