public ExportData(IUnitOfWork uow, Export1cMode mode, DateTime dateStart, DateTime dateEnd) { this.Objects = new List <ObjectNode>(); this.UoW = uow; this.ExportMode = mode; this.Version = "2.0"; this.ExportDate = DateTime.Now; this.StartPeriodDate = dateStart; this.EndPeriodDate = dateEnd; this.SourceName = "Торговля+Склад, редакция 9.2"; this.DestinationName = "БухгалтерияПредприятия"; this.ConversionRulesId = "70e9dbac-59df-44bb-82c6-7d4f30d37c74"; this.Comment = ""; this.AccountCatalog = new AccountCatalog(this); this.BankCatalog = new BankCatalog(this); this.ContractCatalog = new ContractCatalog(this); this.CounterpartyCatalog = new CounterpartyCatalog(this); this.CurrencyCatalog = new CurrencyCatalog(this); this.MeasurementUnitCatalog = new MeasurementUnitsCatalog(this); this.NomenclatureCatalog = new NomenclatureCatalog(this); this.NomenclatureGroupCatalog = new NomenclatureGroupCatalog(this); this.OrganizationCatalog = new OrganizationCatalog(this); this.WarehouseCatalog = new WarehouseCatalog(this); this.ExchangeRules = new RulesNode(); }
public ExportOperation(IOrderParametersProvider orderParametersProvider, Export1cMode mode, DateTime start, DateTime end) { this.orderParametersProvider = orderParametersProvider ?? throw new ArgumentNullException(nameof(orderParametersProvider)); uow = UnitOfWorkFactory.CreateWithoutRoot(); this.start = start; this.end = end; this.mode = mode; }
private void Export(Export1cMode mode) { var dateStart = dateperiodpicker1.StartDate; var dateEnd = dateperiodpicker1.EndDate; using (var exportOperation = new ExportOperation(new OrderParametersProvider(new ParametersProvider()), mode, dateStart, dateEnd)) { this.exportInProgress = true; UpdateExportButtonSensitivity(); LongOperationDlg.StartOperation(exportOperation.Run, "", 1, false); this.exportInProgress = false; UpdateExportButtonSensitivity(); exportData = exportOperation.Result; } this.labelTotalCounterparty.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceCounterparty) .ToString(); this.labelTotalNomenclature.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceNomenclature) .ToString(); this.labelTotalSales.Text = exportData.Objects .OfType <SalesDocumentNode>() .Count() .ToString(); this.labelTotalSum.Text = exportData.OrdersTotalSum.ToString("C"); this.labelExportedSum.Markup = String.Format("<span foreground=\"{1}\">{0:C}</span>", exportData.ExportedTotalSum, exportData.ExportedTotalSum == exportData.OrdersTotalSum ? "green" : "red"); this.labelTotalInvoices.Text = exportData.Objects .OfType <InvoiceDocumentNode>() .Count() .ToString(); GtkScrolledWindowErrors.Visible = exportData.Errors.Count > 0; if (exportData.Errors.Count > 0) { TextTagTable textTags = new TextTagTable(); var tag = new TextTag("Red"); tag.Foreground = "red"; textTags.Add(tag); TextBuffer tempBuffer = new TextBuffer(textTags); TextIter iter = tempBuffer.EndIter; tempBuffer.InsertWithTags(ref iter, String.Join("\n", exportData.Errors), tag); textviewErrors.Buffer = tempBuffer; } buttonSave.Sensitive = exportData != null && exportData.Errors.Count == 0; }
private void Export(Export1cMode mode) { var dateStart = dateperiodpicker1.StartDate; var dateEnd = dateperiodpicker1.EndDate; int?organizationId = null; if (mode == Export1cMode.BuhgalteriaOOONew) { organizationId = (comboOrganization.SelectedItem as Organization)?.Id; } else if (mode == Export1cMode.BuhgalteriaOOO) { organizationId = new OrganizationParametersProvider(_parametersProvider).VodovozOrganizationId; } using (var exportOperation = new ExportOperation( mode, new OrderParametersProvider(_parametersProvider), dateStart, dateEnd, organizationId )) { this.exportInProgress = true; UpdateExportSensitivity(); LongOperationDlg.StartOperation(exportOperation.Run, "", 1, false); this.exportInProgress = false; UpdateExportSensitivity(); exportData = exportOperation.Result; } labelTotalCounterparty.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceCounterparty) .ToString(); labelTotalNomenclature.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceNomenclature) .ToString(); labelTotalSales.Text = (exportData.Objects .OfType <SalesDocumentNode>() .Count() + exportData.Objects.OfType <RetailDocumentNode>().Count()) .ToString(); labelTotalSum.Text = exportData.OrdersTotalSum.ToString("C", CultureInfo.GetCultureInfo("ru-RU")); labelExportedSum.Markup = $"<span foreground=\"{(exportData.ExportedTotalSum == exportData.OrdersTotalSum ? "green" : "red")}\">" + $"{exportData.ExportedTotalSum.ToString("C", CultureInfo.GetCultureInfo("ru-RU"))}</span>"; labelTotalInvoices.Text = exportData.Objects .OfType <InvoiceDocumentNode>() .Count() .ToString(); GtkScrolledWindowErrors.Visible = exportData.Errors.Count > 0; if (exportData.Errors.Count > 0) { TextTagTable textTags = new TextTagTable(); var tag = new TextTag("Red"); tag.Foreground = "red"; textTags.Add(tag); TextBuffer tempBuffer = new TextBuffer(textTags); TextIter iter = tempBuffer.EndIter; tempBuffer.InsertWithTags(ref iter, String.Join("\n", exportData.Errors), tag); textviewErrors.Buffer = tempBuffer; } buttonSave.Sensitive = exportData != null && exportData.Errors.Count == 0; }
public IList <VodovozOrder> GetOrdersToExport1c8( IUnitOfWork uow, IOrderParametersProvider orderParametersProvider, Export1cMode mode, DateTime startDate, DateTime endDate, int?organizationId = null) { VodovozOrder orderAlias = null; OrderItem orderItemAlias = null; var export1CSubquerySum = QueryOver.Of(() => orderItemAlias) .Where(() => orderItemAlias.Order.Id == orderAlias.Id) .Select(Projections.Sum( Projections.SqlFunction(new VarArgsSQLFunction("", " * ", ""), NHibernateUtil.Decimal, Projections.Conditional( Restrictions.IsNotNull(Projections.Property <OrderItem>(x => x.ActualCount)), Projections.Property <OrderItem>(x => x.ActualCount), Projections.Property <OrderItem>(x => x.Count) ), Projections.Property <OrderItem>(x => x.Price), Projections.SqlFunction(new SQLFunctionTemplate(NHibernateUtil.Decimal, "( 1 - ?1 / 100 )"), NHibernateUtil.Decimal, Projections.Property <OrderItem>(x => x.Discount) ) ) )) ; var query = uow.Session.QueryOver(() => orderAlias) .Where(() => orderAlias.OrderStatus.IsIn(VodovozOrder.StatusesToExport1c)) .Where(() => startDate <= orderAlias.DeliveryDate && orderAlias.DeliveryDate <= endDate); if (organizationId.HasValue) { CounterpartyContract counterpartyContractAlias = null; query.Left.JoinAlias(() => orderAlias.Contract, () => counterpartyContractAlias) .Where(() => counterpartyContractAlias.Organization.Id == organizationId); } switch (mode) { case Export1cMode.BuhgalteriaOOO: query.Where(o => o.PaymentType == PaymentType.cashless) .And(Subqueries.Le(0.01, export1CSubquerySum.DetachedCriteria)); break; case Export1cMode.BuhgalteriaOOONew: CashReceipt cashReceiptAlias = null; query.JoinEntityAlias(() => cashReceiptAlias, () => cashReceiptAlias.Order.Id == orderAlias.Id, JoinType.LeftOuterJoin) .Where(Restrictions.Disjunction() .Add(() => orderAlias.PaymentType == PaymentType.cashless) .Add(Restrictions.Conjunction() .Add(Restrictions.On(() => orderAlias.PaymentType) .IsIn(new[] { PaymentType.Terminal, PaymentType.cash })) .Add(Restrictions.IsNotNull(Projections.Property(() => cashReceiptAlias.Id)))) .Add(Restrictions.Conjunction() .Add(() => orderAlias.PaymentType == PaymentType.ByCard) .Add(Restrictions.Disjunction() .Add(Restrictions.On(() => orderAlias.PaymentByCardFrom.Id) .IsIn(orderParametersProvider.PaymentsByCardFromNotToSendSalesReceipts)) .Add(Restrictions.IsNotNull(Projections.Property(() => cashReceiptAlias.Id)))) ) ); break; case Export1cMode.IPForTinkoff: query.Where(o => o.PaymentType == PaymentType.ByCard) .And(o => o.OnlineOrder != null) .And(Subqueries.Le(0.01, export1CSubquerySum.DetachedCriteria)); break; default: throw new ArgumentOutOfRangeException(nameof(mode), mode, null); } return(query.List()); }