public bool CreateFile(IEnumerable <VatOSSTable> listVatOSS) { var result = listVatOSS.Where(s => s.SystemInfo == VALIDATE_OK).ToList(); if (result.Count > 0) { var sort = new VatOSSTableTypeSort(); result.Sort(sort); var sfd = UtilDisplay.LoadSaveFileDialog; sfd.Filter = UtilFunctions.GetFilteredExtensions(FileextensionsTypes.CSV); var userClickedSave = sfd.ShowDialog(); if (userClickedSave != true) { return(false); } try { using (var stream = File.Create(sfd.FileName)) { var sw = new StreamWriter(stream, Encoding.Default); var sumOfAmount = StreamToFile(result, sw); sw.Flush(); } } catch (Exception ex) { UnicontaMessageBox.Show(ex); return(false); } } return(true); }
private void Compress() { try { if (!CallPrevalidate()) { return; } var listVatOSS = vatOSSHelper.CompressVatOSS((IEnumerable <VatOSSTable>)dgVatOSSGrid.GetVisibleRows()); if (listVatOSS == null || listVatOSS.Count == 0) { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("NoLinesFound"), Uniconta.ClientTools.Localization.lookup("Warning")); } else { Date.Visible = false; InvoiceNumber.Visible = false; Item.Visible = false; ItemName.Visible = false; Account.Visible = false; DebtorName.Visible = false; Compressed.Visible = true; SystemInfo.Visible = true; var sort = new VatOSSTableTypeSort(); listVatOSS.Sort(sort); dgVatOSSGrid.ItemsSource = listVatOSS; dgVatOSSGrid.Visibility = Visibility.Visible; dgVatOSSGrid.UpdateTotalSummary(); compressed = true; CallValidate(true); ribbonControl.DisableButtons("Compress"); } } catch (Exception e) { UnicontaMessageBox.Show(e, Uniconta.ClientTools.Localization.lookup("Exception")); throw; } }
public async void GetVatOSS(DateTime fromDate, DateTime toDate) { SetDateTime(txtDateFrm, txtDateTo); busyIndicator.IsBusy = true; List <PropValuePair> propValPair = new List <PropValuePair>(); if (fromDate != DateTime.MinValue || toDate != DateTime.MinValue) { string filter; if (fromDate != DateTime.MinValue) { filter = String.Format("{0:d}..", fromDate); } else { filter = ".."; } if (toDate != DateTime.MinValue) { filter += String.Format("{0:d}", toDate); } var prop = PropValuePair.GenereteWhereElements("Date", typeof(DateTime), filter); propValPair.Add(prop); } if (glVatCache == null) { glVatCache = await api.LoadCache <Uniconta.DataModel.GLVat>(); } var vatEUList = glVatCache.Where(s => s._TypeSales == CreateVatOSSFile.VATTYPE_MOSS).Select(x => x._Vat).Distinct(); if (vatEUList != null && vatEUList.Count() > 0) { var strLst = string.Join(";", vatEUList); propValPair.Add(PropValuePair.GenereteWhereElements(nameof(DebtorInvoiceLines.Vat), typeof(string), strLst)); } var listOfDebInvLines = await api.Query <DebtorInvoiceLines>(propValPair); List <VatOSSTable> vatOSSlst = new List <VatOSSTable>(); if (listOfDebInvLines != null && listOfDebInvLines.Length != 0) { vatOSSlst = UpdateValues(listOfDebInvLines); busyIndicator.IsBusy = false; } else { var vatOSS = new VatOSSTable(); vatOSS._CompanyId = api.CompanyId; vatOSS._Date = DefaultFromDate; vatOSS.MOSSType = vatOSSReportType == 0 ? CreateVatOSSFile.MOSSTYPE_008 : vatOSSReportType == 1 ? CreateVatOSSFile.MOSSTYPE_021 : CreateVatOSSFile.MOSSTYPE_031; vatOSS._MOSSTypeName = GetMOSSTypeName(vatOSS.MOSSType); vatOSS.Compressed = true; vatOSSlst.Add(vatOSS); busyIndicator.IsBusy = false; compressed = true; } var sort = new VatOSSTableTypeSort(); vatOSSlst.Sort(sort); dgVatOSSGrid.ItemsSource = vatOSSlst; dgVatOSSGrid.Visibility = Visibility.Visible; }