public IList <X509Certificate2> ReadCertificates() { var stringReader = new StringReader(pemBlock); var pemLines = StringBuilderReuse.Create(); string line; var certificates = new List <X509Certificate2>(); while ((line = stringReader.ReadLine()) != null) { pemLines.Append(line).Append("\n"); if (line != "-----END CERTIFICATE-----") { continue; } var pemCertificate = pemLines.ToString(); pemLines.Clear(); var certReader = new StringReader(pemCertificate); var pemReader = new PemReader(certReader); var readCert = pemReader.ReadObject() as Org.BouncyCastle.X509.X509Certificate; certificates.Add(new X509Certificate2(readCert.GetEncoded())); } pemLines.Release(); return(certificates); }
private string GetFilterString(string defaultFilter, List <int> newRowIds, List <int> existingRowIds = null) { var strBuilder = StringBuilderReuse.Create(defaultFilter); strBuilder.Append(" And Not [RowId] In ("); var totalRowIds = new List <int>(); if (newRowIds != null) { totalRowIds.AddRange(newRowIds); } if (existingRowIds != null) { totalRowIds.AddRange(existingRowIds); } foreach (var rowId in totalRowIds.Distinct()) { strBuilder.Append('\'').AppendNum(rowId).Append('\'').Append(','); } strBuilder.Length--; strBuilder.Append(')'); return(strBuilder.ToStringAndRelease()); }
async private void ImportButton_Click(object sender, RoutedEventArgs e) { System.IO.FileStream stream = null; try { var selectedJournal = lookupJournal.SelectedItem as GLDailyJournalClient; if (selectedJournal == null) { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("RecordNotSelected"), Uniconta.ClientTools.Localization.lookup("Error")); return; } var importDateV = new ImportDATEV(api, selectedJournal); stream = new System.IO.FileStream(browseFile.FilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read); var journalLines = await importDateV.CreateJournalLines(stream); stream.Dispose(); stream = null; if (importDateV.faultyAccounts.Count != 0) { journalLines = null; var sb = StringBuilderReuse.Create(); sb.Append(string.Format(Uniconta.ClientTools.Localization.lookup("MissingOBJ"), Uniconta.ClientTools.Localization.lookup("Account"))).AppendLine(':'); foreach (var s in importDateV.faultyAccounts) { sb.AppendLine(s); } UnicontaMessageBox.Show(sb.ToStringAndRelease(), "", MessageBoxButton.OK); return; } if (journalLines != null && journalLines.Count > 0) { var result = await api.Insert(journalLines); if (result == ErrorCodes.Succes) { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("Succes"), Uniconta.ClientTools.Localization.lookup("Message")); DialogResult = true; } } else { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("NoJournalLinesCreated"), Uniconta.ClientTools.Localization.lookup("Error")); return; } } catch (Exception ex) { stream?.Dispose(); UnicontaMessageBox.Show(ex); DialogResult = false; } }
private void DashboardLayoutItem_MouseUp(object sender, MouseButtonEventArgs e) { DevExpress.DashboardWpf.DashboardLayoutItem item = sender as DevExpress.DashboardWpf.DashboardLayoutItem; FocusedItem = dashboardViewerUniconta.Dashboard.Items[item.Name]; if (FocusedItem != null && (((DataDashboardItem)FocusedItem).DataSource) != null && dataSourceAndTypeMap.ContainsKey((((DataDashboardItem)FocusedItem).DataSource).ComponentName)) { tableType = dataSourceAndTypeMap[(((DataDashboardItem)FocusedItem).DataSource).ComponentName]; selectedDataSourceName = (((DataDashboardItem)FocusedItem).DataSource).ComponentName; var dataSourceName = (((DataDashboardItem)FocusedItem).DataSource).Name; int startindex = dataSourceName.IndexOf('('); if (startindex >= 0) { int Endindex = dataSourceName.IndexOf(')'); string companyName = dataSourceName.Substring(startindex + 1, Endindex - startindex - 1); companyName = string.Compare(companyName, company.KeyName) == 0 ? companyName : company.KeyName; dashboardViewerUniconta.TitleContent = string.Format("{0} {1} ( {2} )", Uniconta.ClientTools.Localization.lookup("Company"), companyName, tableType.Name); } else { dashboardViewerUniconta.TitleContent = string.Format("{0} {1} ( {2} )", Uniconta.ClientTools.Localization.lookup("Company"), company.KeyName, tableType.Name); } } else if (((DataDashboardItem)FocusedItem).DataSource is DashboardFederationDataSource) { var dataSource = ((DataDashboardItem)FocusedItem).DataSource; var sources = ((DevExpress.DataAccess.DataFederation.FederationDataSourceBase)(dataSource)).Sources; var name = StringBuilderReuse.Create(); name.Append(_selectedDashBoard._Name).Append(" ("); foreach (var source in sources) { if (source.DataSource is DashboardObjectDataSource) { var componentName = ((DashboardObjectDataSource)(source.DataSource)).ComponentName; name.Append(source.Name).Append(" "); if (!dataSourceLoadingParams.Contains(componentName)) { dataSourceLoadingParams.Add(componentName); } } } name.Append(')'); dashboardViewerUniconta.TitleContent = name.ToStringAndRelease(); if (!LoadOnOpen) // load on open is saved as true. and first time on load user click on federation related dashboardItem { LoadOnOpen = true; } dashboardViewerUniconta.ReloadData(); } else { tableType = null; selectedDataSourceName = null; dashboardViewerUniconta.TitleContent = string.Empty; } }
void ExportFile(VouchersClient voucher, ZipOutputStream zipOutputStream) { byte[] attachment = voucher.Buffer; voucher._Data = null; voucher._LoadedData = null; if (attachment == null) { if (voucher._Url != null) { try { if (voucher.IsWebUrl) { #if !SILVERLIGHT attachment = new WebClient().DownloadData(voucher._Url); var ext = System.IO.Path.GetExtension(voucher._Url); if (ext != null) { voucher._Fileextension = DocumentConvert.GetDocumentType(DocumentConvert.GetExtension(ext)); } #endif } else { #if SILVERLIGHT attachment = UtilFunctions.LoadFile(voucher._Url); #else attachment = UtilFunctions.LoadFile(voucher._Url).GetAwaiter().GetResult(); #endif } if (attachment == null) { return; } } catch { return; } } else { return; } } // Write the data to the ZIP file var sb = StringBuilderReuse.Create(voucher._Text).Replace('/', '-').Replace('\\', '-'); sb.Append('_').Append(voucher.RowId).Append('.').Append(Enum.GetName(typeof(FileextensionsTypes), IdObject.get((byte)voucher._Fileextension))); var name = sb.ToStringAndRelease(); zipOutputStream.PutNextEntry(new ZipEntry(name)); zipOutputStream.Write(attachment, 0, attachment.Length); WriteLogLine(string.Format(Uniconta.ClientTools.Localization.lookup("ExportingFile"), name)); }
protected X509Certificate2 FromPemBlock(string pem) { var builder = StringBuilderReuse.Create(); builder.Append(pem); builder.Remove('\n'); builder.Remove('\r'); builder.Remove("-----BEGIN CERTIFICATE-----"); builder.Remove("-----END CERTIFICATE-----"); return(new X509Certificate2(Convert.FromBase64String(builder.ToStringAndRelease()))); }
private void Generate() { dgOpenTransactionGrid.tableView.CloseEditor(); if (selectedInvoices != null && selectedRowIds != null) { var sb = StringBuilderReuse.Create(); if (selectedInvoices.Count > 0) { sb.Append("I:"); foreach (var inv in selectedInvoices) { sb.Append(inv).Append(';'); } } else if (selectedRowIds.Count > 0) { sb.Append("R:"); foreach (var row in selectedRowIds) { sb.AppendNum(row).Append(';'); } } var len = sb.Length; if (len > 0 && sb[len - 1] == ';') // remove the last { sb.Length--; } settlement = sb.ToStringAndRelease(); if (SelectedJournalLine != null) { refreshParams = new object[6]; refreshParams[0] = SelectedJournalLine; refreshParams[1] = settlement; refreshParams[2] = RemainingAmt; refreshParams[3] = RemainingAmtCur; refreshParams[4] = settleCur != 0 ? Enum.GetName(typeof(Currencies), IdObject.get(settleCur)) : null; refreshParams[5] = OffSet; } else if (SelectedBankStatemenLine != null) { refreshParams = new object[2]; refreshParams[0] = SelectedBankStatemenLine; refreshParams[1] = settlement; } CloseDockItem(); } }
/// <summary> /// LT: Only two Addresslines are accepted /// </summary> public override PostalAddress CreditorAddress(Uniconta.DataModel.Creditor creditor, PostalAddress creditorAddress, bool unstructured = false) { if (CredPaymFormat.Bank == ltBank.Standard) { return(null); } var adr1 = StandardPaymentFunctions.RegularExpressionReplace(creditor._Address1, allowedCharactersRegEx, replaceCharactersRegEx); var adr2 = StandardPaymentFunctions.RegularExpressionReplace(creditor._Address2, allowedCharactersRegEx, replaceCharactersRegEx); var adr3 = StandardPaymentFunctions.RegularExpressionReplace(creditor._Address3, allowedCharactersRegEx, replaceCharactersRegEx); var zipCode = StandardPaymentFunctions.RegularExpressionReplace(creditor._ZipCode, allowedCharactersRegEx, replaceCharactersRegEx); var city = StandardPaymentFunctions.RegularExpressionReplace(creditor._City, allowedCharactersRegEx, replaceCharactersRegEx); unstructured = false; switch (CredPaymFormat.Bank) { case ltBank.Swedbank: case ltBank.SEB: case ltBank.Luminor: unstructured = false; break; default: unstructured = false; break; } if (unstructured) { var strB = StringBuilderReuse.Create(); var adr1_result = strB.Append(adr1).Append(AddSeparator(adr2)).Append(adr2).ToString(); creditorAddress.AddressLine1 = adr1_result.Length > 70 ? adr1_result.Substring(0, 70) : adr1_result; strB.Clear(); var adr2_result = strB.Append(adr3).Append(AddSeparator(zipCode)).Append(zipCode).Append(AddSeparator(city)).Append(city).ToString(); creditorAddress.AddressLine2 = adr2_result.Length > 70 ? adr2_result.Substring(0, 70) : adr2_result; creditorAddress.Unstructured = true; strB.Release(); } else { creditorAddress.ZipCode = zipCode; creditorAddress.CityName = city; creditorAddress.StreetName = adr1; } creditorAddress.CountryId = ((CountryISOCode)creditor._Country).ToString(); return(creditorAddress); }
/// <summary> /// Creditor Address /// </summary> public override PostalAddress CreditorAddress(Uniconta.DataModel.Creditor creditor, PostalAddress creditorAddress, bool unstructured = false) { var adr1 = StandardPaymentFunctions.RegularExpressionReplace(creditor._Address1, allowedCharactersRegEx, replaceCharactersRegEx); var adr2 = StandardPaymentFunctions.RegularExpressionReplace(creditor._Address2, allowedCharactersRegEx, replaceCharactersRegEx); var adr3 = StandardPaymentFunctions.RegularExpressionReplace(creditor._Address3, allowedCharactersRegEx, replaceCharactersRegEx); var zipCode = StandardPaymentFunctions.RegularExpressionReplace(creditor._ZipCode, allowedCharactersRegEx, replaceCharactersRegEx); var city = StandardPaymentFunctions.RegularExpressionReplace(creditor._City, allowedCharactersRegEx, replaceCharactersRegEx); if (creditor._ZipCode != null) { creditorAddress.ZipCode = zipCode; creditorAddress.CityName = city; creditorAddress.StreetName = adr1; } else { if (companyBankEnum == CompanyBankENUM.Rabobank) //Rabobank: Only two Addresslines are accepted { var strB = StringBuilderReuse.Create(); var adr1_result = strB.Append(adr1).Append(AddSeparator(adr2)).Append(adr2).ToString(); creditorAddress.AddressLine1 = adr1_result.Length > 70 ? adr1_result.Substring(0, 70) : adr1_result; strB.Clear(); var adr2_result = strB.Append(adr3).Append(AddSeparator(zipCode)).Append(zipCode).Append(AddSeparator(city)).Append(city).ToString(); creditorAddress.AddressLine2 = adr2_result.Length > 70 ? adr2_result.Substring(0, 70) : adr2_result; creditorAddress.Unstructured = true; strB.Release(); } else { creditorAddress.AddressLine1 = adr1; creditorAddress.AddressLine2 = adr2; creditorAddress.AddressLine3 = adr3; creditorAddress.Unstructured = true; } } creditorAddress.CountryId = ((CountryISOCode)creditor._Country).ToString(); return(creditorAddress); }
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); }
string GetValues(UnicontaBaseEntity oldRecord, UnicontaBaseEntity newRecord, bool IsNewValue) { if (oldRecord == null) { return(null); } var prop = oldRecord.GetType().GetProperty(this._PropName); if (prop != null) { return(CheckProperty(oldRecord, newRecord, IsNewValue, prop)); } StringBuilderReuse values = null; string singleVal = null; foreach (var RecProperty in oldRecord.GetType().GetProperties()) { var val = CheckProperty(oldRecord, newRecord, IsNewValue, RecProperty); if (val != null) { if (singleVal == null) { singleVal = val; } else { if (values == null) { values = StringBuilderReuse.Create(); values.Append(singleVal); } values.Append(';').Append(val); } } } return((values != null) ? values.ToStringAndRelease() : singleVal); }
public bool MergePayments(Company company, PaymentsGrid dgCreditorTranOpenGrid, CreditorPaymentFormat credPaymFormat, SQLCache bankAccountCache) { string creditorAcc = string.Empty; string creditorOCRPaymentId = string.Empty; string creditorBIC = string.Empty; string mergePaymIdString = string.Empty; if (credPaymFormat._PaymentGrouping == PaymentGroupingType.Invoice) { return(false); } var credCache = company.GetCache(typeof(Uniconta.DataModel.Creditor)); PaymentISO20022Validate paymentISO20022Validate = new PaymentISO20022Validate(); BankSpecificSettings bankSpecific = BankSpecificSettings.BankSpecTypeInstance(credPaymFormat); try { var grid = dgCreditorTranOpenGrid.GetVisibleRows() as IEnumerable <CreditorTransPayment>; foreach (var rec in grid) { if (rec._PaymentFormat != credPaymFormat._Format || rec._OnHold || rec._Paid) { rec.MergePaymId = Uniconta.ClientTools.Localization.lookup("Excluded"); continue; } //Validate payments >> paymentISO20022Validate.CompanyBank(credPaymFormat); var validateRes = paymentISO20022Validate.ValidateISO20022(company, rec, bankAccountCache); if (validateRes.HasErrors) { foreach (CheckError error in validateRes.CheckErrors) { rec.ErrorInfo += rec.ErrorInfo == null?error.ToString() : Environment.NewLine + rec.ErrorInfo; } rec.MergePaymId = Uniconta.ClientTools.Localization.lookup("Excluded"); continue; } else { rec.ErrorInfo = BaseDocument.VALIDATE_OK; } //Validate payments << var creditor = (Uniconta.DataModel.Creditor)credCache.Get(rec.Account); string creditorNumber = creditor._Account; string paymGrpVal = string.Empty; switch (credPaymFormat._PaymentGrouping) { case PaymentGroupingType.Date: paymGrpVal = rec._PaymentDate.ToString("yyyyMMdd"); break; case PaymentGroupingType.Week: paymGrpVal = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(rec._PaymentDate, CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday).ToString(); break; case PaymentGroupingType.All: break; } var mergePaymId = StringBuilderReuse.Create(); switch (rec._PaymentMethod) { case PaymentTypes.VendorBankAccount: creditorAcc = bankSpecific.CreditorBBAN(rec._PaymentId, creditor._PaymentId, rec._SWIFT); creditorOCRPaymentId = bankSpecific.CreditorRefNumber(rec._PaymentId); creditorBIC = bankSpecific.CreditorBIC(rec._SWIFT); if (creditorOCRPaymentId != string.Empty && creditorBIC != string.Empty) { mergePaymId.Append(creditorNumber).Append('-').Append(creditorAcc).Append('-').Append(creditorOCRPaymentId).Append('-').Append(creditorBIC).Append('-').Append(rec.CurrencyLocalStr).Append('-').Append(paymGrpVal); } else if (creditorOCRPaymentId != string.Empty) { mergePaymId.Append(creditorNumber).Append('-').Append(creditorAcc).Append('-').Append(creditorOCRPaymentId).Append('-').Append(rec.CurrencyLocalStr).Append('-').Append(paymGrpVal); } else if (creditorBIC != string.Empty) { mergePaymId.Append(creditorNumber).Append('-').Append(creditorAcc).Append('-').Append(creditorBIC).Append('-').Append(rec.CurrencyLocalStr).Append('-').Append(paymGrpVal); } else { mergePaymId.Append(creditorNumber).Append('-').Append(creditorAcc).Append('-').Append(rec.CurrencyLocalStr).Append('-').Append(paymGrpVal); } break; case PaymentTypes.IBAN: creditorAcc = bankSpecific.CreditorIBAN(rec._PaymentId, creditor._PaymentId, company._CountryId, creditor._Country); creditorBIC = bankSpecific.CreditorBIC(rec._SWIFT); creditorOCRPaymentId = bankSpecific.CreditorRefNumberIBAN(rec._PaymentId, company._CountryId, creditor._Country); mergePaymId.Append(creditorNumber).Append('-').Append(creditorAcc).Append('-').Append(creditorBIC).Append('-').Append(rec.CurrencyLocalStr).Append('-').Append(paymGrpVal); break; case PaymentTypes.PaymentMethod3: //FIK71 var tuple71 = bankSpecific.CreditorFIK71(rec._PaymentId); creditorOCRPaymentId = tuple71.Item1; creditorOCRPaymentId = BaseDocument.FIK71 + "/" + creditorOCRPaymentId; creditorAcc = tuple71.Item2; mergePaymId.Append(creditorNumber).Append('-').Append(creditorOCRPaymentId).Append('-').Append(creditorAcc).Append('-').Append(rec.CurrencyLocalStr).Append('-').Append(paymGrpVal); break; case PaymentTypes.PaymentMethod5: //FIK75 var tuple75 = bankSpecific.CreditorFIK75(rec._PaymentId); creditorOCRPaymentId = tuple75.Item1; creditorOCRPaymentId = BaseDocument.FIK75 + "/" + creditorOCRPaymentId; creditorAcc = tuple75.Item2; mergePaymId.Append(creditorNumber).Append('-').Append(creditorOCRPaymentId).Append('-').Append(creditorAcc).Append('-').Append(rec.CurrencyLocalStr).Append('-').Append(paymGrpVal); break; case PaymentTypes.PaymentMethod4: //FIK73 creditorOCRPaymentId = BaseDocument.FIK73 + "/"; creditorAcc = bankSpecific.CreditorFIK73(rec._PaymentId); mergePaymId.Append(creditorNumber).Append('-').Append(creditorOCRPaymentId).Append('-').Append(creditorAcc).Append('-').Append(rec.CurrencyLocalStr).Append('-').Append(paymGrpVal); break; case PaymentTypes.PaymentMethod6: //FIK04 var tuple04 = bankSpecific.CreditorFIK04(rec._PaymentId); creditorOCRPaymentId = tuple04.Item1; creditorOCRPaymentId = BaseDocument.FIK04 + "/" + creditorOCRPaymentId; creditorAcc = tuple04.Item2; mergePaymId.Append(creditorNumber).Append('-').Append(creditorOCRPaymentId).Append('-').Append(creditorAcc).Append('-').Append(rec.CurrencyLocalStr).Append('-').Append(paymGrpVal); break; } if (mergePaymId.Length > 0 && mergePaymId[mergePaymId.Length - 1] == '-') { mergePaymId.Length--; } rec.MergePaymId = mergePaymId.ToStringAndRelease(); } var noDuplicates = grid.Where(x => x.MergePaymId != Uniconta.ClientTools.Localization.lookup("Excluded")).GroupBy(s => s.MergePaymId).Where(grp => grp.Count() == 1).SelectMany(x => x); foreach (var rec in noDuplicates) { if (rec.PaymentAmount <= 0) { rec.MergePaymId = Uniconta.ClientTools.Localization.lookup("Excluded"); rec.ErrorInfo = string.Concat(Uniconta.ClientTools.Localization.lookup("PaymentAmount"), "< 0"); } else { rec.MergePaymId = MERGEID_SINGLEPAYMENT; } } return(true); } catch (Exception ex) { UnicontaMessageBox.Show(ex, Uniconta.ClientTools.Localization.lookup("Exception"), System.Windows.MessageBoxButton.OK); return(false); } }
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); }
void LoadControls() { txtFromAdd.Text = string.Empty; txtToAdd.Text = string.Empty; var journalline = this.journalline; addressList = new List <Address>(); var sbWork = StringBuilderReuse.Create(); sbWork.AppendLineConditional(company._Name).AppendLineConditional(company._Address1).AppendLineConditional(company._Address2).AppendLineConditional(company._Address3); addressList.Add(new Address { Name = Uniconta.ClientTools.Localization.lookup("Company"), ContactAddress = sbWork.ToString() }); sbWork.Clear(); if (employee != null) { sbWork.AppendLineConditional(employee._Name).AppendLineConditional(employee._Address1).AppendLineConditional(employee._Address2); if (employee._ZipCode != null) { sbWork.Append(employee._ZipCode).Append(' '); } sbWork.Append(employee._City); addressList.Add(new Address { Name = Uniconta.ClientTools.Localization.lookup("Private"), ContactAddress = sbWork.ToString() }); } sbWork.Clear(); if (debtor != null) { sbWork.AppendLineConditional(debtor._Name).AppendLineConditional(debtor._Address1).AppendLineConditional(debtor._Address2).AppendLineConditional(debtor._Address3); if (debtor._ZipCode != null) { sbWork.Append(debtor._ZipCode).Append(' '); } sbWork.Append(debtor._City); addressList.Add(new Address { Name = Uniconta.ClientTools.Localization.lookup("Debtor"), ContactAddress = sbWork.ToString() }); } else if (installation != null) { sbWork.AppendLineConditional(installation._Name).AppendLineConditional(installation._Address1).AppendLineConditional(installation._Address2).AppendLineConditional(installation._Address3); if (installation._ZipCode != null) { sbWork.Append(installation._ZipCode).Append(' '); } sbWork.Append(installation._City); addressList.Add(new Address { Name = Uniconta.ClientTools.Localization.lookup("Debtor"), ContactAddress = sbWork.ToString() }); } sbWork.Release(); sbWork = null; Address emptyAddress = null; if (journalline.RowId != 0 && journalline._RegistrationType == RegistrationType.Mileage && addEmptyAddress) { emptyAddress = new Address { Name = string.Empty, ContactAddress = string.Empty }; addressList.Add(emptyAddress); } addressList.Add(new Address { Name = Uniconta.ClientTools.Localization.lookup("Other"), ContactAddress = EMPTYADDRESS });; cmbFromAdd.ItemsSource = addressList; cmbToAdd.ItemsSource = addressList; if (journalline.RowId != 0 && journalline._RegistrationType == RegistrationType.Mileage && addEmptyAddress) { var index = addressList.IndexOf(emptyAddress); cmbFromAdd.SelectedIndex = index; cmbToAdd.SelectedIndex = index; } else { cmbFromAdd.SelectedIndex = 0; cmbToAdd.SelectedIndex = 1; txtFromAdd.Text = addressList.Count >= 1 ? addressList[0].ContactAddress : string.Empty; if (addressList.Count == 4) { cmbToAdd.SelectedIndex = 2; txtToAdd.Text = addressList[2].ContactAddress; } else if (addressList.Count >= 4) { cmbToAdd.SelectedIndex = 3; txtToAdd.Text = addressList[3].ContactAddress; } } if (string.IsNullOrEmpty(txtFromAdd.Text)) { txtFromAdd.Text = journalline.AddressFrom; } if (string.IsNullOrEmpty(txtToAdd.Text)) { txtToAdd.Text = journalline.AddressTo; } txtMonHrs.IsReadOnly = journalline.StatusDay1 == 1 || journalline.StatusDay1 == 2 ? true : false; txtTueHrs.IsReadOnly = journalline.StatusDay2 == 1 || journalline.StatusDay2 == 2 ? true : false; txtWedHrs.IsReadOnly = journalline.StatusDay3 == 1 || journalline.StatusDay3 == 2 ? true : false; txtThuHrs.IsReadOnly = journalline.StatusDay4 == 1 || journalline.StatusDay4 == 2 ? true : false; txtFriHrs.IsReadOnly = journalline.StatusDay5 == 1 || journalline.StatusDay5 == 2 ? true : false; txtSatHrs.IsReadOnly = journalline.StatusDay6 == 1 || journalline.StatusDay6 == 2 ? true : false; txtSunHrs.IsReadOnly = journalline.StatusDay7 == 1 || journalline.StatusDay7 == 2 ? true : false; txtMonHrs.Background = SetBackGroundColor(txtMonHrs, journalline.StatusDay1); txtTueHrs.Background = SetBackGroundColor(txtTueHrs, journalline.StatusDay2); txtWedHrs.Background = SetBackGroundColor(txtWedHrs, journalline.StatusDay3); txtThuHrs.Background = SetBackGroundColor(txtThuHrs, journalline.StatusDay4); txtFriHrs.Background = SetBackGroundColor(txtFriHrs, journalline.StatusDay5); txtSatHrs.Background = SetBackGroundColor(txtSatHrs, journalline.StatusDay6); txtSunHrs.Background = SetBackGroundColor(txtSunHrs, journalline.StatusDay7); doCalculate = true; CalulateMileage(); CalculateTotal(); }
private async Task IncludeTimeJournals() { if (!InclTimeJournals || timeTransFound) { return; } ProjectClient proj = null; EmployeeClient emp = null; if (master != null) { emp = master as EmployeeClient; if (emp == null) { proj = master as ProjectClient; } if (proj == null) { var WIPreport = master as UnicontaClient.Pages.ProjectTransLocalClient; if (WIPreport != null) { proj = WIPreport.ProjectRef; } } } if (timetransLst == null && (master == null || emp != null || proj != null)) { timetransLst = new List <ProjectTransClient>(); timeTransFound = true; busyIndicator.IsBusy = true; var pairTM = new List <PropValuePair>(); if (emp != null) { pairTM.Add(PropValuePair.GenereteWhereElements(nameof(TMJournalLineClient.Employee), typeof(string), emp._Number)); pairTM.Add(PropValuePair.GenereteWhereElements(nameof(TMJournalLineClient.Date), emp._TMApproveDate, CompareOperator.GreaterThanOrEqual)); } else if (proj != null) { if (projLst == null) { var strb = StringBuilderReuse.Create(); strb.Append(proj._Number); foreach (var x in Projects) { if (x._MasterProject == proj._Number) { strb.Append(';').Append(x._Number); } } projLst = strb.ToString(); strb.Release(); } var projselected = includeSubProject ? projLst : proj._Number; pairTM.Add(PropValuePair.GenereteWhereElements(nameof(TMJournalLineClient.Project), typeof(string), projselected)); var minApproveDate = Employees.Where(x => x._TMApproveDate != DateTime.MinValue && x._Terminated == DateTime.MinValue).Min(x => x._TMApproveDate as DateTime?) ?? DateTime.MinValue; if (minApproveDate != DateTime.MinValue) { pairTM.Add(PropValuePair.GenereteWhereElements(nameof(TMJournalLineClient.Date), minApproveDate, CompareOperator.GreaterThanOrEqual)); } } else { var minApproveDate = Employees.Where(x => x._TMApproveDate != DateTime.MinValue && x._Terminated == DateTime.MinValue).Min(x => x._TMApproveDate as DateTime?) ?? DateTime.MinValue; if (minApproveDate != DateTime.MinValue) { pairTM.Add(PropValuePair.GenereteWhereElements(nameof(TMJournalLineClient.Date), minApproveDate, CompareOperator.GreaterThanOrEqual)); } } var tmJourLines = await api.Query <TMJournalLineClient>(pairTM); var tmLines = tmJourLines.Where(s => (s.Project != null && s.PayrollCategory != null && s.Date > Employees.First(z => z._Number == s.Employee)._TMApproveDate)).ToArray(); var search = new TMJournalLineClient(); var sort = new TMJournalEmpDateSort(); int pos = 0; Array.Sort(tmLines, sort); string lastEmployee = null; string lastPayroll = null; string lastProject = null; EmpPayrollCategory payrollCat = null; Uniconta.DataModel.Project project = null; var grpEmpDate = tmLines.GroupBy(x => new { x.Employee, x.Date }).Select(g => new { g.Key.Employee, g.Key.Date, EmployeeTable = Employees.Get(g.Key.Employee) }); foreach (var rec in grpEmpDate) { if (lastEmployee != rec.Employee) { lastEmployee = rec.Employee; await priceLookup.EmployeeChanged(rec.EmployeeTable); } search._Employee = rec.Employee; search._Date = rec.Date; pos = Array.BinarySearch(tmLines, search, sort); if (pos < 0) { pos = ~pos; } while (pos < tmLines.Length) { var s = tmLines[pos++]; if (s._Employee != rec.Employee || s._Date != rec.Date) { break; } if (s.Total != 0) { if (lastPayroll != s._PayrollCategory) { payrollCat = (Uniconta.DataModel.EmpPayrollCategory)Payrolls?.Get(s._PayrollCategory); lastPayroll = s._PayrollCategory; } var line = new ProjectTransClient(); line.IsTimeJournal = true; line._Project = s._Project; line._Employee = s._Employee; line._PayrollCategory = s._PayrollCategory; line._PrCategory = payrollCat?._PrCategory; line._Task = s._Task; line._Invoiceable = s._Invoiceable; line._Date = s._Date; if (s._RegistrationType == RegistrationType.Hours) { line._Text = s._Text; line._Unit = (byte)ItemUnit.Hours; if (payrollCat != null && (payrollCat._InternalType == Uniconta.DataModel.InternalType.OverTime || payrollCat._InternalType == Uniconta.DataModel.InternalType.FlexTime)) { line._Qty = payrollCat._Factor == 0 ? s.Total : s.Total * payrollCat._Factor; } else { line._Qty = s.Total; } } else { line._Text = TMJournalLineClient.GetMileageFormattedText(s._Text, s._AddressFrom, s._AddressTo, s._VechicleRegNo); line._Unit = (byte)ItemUnit.km; line._Qty = s.Total; } s.Day1 = s.Total; s.Day2 = s.Day3 = s.Day4 = s.Day5 = s.Day6 = s.Day7 = 0; await priceLookup.GetEmployeePrice(s); line._CostPrice = s.GetCostPricesDayN(1); line._SalesPrice = s.GetSalesPricesDayN(1); if (api.CompanyEntity._DimFromProject) { if (lastProject != s._Project) { project = (Uniconta.DataModel.Project)Projects.Get(s._Project); lastProject = s._Project; } line._Dim1 = project._Dim1; line._Dim2 = project._Dim2; line._Dim3 = project._Dim3; line._Dim4 = project._Dim4; line._Dim5 = project._Dim5; } else { line._Dim1 = rec.EmployeeTable._Dim1; line._Dim2 = rec.EmployeeTable._Dim2; line._Dim3 = rec.EmployeeTable._Dim3; line._Dim4 = rec.EmployeeTable._Dim4; line._Dim5 = rec.EmployeeTable._Dim5; } timetransLst.Add(line); } } } busyIndicator.IsBusy = false; } if (timetransLst != null) { var transLst = ((IEnumerable <ProjectTransClient>)dgProjectTransaction.ItemsSource).ToList(); transLst.AddRange(timetransLst); dgProjectTransaction.SetSource(transLst.ToArray()); } }
async void aggregate(bool aggregateItem, bool aggregateEmployee, bool aggregateCategory) { var result = await dgProjectTransClientInvoiceGrid.SaveData(); if (result != ErrorCodes.Succes) { return; } if (mainList == null) { mainList = (IEnumerable <ProjectTransInvoiceClient>)dgProjectTransClientInvoiceGrid.ItemsSource; } if (mainList == null || mainList.Count() == 0) { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("NoDataCollected"), Uniconta.ClientTools.Localization.lookup("Information"), MessageBoxButton.OK); return; } IEnumerable <ProjectTransInvoiceClient> lst; if (!aggregateCategory && !aggregateEmployee && !aggregateItem) { lst = mainList; } else { var categoryCache = this.CategoryCache; var dict = new Dictionary <string, ProjectTransInvoiceClient>(); List <ProjectTransInvoiceClient> NoAggregate = null; var sb = StringBuilderReuse.Create(); foreach (var rec in mainList) { if (!rec._canInvoice) { continue; } var cat = (PrCategory)categoryCache.Get(rec._PrCategory); if ((cat != null && !cat._CanAggregate) || ((aggregateItem || aggregateEmployee) && rec._Employee == null && rec._Item == null)) { if (NoAggregate == null) { NoAggregate = new List <ProjectTransInvoiceClient>(); } NoAggregate.Add(rec); continue; } sb.Clear(); if (aggregateCategory) { sb.Append(rec._PrCategory); } if (aggregateEmployee) { sb.Append('\n').Append(rec._Employee ?? "?"); } if (aggregateItem) { sb.Append('\n').Append(rec._Item ?? "?"); } var key = sb.ToString(); ProjectTransInvoiceClient val; if (dict.TryGetValue(key, out val)) { val._Qty += rec._Qty; val._SalesAmountAgr += rec._SalesAmountAgr; if (NumberConvert.ToLong(val._SalesAmountAgr * 100d) == 0) { val._SalesPrice = 0; val._Qty = 0; } val._CostAmountAgr += rec._CostAmountAgr; if (NumberConvert.ToLong(val._CostAmountAgr * 100d) == 0) { val._CostPrice = 0; } if (!aggregateCategory && val._PrCategory != rec._PrCategory) { val._PrCategory = null; if (val._Unit == 0) { val._Unit = (byte)cat._Unit; } } if (!aggregateEmployee && val._Employee != rec._Employee) { val._Employee = null; } if (!aggregateItem && val._Item != rec._Item) { if (val._Unit == 0) { var itm = (InvItem)ItemCache.Get(val._Item ?? rec._Item); if (itm != null) { val._Unit = (byte)itm._Unit; } } val._Item = null; } if (val._Dim1 != rec._Dim1) { val._Dim1 = null; } if (val._Dim2 != rec._Dim2) { val._Dim2 = null; } if (val._Dim3 != rec._Dim3) { val._Dim3 = null; } if (val._Dim4 != rec._Dim4) { val._Dim4 = null; } if (val._Dim5 != rec._Dim5) { val._Dim5 = null; } } else { val = new ProjectTransInvoiceClient(); StreamingManager.Copy(rec, val); val._SalesAmountAgr = rec._SalesAmountAgr; val._CostAmountAgr = rec._CostAmountAgr; dict.Add(key, val); } } sb.Release(); sb = null; lst = dict.Values; foreach (var rec in lst) { if (rec._Qty != 0) { rec._SalesPrice = Math.Round(Math.Abs(rec._SalesAmountAgr) / rec._Qty, 2); rec._CostPrice = Math.Round(Math.Abs(rec._CostAmountAgr) / rec._Qty, 2); rec._DiscountPct = 0; } } if (NoAggregate != null) { NoAggregate.AddRange(lst); lst = NoAggregate; } var sortedLst = lst.ToList(); sortedLst.Sort(new sortTrans(categoryCache)); lst = sortedLst; } dgProjectTransClientInvoiceGrid.ItemsSource = lst; }
List <IntrastatClient> UpdateValues(IntrastatClient[] listIntraStat, ImportOrExportIntrastat importOrExport, double factor) { if (listIntraStat == null || listIntraStat.Length == 0) { return(null); } var intraList = new List <IntrastatClient>(listIntraStat.Length >> 4); // div 8 var companyCountry = api.CompanyEntity._CountryId; var companyRegNo = Regex.Replace(api.CompanyEntity._Id ?? string.Empty, "[^0-9]", ""); foreach (var intraStat in listIntraStat) { intraStat.ImportOrExport = importOrExport; if (intraStat._NetAmount() == 0 || intraStat._Subtotal || intraStat._PartOfBOM || intraStat._DCAccount == null || intraStat._Item == null) { continue; } var item = intraStat.InvItem; if (item == null) { continue; } if (item?._ItemType == (byte)ItemType.Service) { continue; } if (importOrExport == ImportOrExportIntrastat.Import) { intraStat.Country = intraStat.Creditor.Country; } else // export { var deb = intraStat.Debtor; intraStat.Country = deb._DeliveryCountry == 0 ? deb._Country : deb._DeliveryCountry; } if (intraStat.Country == companyCountry) { continue; } if (!Country2Language.IsEU(intraStat.Country) && intraStat.Country != CountryCode.Unknown) { continue; } intraStat.DebtorRegNo = intraStat?.Debtor?._LegalIdent; var fdebtorCVR = intraStat.DebtorRegNo; if (fdebtorCVR != null) { long value; if (!long.TryParse(fdebtorCVR, out value)) { fdebtorCVR = Regex.Replace(fdebtorCVR, @"[-/ ]", ""); } var preCtry = StringBuilderReuse.Create().Append(fdebtorCVR).Truncate(2).ToStringAndRelease(); var pCountry = intraStat.PartnerCountry; if (preCtry != pCountry) { fdebtorCVR = StringBuilderReuse.Create().Append(pCountry).Append(fdebtorCVR).ToStringAndRelease(); } intraStat.fDebtorRegNo = fdebtorCVR; } else { intraStat.DebtorRegNo = IntraHelper.UNKNOWN_CVRNO; intraStat.fDebtorRegNo = IntraHelper.UNKNOWN_CVRNO; } intraStat.CompanyRegNo = companyRegNo; var salesAmount = intraStat._NetAmount() * factor; intraStat.TransType = salesAmount < 0 ? "21" : "11"; intraStat.InvAmount = Math.Abs(salesAmount); intraStat.InvoiceQuantity = Math.Abs(intraStat._Qty); intraStat.CountryOfOrigin = item._CountryOfOrigin == CountryCode.Unknown ? item.InventoryGroup._CountryOfOrigin : item._CountryOfOrigin; intraStat.IntraUnitPerPCS = Math.Abs(item._IntraUnit); intraStat.WeightPerPCS = Math.Abs(item.Weight); intraStat.NetWeight = intraStat.WeightPerPCS * intraStat.InvoiceQuantity; intraStat.IntraUnit = item._IntraUnit * (int)Math.Round(intraStat.InvoiceQuantity, 0); switch (item._Unit) { case ItemUnit.Gram: intraStat.WeightPerPCS /= 1000; intraStat.NetWeight /= 1000; break; case ItemUnit.Milligram: intraStat.WeightPerPCS /= 1000000; intraStat.NetWeight /= 1000000; break; } intraStat.Date = intraStat.Date == DateTime.MinValue ? DateTime.Now : intraStat.Date; var itmCod = item._TariffNumber ?? item.InventoryGroup?._TariffNumber; if (itmCod != null) { itmCod = Regex.Replace(itmCod, "[^0-9]", ""); itmCod = itmCod != null && itmCod.Length > 8 ? itmCod.Substring(0, 8) : itmCod; intraStat.ItemCode = itmCod; } intraList.Add(intraStat); } return(intraList); }
public void Validate(IEnumerable <VatOSSTable> listVatOSS, int reportType, bool compressed, bool onlyValidate) { var countErr = 0; var errText = StringBuilderReuse.Create(); foreach (var rec in listVatOSS) { var debtor = rec.DebtorRef; rec.SystemInfo = VALIDATE_OK; errText.Clear(); if (compressed && rec.Compressed == false) { errText.Append(Localization.lookup("CompressPosting")); } if (reportType == 0 && rec.MOSSType != MOSSTYPE_001 && rec.MOSSType != MOSSTYPE_002 && rec.MOSSType != MOSSTYPE_003 && rec.MOSSType != MOSSTYPE_004 && rec.MOSSType != MOSSTYPE_005 && rec.MOSSType != MOSSTYPE_006 && rec.MOSSType != MOSSTYPE_007 && rec.MOSSType != MOSSTYPE_008 && rec.MOSSType != MOSSTYPE_009) { errText.Append(string.Format(Localization.lookup("ActionNotAllowedObj"), Localization.lookup("MOSSType"), Localization.lookup("UnionSchemeOSS"))); } else if (reportType == 1 && rec.MOSSType != MOSSTYPE_020 && rec.MOSSType != MOSSTYPE_021) { errText.Append(string.Format(Localization.lookup("ActionNotAllowedObj"), Localization.lookup("MOSSType"), Localization.lookup("NonUnionSchemeOSS"))); } else if (reportType == 2 && rec.MOSSType != MOSSTYPE_030 && rec.MOSSType != MOSSTYPE_031) { errText.Append(string.Format(Localization.lookup("ActionNotAllowedObj"), Localization.lookup("MOSSType"), Localization.lookup("ImportSchemeOSS"))); } if (errText.Length == 0 && rec.MOSSType == null) { errText.Append(fieldCannotBeEmpty("VATMOSSType")); } if (rec.MOSSType == MOSSTYPE_007) { if (errText.Length == 0) { if (rec.ShipmentCountry == null && rec.BusinessCountry == null) { errText.Append(string.Format("{0} {1}/{2}", Localization.lookup("FieldCannotBeEmpty"), Localization.lookup("BusinessCountry"), Localization.lookup("ShipmentCountry"))); } if (errText.Length == 0 && rec.Id == null) { errText.Append(fieldCannotBeEmpty("Id")); } } } else if (rec.MOSSType != MOSSTYPE_008 && rec.MOSSType == MOSSTYPE_021 && rec.MOSSType == MOSSTYPE_031) { if (errText.Length == 0 && debtor?.Country == null) { errText.Append(Localization.lookup("CountryNotSet")); } if (errText.Length == 0 && rec.Country == null) { errText.Append(fieldCannotBeEmpty("VatCountry")); } } if (errText.Length == 0 && rec.BusinessCountry != null && rec.ShipmentCountry != null) { errText.Append(string.Format("{0}/{1} {2}", Localization.lookup("BusinessCountry"), Localization.lookup("ShipmentCountry"), Localization.lookup("CombinationNotAllowed").ToLower())); } if (errText.Length == 0 && (rec.MOSSType == MOSSTYPE_003 || rec.MOSSType == MOSSTYPE_004)) { if (rec.BusinessCountry == null) { errText.Append(fieldCannotBeEmpty("BusinessCountry")); } if (errText.Length == 0 && rec.Id == null) { errText.Append(fieldCannotBeEmpty("Id")); } } if (errText.Length == 0 && rec.MOSSType == MOSSTYPE_005) { if (rec.ShipmentCountry == null) { errText.Append(fieldCannotBeEmpty("ShipmentCountry")); } if (errText.Length == 0 && rec.Id == null) { errText.Append(fieldCannotBeEmpty("Id")); } } if (errText.Length > 0) { rec.SystemInfo = errText.ToString(); countErr++; } } errText.Release(); }