public void BBANIBANPaymentType(DanishFormatFieldBase _field, CreditorTransPayment tran) { var field = _field as BECFormatFields; var countryId = string.Empty; var iban = string.Empty; var swift = string.Empty; var bban = string.Empty; var regNum = string.Empty; field.SwiftAddress = string.Empty; field.CountryCode = string.Empty; if (tran._PaymentMethod == PaymentTypes.IBAN) { iban = tran.PaymentId ?? string.Empty; if (iban != string.Empty) { iban = iban.ToUpper(); countryId = iban.Substring(0, 2); } field.ToAccountNumber = string.Empty; } else { bban = tran.PaymentId ?? string.Empty; bban = Regex.Replace(bban, "[^0-9]", ""); regNum = bban.Substring(0, 4); bban = bban.Remove(0, 4); bban = bban.PadLeft(10, '0'); field.ToAccountNumber = string.Format("{0}{1}", regNum, bban); } swift = tran._SWIFT ?? string.Empty; if (swift != string.Empty) { swift = Regex.Replace(swift, "[^\\w\\d]", ""); swift = swift.ToUpper(); if (swift.Length >= 6) { countryId = countryId == string.Empty ? swift.Substring(4, 2) : countryId; } } if (tran._PaymentMethod == PaymentTypes.VendorBankAccount && countryId != string.Empty && countryId != BaseDocument.COUNTRY_DK) { field.TransTypeCommand = BECPayFormat.TRANSTYPE_ERH400; bban = tran.PaymentId ?? string.Empty; bban = Regex.Replace(bban, "[^0-9]", ""); field.ToAccountNumber = bban; field.PaymentId = swift; } field.SwiftAddress = swift; field.ReceiverIBAN = iban; field.CountryCode = countryId; }
public DanishFormatFieldBase SecondaryCreateDomesticFormatField(CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, Company company, bool glJournalGenerated = false) { var danishFields = new BankDataFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); DomesticPaymentType(danishFields, tran); danishFields.TransTypeCommand = BankDataPayFormat.TRANSTYPE_IB030202000005; danishFields.Index = BankDataPayFormat.INDEX02; danishFields.SenderName = NETSNorge.processString(company._Name, 35, false); danishFields.SenderAddress1 = NETSNorge.processString(company._Address1, 35, false); danishFields.SenderAddress2 = NETSNorge.processString(company._Address2, 35, false); danishFields.SenderAddress3 = NETSNorge.processString(company._Address3, 35, false); danishFields.ReservetForXML = 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, 48, false), NETSNorge.processString(string.Empty, 255, false), NETSNorge.processString(string.Empty, 255, false) }; return(danishFields); }
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 void SharedCodeForCreateBankFormatFields(Company company, CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, DanishFormatFieldBase danishFields) { danishFields.TransferDate = tran.PaymentDate; danishFields.Currency = tran.Trans._Currency != 0 ? (Currencies)tran.Trans._Currency : company._CurrencyId; var regNum = bankAccount._BankAccountPart1 ?? string.Empty; var bban = bankAccount._BankAccountPart2 ?? string.Empty; regNum = Regex.Replace(regNum, "[^0-9]", ""); bban = Regex.Replace(bban, "[^0-9]", ""); bban = bban.PadLeft(10, '0'); danishFields.FromAccountNumber = string.Format("{0}{1}", regNum, bban); }
public void BBANIBANPaymentType(DanishFormatFieldBase _field, CreditorTransPayment tran) { var field = _field as DanskBankFormatFields; var countryId = string.Empty; var iban = string.Empty; var swift = string.Empty; var bban = string.Empty; field.SwiftAddress = string.Empty; field.CountryCode = string.Empty; if (tran._PaymentMethod == PaymentTypes.IBAN) { iban = tran.PaymentId ?? string.Empty; if (iban != string.Empty) { iban = Regex.Replace(iban, "[^\\w\\d]", ""); iban = iban.ToUpper(); countryId = iban.Substring(0, 2); } } else { bban = tran.PaymentId ?? string.Empty; bban = Regex.Replace(bban, "[^0-9]", ""); string regNum = bban.Substring(0, 4); bban = bban.Remove(0, 4); bban = bban.PadLeft(10, '0'); bban = string.Format("{0}{1}", regNum, bban); } swift = tran._SWIFT ?? string.Empty; if (swift != string.Empty) { swift = Regex.Replace(swift, "[^\\w\\d]", ""); swift = swift.ToUpper(); countryId = countryId == string.Empty ? swift.Substring(4, 2) : countryId; } field.SwiftAddress = swift; field.ReceiverIBAN = iban; field.ToAccountNumber = bban; field.CountryCode = countryId; }
public void DomesticPaymentType(DanishFormatFieldBase _field, CreditorTransPayment tran) { var field = _field as BankDataFormatFields; field.SwiftAddress = string.Empty; field.CountryCode = string.Empty; field.FormType = "Vendor Bank Account"; var bban = tran.PaymentId ?? string.Empty; bban = Regex.Replace(bban, "[^0-9]", ""); string regNum = bban.Substring(0, 4); bban = bban.Remove(0, 4); bban = bban.PadLeft(10, '0'); field.ToAccountRegNr = NETSNorge.processString(regNum, 4, false); field.ToAccountNumber = NETSNorge.processString(bban, 10, false); }
public void SharedForeignReceiverBankInfo(DanishFormatFieldBase field, CreditorTransPayment tran) { var countryId = string.Empty; var iban = string.Empty; var bban = string.Empty; if (tran._PaymentMethod == PaymentTypes.IBAN) { field.FormType = "IBAN"; iban = tran.PaymentId ?? string.Empty; if (iban != string.Empty) { iban = Regex.Replace(iban, "[^\\w\\d]", ""); iban = iban.ToUpper(); countryId = iban.Substring(0, 2); } } else { field.FormType = "Vendor Bank Account"; bban = tran.PaymentId ?? string.Empty; bban = Regex.Replace(bban, "[^0-9]", ""); } var swift = tran._SWIFT ?? string.Empty; if (swift != string.Empty) { swift = Regex.Replace(swift, "[^\\w\\d]", ""); swift = swift.ToUpper(); if (swift.Length > 6) { countryId = countryId == string.Empty ? swift.Substring(4, 2) : countryId; } } field.SwiftAddress = swift; field.ReceiverIBAN = iban; field.ToAccountNumber = bban; field.CountryCode = countryId; }
public static string InternalMessage(string messageFormat, CreditorTransPayment rec, Company company, Uniconta.DataModel.Creditor creditor) { var sbAdvText = StringBuilderReuse.Create(); var advText = string.Empty; var country = company._CountryId; var tuple = MessageLabel(country); if (messageFormat != null) { sbAdvText.Append(messageFormat); if (rec.invoiceNumbers != null && rec.MergePaymId != MERGEID_SINGLEPAYMENT) { sbAdvText.Remove("Fak:%1").Trim(); //Removes invoicenumbers for merge payment due to limitation of characters sbAdvText.Remove("Fak: %1").Trim(); sbAdvText.Remove("%1").Trim(); } sbAdvText.Replace("%1", "{0}").Replace("%2", "{1}").Replace("%3", "{2}").Replace("%4", "{3}").Replace("%5", "{4}"); advText = string.Format(sbAdvText.ToStringAndRelease(), rec.InvoiceAN, creditor?._Account, creditor?._Name, NumberConvert.ToStringNull(rec.Voucher), NumberConvert.ToStringNull(rec.PaymentRefId)); } else //Default message { BuildBankAdviceText(sbAdvText, NumberConvert.ToString(rec.PaymentEndToEndId), tuple.Item3); if (rec.invoiceNumbers == null || rec.MergePaymId == MERGEID_SINGLEPAYMENT) { BuildBankAdviceText(sbAdvText, rec.InvoiceAN ?? string.Empty, tuple.Item2); } BuildBankAdviceText(sbAdvText, creditor?._Account, tuple.Item1); advText = sbAdvText.ToStringAndRelease(); } return(advText); }
public DanishFormatFieldBase CreateFormatField(CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, Uniconta.DataModel.Creditor creditor, Company company, bool glJournalGenerated = false) { var danishFields = new BECFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); switch (tran._PaymentMethod) { case PaymentTypes.VendorBankAccount: danishFields.TransTypeCommand = BECPayFormat.TRANSTYPE_ERH356; BBANIBANPaymentType(danishFields, tran); break; case PaymentTypes.IBAN: danishFields.TransTypeCommand = BECPayFormat.TRANSTYPE_ERH400; BBANIBANPaymentType(danishFields, tran); danishFields.ToAccountNumber = danishFields.ToAccountNumber != string.Empty ? danishFields.ToAccountNumber : danishFields.ReceiverIBAN; danishFields.PaymentId = danishFields.SwiftAddress; break; case PaymentTypes.PaymentMethod3: SharedFIKPayment(danishFields, tran); danishFields.TransTypeCommand = BECPayFormat.TRANSTYPE_ERH351; danishFields.PaymentId = string.Format("{0}{1}", BankFormatBase.FIK71, danishFields.PaymentId); danishFields.ToAccountNumber = string.Format("{0} {1}", BankFormatBase.FI, danishFields.ToAccountNumber); break; case PaymentTypes.PaymentMethod4: SharedFIKPayment(danishFields, tran); danishFields.TransTypeCommand = BECPayFormat.TRANSTYPE_ERH357; danishFields.PaymentId = string.Format("{0}{1}", BankFormatBase.FIK73, danishFields.PaymentId); danishFields.ToAccountNumber = string.Format("{0} {1}", BankFormatBase.FI, danishFields.ToAccountNumber); break; case PaymentTypes.PaymentMethod5: SharedFIKPayment(danishFields, tran); danishFields.TransTypeCommand = BECPayFormat.TRANSTYPE_ERH358; danishFields.PaymentId = string.Format("{0}{1}", BankFormatBase.FIK75, danishFields.PaymentId); danishFields.ToAccountNumber = string.Format("{0} {1}", BankFormatBase.FI, danishFields.ToAccountNumber); break; case PaymentTypes.PaymentMethod6: SharedFIKPayment(danishFields, tran); danishFields.TransTypeCommand = BECPayFormat.TRANSTYPE_ERH352; danishFields.PaymentId = string.Format("{0}{1}", BankFormatBase.FIK04, danishFields.PaymentId); danishFields.ToAccountNumber = string.Format("{0} {1}", BankFormatBase.GIRO, danishFields.ToAccountNumber); break; default: break; } danishFields.BeneficiaryName = glJournalGenerated ? string.Empty : ShortenWordToCriteria(tran.Creditor.Name, 35); var paymentAmount = Math.Round(tran.PaymentAmount, 2); if (danishFields.TransTypeCommand == BECPayFormat.TRANSTYPE_ERH400) { danishFields.Column06 = ShortenWordToCriteria(string.Format("{0}, {1} {2}", tran.Creditor.Address1, tran.Creditor.ZipCode, tran.Creditor.City), 35); //Modtager adresse1 danishFields.Column07 = ShortenWordToCriteria(tran.Creditor.Address2, 35); //Modtager adresse2 danishFields.Column08 = ShortenWordToCriteria(tran.Creditor.Address3, 35); //Modtager adresse3 danishFields.AmountForeignStr = paymentAmount.ToString("F"); danishFields.CurrencyCode = danishFields.Currency.ToString(); danishFields.ReferenceToPrimaryDoc = "02"; danishFields.ExpenseCode = "S"; } else { danishFields.Column06 = string.Empty; //Frekvens danishFields.Column07 = string.Empty; //Antal gange danishFields.Column08 = string.Empty; //Slutdato danishFields.AmountLocalStr = paymentAmount.ToString("F"); danishFields.CurrencyCode = String.Empty; danishFields.ReferenceToPrimaryDoc = "N"; danishFields.ExpenseCode = string.Empty; } var internalAdvText = StandardPaymentFunctions.InternalMessage(paymentFormat._OurMessage, tran, company, creditor); danishFields.OwnVoucherNumber = ShortenWordToCriteria(internalAdvText, 20); danishFields.ClearingCode = string.Empty; danishFields.Blanks2 = string.Empty; danishFields.NotUsed = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; danishFields.NotUsed02 = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; if (tran._PaymentMethod == PaymentTypes.VendorBankAccount || tran._PaymentMethod == PaymentTypes.PaymentMethod4) { danishFields.SenderName = ShortenWordToCriteria(company._Name, 35); danishFields.SenderAddress1 = ShortenWordToCriteria(company._Address1, 35); danishFields.SenderAddress2 = ShortenWordToCriteria(company._Address2, 35); danishFields.SenderAddress3 = ShortenWordToCriteria(company._Address3, 35); } else { danishFields.SenderName = string.Empty; danishFields.SenderAddress1 = string.Empty; danishFields.SenderAddress2 = string.Empty; danishFields.SenderAddress3 = string.Empty; } danishFields.Blanks = string.Empty; var externalAdvText = StandardPaymentFunctions.ExternalMessage(paymentFormat._Message, tran, company, creditor); var message = externalAdvText; if (tran._PaymentMethod == PaymentTypes.VendorBankAccount && danishFields.TransTypeCommand != BECPayFormat.TRANSTYPE_ERH400) { danishFields.PaymentId = ShortenWordToCriteria(message, 20); } //Extended notification if (danishFields.TransTypeCommand != BECPayFormat.TRANSTYPE_ERH400) { if (paymentFormat._ExtendedText) { if (message == null || message.Length <= 20) { message = string.Empty; } } else { message = string.Empty; } } int maxStrLen = 35; int maxLines = 6; if (tran._PaymentMethod == PaymentTypes.PaymentMethod4 || tran._PaymentMethod == PaymentTypes.PaymentMethod5 || tran._PaymentMethod == PaymentTypes.VendorBankAccount || tran._PaymentMethod == PaymentTypes.IBAN) { 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.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 BankDataFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); SharedForeignReceiverBankInfo(danishFields, tran); var externalAdvText = StandardPaymentFunctions.ExternalMessage(paymentFormat._Message, tran, company, creditor); var message = externalAdvText; message = NETSNorge.processString(message, 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.TransTypeCommand = BankDataPayFormat.TRANSTYPE_IB030204000003; danishFields.Index = BankDataPayFormat.INDEX01; var lineamountint = NumberConvert.ToLong(tran.PaymentAmount * 100d); danishFields.AmountLong = lineamountint; danishFields.FromAccountType = 2; danishFields.TransferCoin = new string(' ', 3); var paymentType = ISOPaymentType(tran.CurrencyLocalStr, bankAccount, danishFields.ReceiverIBAN, company); danishFields.TransferType = paymentType == UnicontaISO20022CreditTransfer.ISO20022PaymentTypes.SEPA ? BankDataPayFormat.FOREIGN_SEPATRANSFER : BankDataPayFormat.FOREIGN_STANDARDTRANSFER; 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.OtherTransfers = new List <string>() { NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(string.Empty, 4, false), NETSNorge.processString(string.Empty, 6, false), NETSNorge.processString(string.Empty, 2, false), NETSNorge.processString(string.Empty, 75, false), NETSNorge.processString(string.Empty, 75, false), NETSNorge.processString(string.Empty, 75, false), NETSNorge.processString(string.Empty, 24, false), NETSNorge.processString(string.Empty, 215, false) }; danishFields.UniquePaymRef = tran.PaymentEndToEndId.ToString(); return(danishFields); }
public DanishFormatFieldBase SecondaryCreateForeignFormatField(CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, Uniconta.DataModel.Creditor creditor, Company company, bool glJournalGenerated = false ) { var danishFields = new BankDataFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); SharedForeignReceiverBankInfo(danishFields, tran); danishFields.TransTypeCommand = BankDataPayFormat.TRANSTYPE_IB030204000003; danishFields.Index = BankDataPayFormat.INDEX02; danishFields.Blanks = NETSNorge.processString(string.Empty, 1, false); danishFields.SwiftAddress = NETSNorge.processString(danishFields.SwiftAddress, 11, false); danishFields.ReceiverBankInfo = new List <string>() { NETSNorge.processString("Bank", 35, false), //Dummy text - ask bank if correct Bank name is needed NETSNorge.processString("Address", 35, false), //Dummy text - ask bank if correct Bank address is needed NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(danishFields.CountryCode, 35, false), NETSNorge.processString(string.Empty, 33, false) //BankCode }; danishFields.ToAccountNumber = NETSNorge.processString(danishFields.ToAccountNumber, 34, false); danishFields.ReceiverIBAN = NETSNorge.processString(danishFields.ReceiverIBAN, 35, false); var paymentType = ISOPaymentType(tran.CurrencyLocalStr, bankAccount, danishFields.ReceiverIBAN, company); danishFields.TransferType = paymentType == UnicontaISO20022CreditTransfer.ISO20022PaymentTypes.SEPA ? 1 : 0;; danishFields.TransferTypeForeign = 1; //Cross border payments always paid by receiver danishFields.Blanks2 = NETSNorge.processString(string.Empty, 15, false); danishFields.Messages = new List <string>() { NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(string.Empty, 35, false), NETSNorge.processString(string.Empty, 35, false) }; var internalAdvText = StandardPaymentFunctions.InternalMessage(paymentFormat._OurMessage, tran, company, creditor); danishFields.OwnVoucherNumber = NETSNorge.processString(internalAdvText, 35, false); danishFields.SenderInformation = new List <string>() { NETSNorge.processString(string.Empty, 15, false), NETSNorge.processString(string.Empty, 13, false), NETSNorge.processString(string.Empty, 1, false), NETSNorge.processString(string.Empty, 7, false), NETSNorge.processString(string.Empty, 15, false), NETSNorge.processString(string.Empty, 13, false), NETSNorge.processString(string.Empty, 1, false), NETSNorge.processString(string.Empty, 7, false), NETSNorge.processString(string.Empty, 15, false), NETSNorge.processString(string.Empty, 13, false), NETSNorge.processString(string.Empty, 1, false), NETSNorge.processString(string.Empty, 7, false), NETSNorge.processString(string.Empty, 15, false), NETSNorge.processString(string.Empty, 13, false), NETSNorge.processString(string.Empty, 1, false), NETSNorge.processString(string.Empty, 7, false), NETSNorge.processString(string.Empty, 15, false), NETSNorge.processString(string.Empty, 13, false), NETSNorge.processString(string.Empty, 1, false), NETSNorge.processString(string.Empty, 7, false), NETSNorge.processString(string.Empty, 169, false), }; danishFields.UniquePaymRef = tran.PaymentEndToEndId.ToString(); return(danishFields); }
public static string ExternalMessage(string messageFormat, CreditorTransPayment rec, Company company, Uniconta.DataModel.Creditor creditor, bool UIMessage = false) { var sbAdvText = StringBuilderReuse.Create(); string advText; var country = creditor == null || creditor._Country == CountryCode.Unknown ? company._CountryId : creditor._Country; var tuple = MessageLabel(country); if (UIMessage == false && rec.invoiceNumbers != null && rec.MergePaymId != MERGEID_SINGLEPAYMENT) { var invNumbers = rec.invoiceNumbers.ToString(); var invNumbersCheck = Regex.Replace(invNumbers, "[^1-9]", ""); BuildBankAdviceText(sbAdvText, creditor?._OurAccount, tuple.Item1); BuildBankAdviceText(sbAdvText, invNumbersCheck == string.Empty ? invNumbersCheck : invNumbers, tuple.Item2); if (sbAdvText.Length == 0) { sbAdvText.Append(company.Name); } advText = sbAdvText.ToStringAndRelease(); } else { if (!string.IsNullOrEmpty(rec._Message)) { sbAdvText.Release(); return(rec._Message); } if (messageFormat != null) { sbAdvText.Append(messageFormat); if (rec.InvoiceAN == null && sbAdvText.IndexOf("%1") >= 0) { MessageFormatRemove(sbAdvText, "%1"); } if (company.Name == null && sbAdvText.IndexOf("%2") >= 0) { MessageFormatRemove(sbAdvText, "%2"); } if (rec.CashDiscount == 0 && sbAdvText.IndexOf("%3") >= 0) { MessageFormatRemove(sbAdvText, "%3"); } if (creditor?._OurAccount == null && sbAdvText.IndexOf("%4") >= 0) { MessageFormatRemove(sbAdvText, "%4"); } if (rec.TransType == null && sbAdvText.IndexOf("%5") >= 0) { MessageFormatRemove(sbAdvText, "%5"); } advText = string.Format(sbAdvText.Replace("%1", "{0}").Replace("%2", "{1}").Replace("%3", "{2}").Replace("%4", "{3}").Replace("%5", "{4}").ToStringAndRelease(), rec.InvoiceAN, company.Name, rec.CashDiscount, creditor?._OurAccount, rec.TransType); } else if (UIMessage == false) //Default message { BuildBankAdviceText(sbAdvText, creditor?._OurAccount, tuple.Item1); BuildBankAdviceText(sbAdvText, rec.InvoiceAN, tuple.Item2); BuildBankAdviceText(sbAdvText, company.Name); advText = sbAdvText.ToStringAndRelease(); } else { sbAdvText.Release(); advText = string.Empty; } } return(advText); }
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); }
public DanishFormatFieldBase CreateFormatField(CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, Uniconta.DataModel.Creditor creditor, Company company, bool glJournalGenerated = false) { var danishFields = new NordeaFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); danishFields.RecordType = "0"; danishFields.NotUsed = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; danishFields.BankCode = string.Empty; switch (tran._PaymentMethod) { case PaymentTypes.PaymentMethod3: //FIK71 SharedFIKPayment(danishFields, tran); danishFields.TransTypeCommand = NordeaPaymentFormat.TRANSTYPE_46; break; case PaymentTypes.PaymentMethod4: //FIK73 SharedFIKPayment(danishFields, tran); danishFields.TransTypeCommand = NordeaPaymentFormat.TRANSTYPE_46; break; case PaymentTypes.PaymentMethod5: //FIK75 SharedFIKPayment(danishFields, tran); danishFields.TransTypeCommand = NordeaPaymentFormat.TRANSTYPE_46; break; case PaymentTypes.PaymentMethod6: //FIK04 SharedFIKPayment(danishFields, tran); danishFields.TransTypeCommand = NordeaPaymentFormat.TRANSTYPE_46; break; case PaymentTypes.VendorBankAccount: BBANIBANPaymentType(danishFields, tran); break; case PaymentTypes.IBAN: BBANIBANPaymentType(danishFields, tran); danishFields.ToAccountNumber = danishFields.ReceiverIBAN; break; } danishFields.NameOfReceiver = glJournalGenerated ? string.Empty : ShortenWordToCriteria(tran.Creditor.Name, 35); var address = string.Empty; if (glJournalGenerated == false) { List <addressFormat> listAddress = new List <addressFormat>() { new addressFormat() { AddressStr = tran.Creditor.Address1 }, new addressFormat() { AddressStr = tran.Creditor.Address2 }, new addressFormat() { AddressStr = tran.Creditor.Address3 }, }; address = string.Join(", ", listAddress.Where(l => !string.IsNullOrEmpty(l.AddressStr)).Select(l => l.AddressStr.Trim())); } danishFields.AddressOfReceiver = glJournalGenerated ? string.Empty : ShortenWordToCriteria(string.Format("{0}", address), 35); danishFields.AddressOfReceiver2 = glJournalGenerated ? string.Empty : ShortenWordToCriteria(string.Format("{0} {1}", tran.Creditor.ZipCode, tran.Creditor.City), 35); danishFields.AddressOfReceiver3 = glJournalGenerated ? string.Empty : ShortenWordToCriteria(string.Format("{0}", tran.Creditor.Country), 35); danishFields.NotUsed02 = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty }; if (danishFields.TransferDate.DayOfWeek == DayOfWeek.Saturday) { danishFields.TransferDate = danishFields.TransferDate.AddDays(2); } else if (danishFields.TransferDate.DayOfWeek == DayOfWeek.Sunday) { danishFields.TransferDate = danishFields.TransferDate.AddDays(1); } var invoiceNumber = tran.invoiceNumbers == null?tran.Invoice.ToString() : tran.invoiceNumbers.ToString(); invoiceNumber = invoiceNumber == "0" ? string.Empty : string.Format("Faknr:{0}", invoiceNumber); var externalAdvText = StandardPaymentFunctions.ExternalMessage(paymentFormat._Message, tran, company, creditor); var message = externalAdvText; //Extended notification if (danishFields.TransTypeCommand != NordeaPaymentFormat.TRANSTYPE_49) { if (paymentFormat._ExtendedText) { if (message == null || message.Length <= 20) { message = string.Empty; } } else { message = string.Empty; } } int maxStrLen = 35; int maxLines = 4; if (tran._PaymentMethod == PaymentTypes.PaymentMethod4 || tran._PaymentMethod == PaymentTypes.PaymentMethod5 || tran._PaymentMethod == PaymentTypes.VendorBankAccount || tran._PaymentMethod == PaymentTypes.IBAN) { 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, string.Empty }; danishFields.Blanks = string.Empty; danishFields.Amount = Math.Round(tran.PaymentAmount, 2); danishFields.NotUsed04 = new List <string>() { string.Empty, string.Empty }; var internalAdvText = StandardPaymentFunctions.InternalMessage(paymentFormat._OurMessage, tran, company, creditor); danishFields.OwnVoucherNumber = ShortenWordToCriteria(internalAdvText, 20); danishFields.NotUsed05 = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; danishFields.NotUsed06 = new List <string>() { string.Empty, string.Empty, string.Empty, string.Empty }; danishFields.TextCode = danishFields.TransTypeCommand == NordeaPaymentFormat.TRANSTYPE_45 ? NordeaPaymentFormat.TEXTCODE_SHORTADVICE : string.Empty; danishFields.Blanks2 = string.Empty; danishFields.TextToBeneficiary = danishFields.TransTypeCommand == NordeaPaymentFormat.TRANSTYPE_45 ? ShortenWordToCriteria(externalAdvText, 20) : string.Empty; maxStrLen = 35; maxLines = 37; var longAdvice = NETSNorge.processString(string.Empty, maxStrLen * maxLines, false); List <string> longAdviceList = new List <string>(); if (longAdvice != string.Empty) { if (longAdvice.Length > maxLines * maxStrLen) { longAdvice = longAdvice.Substring(0, maxLines * maxStrLen); } longAdviceList = longAdvice.Select((x, i) => i) .Where(i => i % maxStrLen == 0) .Select(i => longAdvice.Substring(i, longAdvice.Length - i >= maxStrLen ? maxStrLen : longAdvice.Length - i)).ToList <string>(); } danishFields.LongAdviceText = longAdviceList; danishFields.PromptAdvice = danishFields.TransTypeCommand == NordeaPaymentFormat.TRANSTYPE_45 ? "0" : string.Empty; danishFields.Blanks3 = string.Empty; danishFields.UniquePaymRef = danishFields.TransTypeCommand == NordeaPaymentFormat.TRANSTYPE_45 ? tran.PaymentEndToEndId.ToString() : string.Empty; danishFields.ExpenseCode = danishFields.TransTypeCommand == NordeaPaymentFormat.TRANSTYPE_49 ? NordeaPaymentFormat.EXPENSECODE_BOTH : string.Empty; 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); }
public DanishFormatFieldBase CreateDomesticFormatField(CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, Uniconta.DataModel.Creditor creditor, Company company, bool glJournalGenerated = false) { var danishFields = new BankDataFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); DomesticPaymentType(danishFields, tran); danishFields.TransTypeCommand = BankDataPayFormat.TRANSTYPE_IB030202000005; danishFields.Index = BankDataPayFormat.INDEX01; var lineamountint = NumberConvert.ToLong(tran.PaymentAmount * 100d); danishFields.AmountLong = lineamountint; danishFields.FromAccountType = 2; danishFields.TransferType = 2; danishFields.ClearingTypeChannel = "0"; if (glJournalGenerated) { danishFields.NameOfReceiver = NETSNorge.processString(string.Empty, 32, false); danishFields.AddressOfReceiver = NETSNorge.processString(string.Empty, 32, false); danishFields.AddressOfReceiver2 = NETSNorge.processString(string.Empty, 32, false); danishFields.ZipCodeOfReceiver = NETSNorge.processString(string.Empty, 4, false); danishFields.CityOfReceiver = NETSNorge.processString(string.Empty, 32, false); } else { danishFields.NameOfReceiver = NETSNorge.processString(tran.Creditor.Name, 32, false); danishFields.AddressOfReceiver = NETSNorge.processString(tran.Creditor.Address1, 32, false); danishFields.AddressOfReceiver2 = NETSNorge.processString(tran.Creditor.Address2, 32, false); danishFields.ZipCodeOfReceiver = NETSNorge.processString(tran.Creditor.ZipCode, 4, false); danishFields.CityOfReceiver = NETSNorge.processString(tran.Creditor.City, 32, false); } var internalAdvText = StandardPaymentFunctions.InternalMessage(paymentFormat._OurMessage, tran, company, creditor); danishFields.OwnVoucherNumber = NETSNorge.processString(internalAdvText, 35, false); //Message to Beneficiary >> var externalAdvText = StandardPaymentFunctions.ExternalMessage(paymentFormat._Message, tran, company, creditor); var message = externalAdvText; danishFields.ReceiverAccountStatement = NETSNorge.processString(externalAdvText, 35, false); //Extended notification if (paymentFormat._ExtendedText) { if (message == null || message.Length <= 35) { message = string.Empty; } } else { message = string.Empty; } message = NETSNorge.processString(message, 315, false); int maxStrLen = 35; int maxLines = 9; 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.ReceiverAccountStatement = NETSNorge.processString(message, 35, false); danishFields.AdviceText = messageList; //Message to Beneficiary << danishFields.Blanks = NETSNorge.processString(string.Empty, 1, false); danishFields.Blanks2 = NETSNorge.processString(string.Empty, 215, false); danishFields.UniquePaymRef = tran.PaymentEndToEndId.ToString(); return(danishFields); }
public void SharedFIKPayment(DanishFormatFieldBase field, CreditorTransPayment tran) { var ocrLine = tran.PaymentId; ocrLine = ocrLine.Replace(" ", ""); ocrLine = ocrLine.Replace("+71<", ""); ocrLine = ocrLine.Replace(">71<", ""); ocrLine = ocrLine.Replace("+73<", ""); ocrLine = ocrLine.Replace(">73<", ""); ocrLine = ocrLine.Replace("+75<", ""); ocrLine = ocrLine.Replace(">75<", ""); ocrLine = ocrLine.Replace("+04<", ""); ocrLine = ocrLine.Replace(">04<", ""); ocrLine = ocrLine.Replace("<", ""); ocrLine = ocrLine.Replace(">", ""); var paymID = string.Empty; var creditorAccount = string.Empty; if (tran._PaymentMethod == PaymentTypes.PaymentMethod4) //FIK73 { ocrLine = ocrLine.Replace("+", ""); creditorAccount = ocrLine; } else { int index = ocrLine.IndexOf("+"); if (index > 0) { paymID = ocrLine.Substring(0, index); creditorAccount = ocrLine.Remove(0, index + 1); } } switch (tran._PaymentMethod) { case PaymentTypes.PaymentMethod3: field.FormType = BankFormatBase.FIK71; if (paymID.Length > BaseDocument.FIK71LENGTH) { paymID = paymID.Substring(paymID.Length - BaseDocument.FIK71LENGTH, BaseDocument.FIK71LENGTH); } else { paymID = paymID.PadLeft(BaseDocument.FIK71LENGTH, '0'); } break; case PaymentTypes.PaymentMethod4: field.FormType = BankFormatBase.FIK73; break; case PaymentTypes.PaymentMethod5: field.FormType = BankFormatBase.FIK75; if (paymID.Length > BaseDocument.FIK75LENGTH) { paymID = paymID.Substring(paymID.Length - BaseDocument.FIK75LENGTH, BaseDocument.FIK75LENGTH); } else { paymID = paymID.PadLeft(BaseDocument.FIK75LENGTH, '0'); } break; case PaymentTypes.PaymentMethod6: field.FormType = BankFormatBase.FIK04; if (paymID.Length > BaseDocument.FIK04LENGTH) { paymID = paymID.Substring(paymID.Length - BaseDocument.FIK04LENGTH, BaseDocument.FIK04LENGTH); } else { paymID = paymID.PadLeft(BaseDocument.FIK04LENGTH, '0'); } break; } field.PaymentId = paymID; field.ToAccountNumber = creditorAccount; }
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 CreateIndbetalingskortFormatField(CreditorTransPayment tran, CreditorPaymentFormat paymentFormat, BankStatement bankAccount, Uniconta.DataModel.Creditor creditor, Company company, bool glJournalGenerated = false) { var danishFields = new BankDataFormatFields(); SharedCodeForCreateBankFormatFields(company, tran, paymentFormat, bankAccount, danishFields); SharedFIKPayment(danishFields, tran); danishFields.TransTypeCommand = BankDataPayFormat.TRANSTYPE_IB030207000002; danishFields.Index = BankDataPayFormat.INDEX01; var lineamountint = NumberConvert.ToLong(tran.PaymentAmount * 100d); danishFields.AmountLong = lineamountint; danishFields.FromAccountType = 2; danishFields.GiroReg = NETSNorge.processString(string.Empty, 4, false); if (danishFields.FormType == BankFormatBase.FIK04) { danishFields.ToAccountGiro = NETSNorge.processString(danishFields.ToAccountNumber, 10, false); danishFields.ToAccountCreditor = NETSNorge.processString(string.Empty, 8, false); } else { danishFields.ToAccountGiro = NETSNorge.processString(string.Empty, 10, false); danishFields.ToAccountCreditor = NETSNorge.processString(danishFields.ToAccountNumber, 8, false); } string credName = glJournalGenerated ? string.Empty : tran.Creditor.Name; danishFields.NameOfReceiver = NETSNorge.processString(credName, 32, false); danishFields.AlternativSender = NETSNorge.processString(string.Empty, 32, false); var internalAdvText = StandardPaymentFunctions.InternalMessage(paymentFormat._OurMessage, tran, company, creditor); danishFields.OwnVoucherNumber = NETSNorge.processString(internalAdvText, 35, false); danishFields.SenderName = NETSNorge.processString(company._Name, 35, false); danishFields.SenderAddress1 = NETSNorge.processString(company._Address1, 35, false); danishFields.SenderAddress2 = NETSNorge.processString(company._Address2, 35, false); danishFields.SenderAddress3 = NETSNorge.processString(company._Address3, 35, false); danishFields.Blanks = NETSNorge.processString(string.Empty, 35, false); if (danishFields.FormType == BankFormatBase.FIK73 || danishFields.FormType == BankFormatBase.FIK75) { var externalAdvText = StandardPaymentFunctions.ExternalMessage(paymentFormat._Message, tran, company, creditor); var message = externalAdvText; message = NETSNorge.processString(message, 210, false); int maxStrLen = 35; int maxLines = 6; 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.ReceiverAccountInfo = messageList; } else { danishFields.ReceiverAccountInfo = 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.Blanks2 = NETSNorge.processString(string.Empty, 16, false); danishFields.Reserved = NETSNorge.processString(string.Empty, 215, false); danishFields.UniquePaymRef = tran.PaymentEndToEndId.ToString(); return(danishFields); }
public void StatusReport(PaymentsGrid dgCreditorTranOpenGrid, string xmlFileName, CrudAPI capi) { try { if (!this.IsValidStatusReportFormat(xmlFileName)) { UnicontaMessageBox.Show(string.Format("Payment Status Report doesn't have a valid format"), Uniconta.ClientTools.Localization.lookup("Error")); } else { //Clear SystemInfo field>> var grid = dgCreditorTranOpenGrid.GetVisibleRows() as IEnumerable <CreditorTransPayment>; foreach (var rec in grid) { rec.ErrorInfo = null; } //Clear SystemInfo field<< var changedlst = new List <CrudAPI.UpdatePair>(); using (var xmlReader = new StreamReader(xmlFileName)) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(xmlReader); var paymStatusList = this.ReadStatusReport(xmldoc); IEnumerable <UnicontaClient.Pages.CreditorTransPayment> queryPaymentTrans = null; foreach (var paymStatusRec in paymStatusList) { if (dgCreditorTranOpenGrid.ItemsSource != null) { var Trans = dgCreditorTranOpenGrid.GetVisibleRows() as IEnumerable <CreditorTransPayment>; queryPaymentTrans = Trans.Where(paymentTrans => { var endToEndID = Regex.Replace(paymStatusRec.TransEndToEndId ?? "0", "[^0-9]", ""); return(paymentTrans != null && (paymentTrans.PaymentEndToEndId.ToString() == endToEndID)); }); foreach (var rec in queryPaymentTrans) { string statusDescription = paymStatusRec.TransStatusCodeAdd == string.Empty ? paymStatusRec.TransStatusDescription : paymStatusRec.TransStatusCodeAdd; rec.ErrorInfo = string.Format("{0}\n{1}", paymStatusRec.TransStatusDescriptionShort, statusDescription); if (paymStatusRec.TransStatus == PAYMSTATUSID_ACSC)//The payment has been executed { var org = new CreditorTransPayment(); StreamingManager.Copy(rec, org); rec._Paid = true; rec.NotifyPropertyChanged("Paid"); changedlst.Add(new CrudAPI.UpdatePair() { loaded = org, modified = rec }); } } } } if (changedlst != null) { capi.Update(changedlst); } } } } catch (Exception ex) { UnicontaMessageBox.Show(ex, Uniconta.ClientTools.Localization.lookup("Exception"), System.Windows.MessageBoxButton.OK); return; } }