public PaymentsJournalViewModel(
            PaymentsJournalFilterViewModel filterViewModel,
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            INavigationManager navigationManager,
            IOrderRepository orderRepository,
            IOrganizationParametersProvider organizationParametersProvider,
            IProfitCategoryProvider profitCategoryProvider) : base(filterViewModel, unitOfWorkFactory, commonServices)
        {
            TabName = "Журнал платежей из банк-клиента";
            this.unitOfWorkFactory = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
            this.commonServices    = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
            this.orderRepository   = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
            this.organizationParametersProvider = organizationParametersProvider ?? throw new ArgumentNullException(nameof(organizationParametersProvider));
            this.profitCategoryProvider         = profitCategoryProvider ?? throw new ArgumentNullException(nameof(profitCategoryProvider));
            this.navigationManager = navigationManager;

            RegisterPayments();

            FinishJournalConfiguration();

            UpdateOnChanges(
                typeof(Payment),
                typeof(PaymentItem),
                typeof(VodOrder)
                );
        }
        public CreateManualPaymentFromBankClientViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory uowFactory,
            ICommonServices commonServices,
            INavigationManager navigationManager,
            IPaymentsRepository paymentsRepository,
            IProfitCategoryRepository profitCategoryRepository,
            IProfitCategoryProvider profitCategoryProvider,
            IOrganizationRepository organizationRepository,
            IOrganizationParametersProvider organizationParametersProvider,
            ILifetimeScope scope) : base(uowBuilder, uowFactory, commonServices, navigationManager)
        {
            if (profitCategoryRepository == null)
            {
                throw new ArgumentNullException(nameof(profitCategoryRepository));
            }
            if (profitCategoryProvider == null)
            {
                throw new ArgumentNullException(nameof(profitCategoryProvider));
            }

            _paymentsRepository             = paymentsRepository ?? throw new ArgumentNullException(nameof(paymentsRepository));
            _organizationRepository         = organizationRepository ?? throw new ArgumentNullException(nameof(organizationRepository));
            _organizationParametersProvider =
                organizationParametersProvider ?? throw new ArgumentNullException(nameof(organizationParametersProvider));
            Scope = scope ?? throw new ArgumentNullException(nameof(scope));

            Configure(profitCategoryRepository, profitCategoryProvider);
            Entity.PropertyChanged += OnEntityPropertyChanged;
        }
예제 #3
0
 public Stage1OrganizationProvider(IOrganizationParametersProvider organizationParametersProvider,
                                   IOrderParametersProvider orderParametersProvider)
 {
     this.organizationParametersProvider = organizationParametersProvider ??
                                           throw new ArgumentNullException(nameof(organizationParametersProvider));
     this.orderParametersProvider = orderParametersProvider ?? throw new ArgumentNullException(nameof(orderParametersProvider));
 }
예제 #4
0
 public SmsPaymentValidator(IOrganizationParametersProvider organizationParametersProvider)
 {
     _allowedOrganizationIds = new List <int>
     {
         organizationParametersProvider.VodovozSouthOrganizationId,
         organizationParametersProvider.VodovozNorthOrganizationId
     };
 }
예제 #5
0
 public SalesReceiptsInstanceProvider(
     ISalesReceiptsServiceSettings salesReceiptsServiceSettings,
     IOrderRepository orderRepository,
     IOrderParametersProvider orderParametersProvider,
     IOrganizationParametersProvider organizationParametersProvider
     )
 {
     this.salesReceiptsServiceSettings = salesReceiptsServiceSettings ?? throw new ArgumentNullException(nameof(salesReceiptsServiceSettings));
     this.orderRepository                = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
     this.orderParametersProvider        = orderParametersProvider ?? throw new ArgumentNullException(nameof(orderParametersProvider));
     this.organizationParametersProvider = organizationParametersProvider ?? throw new ArgumentNullException(nameof(organizationParametersProvider));
 }
 public Stage2OrganizationProvider(
     IOrganizationParametersProvider organizationParametersProvider,
     IOrderParametersProvider orderParametersProvider,
     IGeographicGroupParametersProvider geographicGroupParametersProvider)
 {
     _organizationParametersProvider = organizationParametersProvider
                                       ?? throw new ArgumentNullException(nameof(organizationParametersProvider));
     _orderParametersProvider = orderParametersProvider
                                ?? throw new ArgumentNullException(nameof(orderParametersProvider));
     _geographicGroupParametersProvider = geographicGroupParametersProvider
                                          ?? throw new ArgumentNullException(nameof(geographicGroupParametersProvider));
 }
예제 #7
0
 public FiscalizationWorker(
     IOrderRepository orderRepository,
     ISalesReceiptSender salesReceiptSender,
     IOrderParametersProvider orderParametersProvider,
     IOrganizationParametersProvider organizationParametersProvider,
     IList <CashBox> cashBoxes)
 {
     this.orderRepository                = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
     this.salesReceiptSender             = salesReceiptSender ?? throw new ArgumentNullException(nameof(salesReceiptSender));
     this.orderParametersProvider        = orderParametersProvider ?? throw new ArgumentNullException(nameof(orderParametersProvider));
     this.organizationParametersProvider = organizationParametersProvider ?? throw new ArgumentNullException(nameof(organizationParametersProvider));
     this.cashBoxes = cashBoxes ?? throw new ArgumentNullException(nameof(cashBoxes));
 }
예제 #8
0
 public Stage2OrganizationProvider(
     IOrganizationParametersProvider organizationParametersProvider,
     IOrderParametersProvider orderParametersProvider,
     IGeographicGroupParametersProvider geographicGroupParametersProvider)
 {
     _organizationParametersProvider =
         organizationParametersProvider ?? throw new ArgumentNullException(nameof(organizationParametersProvider));
     _orderParametersProvider = orderParametersProvider ?? throw new ArgumentNullException(nameof(orderParametersProvider));
     if (geographicGroupParametersProvider == null)
     {
         throw new ArgumentNullException(nameof(geographicGroupParametersProvider));
     }
     _northOrganizationGeoGroupsIds = new[]
     { geographicGroupParametersProvider.NorthGeographicGroupId, geographicGroupParametersProvider.EastGeographicGroupId };
 }
        public PaymentLoaderViewModel(
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            INavigationManager navigationManager,
            IOrganizationParametersProvider organizationParametersProvider,
            IProfitCategoryProvider profitCategoryProvider,
            IPaymentsRepository paymentsRepository,
            ICounterpartyRepository counterpartyRepository,
            IOrderRepository orderRepository)
            : base(unitOfWorkFactory, commonServices?.InteractiveService, navigationManager)
        {
            if (commonServices == null)
            {
                throw new ArgumentNullException(nameof(commonServices));
            }

            _profitCategoryProvider = profitCategoryProvider ?? throw new ArgumentNullException(nameof(profitCategoryProvider));
            _paymentsRepository     = paymentsRepository ?? throw new ArgumentNullException(nameof(paymentsRepository));
            _counterpartyRepository = counterpartyRepository ?? throw new ArgumentNullException(nameof(counterpartyRepository));
            _orderRepository        = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));

            if (organizationParametersProvider == null)
            {
                throw new ArgumentNullException(nameof(organizationParametersProvider));
            }

            InteractiveService = commonServices.InteractiveService;
            _vodovozId         = organizationParametersProvider.VodovozOrganizationId;
            _vodovozSouthId    = organizationParametersProvider.VodovozSouthOrganizationId;

            UoW = unitOfWorkFactory.CreateWithoutRoot();

            TabName = "Выгрузка выписки из банк-клиента";

            GetOrganisations();
            CreateCommands();
            GetProfitCategories();
        }
예제 #10
0
        public IEnumerable <ReceiptForOrderNode> GetOrdersForCashReceiptServiceToSend(
            IUnitOfWork uow,
            IOrderParametersProvider orderParametersProvider,
            IOrganizationParametersProvider organizationParametersProvider,
            ISalesReceiptsParametersProvider salesReceiptsParametersProvider,
            DateTime?startDate = null)
        {
            #region Aliases Restrictions Projections

            var paymentByCardFromNotToSendSalesReceipts = orderParametersProvider.PaymentsByCardFromNotToSendSalesReceipts;
            var vodovozSouthOrganizationId = organizationParametersProvider.VodovozSouthOrganizationId;

            ExtendedReceiptForOrderNode extendedReceiptForOrderNodeAlias = null;

            OrderItem            orderItemAlias            = null;
            VodovozOrder         orderAlias                = null;
            CashReceipt          cashReceiptAlias          = null;
            Nomenclature         nomenclatureAlias         = null;
            ProductGroup         productGroupAlias         = null;
            Counterparty         counterpartyAlias         = null;
            CounterpartyContract counterpartyContractAlias = null;
            Organization         organizationAlias         = null;

            var orderSumProjection = Projections.Sum(
                Projections.SqlFunction(
                    new SQLFunctionTemplate(NHibernateUtil.Decimal, "CAST(IFNULL(?1 * ?2 - ?3, 0) AS DECIMAL(14,2))"),
                    NHibernateUtil.Decimal,
                    Projections.Property(() => orderItemAlias.Count),
                    Projections.Property(() => orderItemAlias.Price),
                    Projections.Property(() => orderItemAlias.DiscountMoney)
                    )
                );

            var orderSumRestriction = Restrictions.Gt(orderSumProjection, 0);

            var alwaysSendOrdersRestriction = Restrictions.Disjunction()
                                              .Add(() => productGroupAlias.OnlineStore != null)
                                              .Add(() => counterpartyAlias.AlwaysSendReceitps)
                                              .Add(() => orderAlias.SelfDelivery)
                                              .Add(Restrictions.In(Projections.Property(() => orderAlias.PaymentType),
                                                                   new[] { PaymentType.ByCard, PaymentType.Terminal }.ToArray()));

            var orderDeliveredStatuses = Restrictions.In(Projections.Property(() => orderAlias.OrderStatus),
                                                         new[] { OrderStatus.Shipped, OrderStatus.UnloadingOnStock }.ToArray());

            var orderPaymentTypesRestriction = Restrictions.In(Projections.Property(() => orderAlias.PaymentType),
                                                               new[] { PaymentType.cash, PaymentType.Terminal, PaymentType.ByCard }.ToArray());

            var paidByCardRestriction = Restrictions.Disjunction()
                                        .Add(() => orderAlias.PaymentType != PaymentType.ByCard)
                                        .Add(() => organizationAlias.Id != vodovozSouthOrganizationId)
                                        .Add(Restrictions.On(() => orderAlias.PaymentByCardFrom.Id)
                                             .Not.IsIn(paymentByCardFromNotToSendSalesReceipts));

            #endregion

            #region AlwaysSendOrders

            var alwaysSendOrdersQuery = uow.Session.QueryOver <VodovozOrder>(() => orderAlias)
                                        .JoinEntityAlias(() => cashReceiptAlias, () => cashReceiptAlias.Order.Id == orderAlias.Id, JoinType.LeftOuterJoin)
                                        .Left.JoinAlias(() => orderAlias.OrderItems, () => orderItemAlias)
                                        .Left.JoinAlias(() => orderItemAlias.Nomenclature, () => nomenclatureAlias)
                                        .Left.JoinAlias(() => nomenclatureAlias.ProductGroup, () => productGroupAlias)
                                        .Left.JoinAlias(() => orderAlias.Client, () => counterpartyAlias)
                                        .Left.JoinAlias(() => orderAlias.Contract, () => counterpartyContractAlias)
                                        .Left.JoinAlias(() => counterpartyContractAlias.Organization, () => organizationAlias)
                                        .Where(alwaysSendOrdersRestriction)
                                        .And(paidByCardRestriction)
                                        .And(Restrictions.Disjunction()
                                             .Add(orderDeliveredStatuses)
                                             .Add(Restrictions.Conjunction()
                                                  .Add(() => orderAlias.SelfDelivery)
                                                  .Add(() => orderAlias.IsSelfDeliveryPaid)))
                                        .And(orderSumRestriction)
                                        .And(orderPaymentTypesRestriction)
                                        .And(Restrictions.Disjunction()
                                             .Add(Restrictions.IsNull(Projections.Property(() => cashReceiptAlias.Id)))
                                             .Add(() => !cashReceiptAlias.Sent));

            if (startDate.HasValue)
            {
                alwaysSendOrdersQuery.Where(() => orderAlias.DeliveryDate >= startDate.Value);
            }

            var alwaysSendOrders = alwaysSendOrdersQuery
                                   .SelectList(list => list
                                               .SelectGroup(() => orderAlias.Id).WithAlias(() => extendedReceiptForOrderNodeAlias.OrderId)
                                               .Select(() => orderAlias.PaymentType).WithAlias(() => extendedReceiptForOrderNodeAlias.PaymentType)
                                               .Select(orderSumProjection).WithAlias(() => extendedReceiptForOrderNodeAlias.OrderSum)
                                               .Select(() => cashReceiptAlias.Id).WithAlias(() => extendedReceiptForOrderNodeAlias.ReceiptId)
                                               .Select(() => cashReceiptAlias.Sent).WithAlias(() => extendedReceiptForOrderNodeAlias.WasSent))
                                   .TransformUsing(Transformers.AliasToBean <ExtendedReceiptForOrderNode>())
                                   .Future <ExtendedReceiptForOrderNode>();

            //Здесь фильтрация идёт не на уровне запроса, т.к. не NHibernate упорно не хочет клась сложное условие в HAVING
            var result = alwaysSendOrders
                         .Where(x =>
                                x.PaymentType != PaymentType.cash ||
                                x.PaymentType == PaymentType.cash && x.OrderSum < 20000)
                         .Select(x => new ReceiptForOrderNode
            {
                OrderId   = x.OrderId,
                ReceiptId = x.ReceiptId,
                WasSent   = x.WasSent
            });

            #endregion

            #region UniqueOrderSumOrders

            if (salesReceiptsParametersProvider.SendUniqueOrderSumOrders)
            {
                var uniqueOrderSumSendOrdersQuery = uow.Session.QueryOver <VodovozOrder>(() => orderAlias)
                                                    .JoinEntityAlias(() => cashReceiptAlias, () => cashReceiptAlias.Order.Id == orderAlias.Id, JoinType.LeftOuterJoin)
                                                    .Left.JoinAlias(() => orderAlias.OrderItems, () => orderItemAlias)
                                                    .Left.JoinAlias(() => orderItemAlias.Nomenclature, () => nomenclatureAlias)
                                                    .Left.JoinAlias(() => nomenclatureAlias.ProductGroup, () => productGroupAlias)
                                                    .Left.JoinAlias(() => orderAlias.Client, () => counterpartyAlias)
                                                    .Left.JoinAlias(() => orderAlias.Contract, () => counterpartyContractAlias)
                                                    .Left.JoinAlias(() => counterpartyContractAlias.Organization, () => organizationAlias)
                                                    .Where(Restrictions.Not(alwaysSendOrdersRestriction))
                                                    .And(paidByCardRestriction)
                                                    .And(orderDeliveredStatuses)
                                                    .And(orderSumRestriction)
                                                    .And(orderPaymentTypesRestriction);

                if (startDate.HasValue)
                {
                    uniqueOrderSumSendOrdersQuery.Where(() => orderAlias.DeliveryDate >= startDate.Value);
                }

                var notUniqueOrderSumSendOrdersTemp = uniqueOrderSumSendOrdersQuery
                                                      .SelectList(list => list
                                                                  .SelectGroup(() => orderAlias.Id).WithAlias(() => extendedReceiptForOrderNodeAlias.OrderId)
                                                                  .Select(() => orderAlias.PaymentType).WithAlias(() => extendedReceiptForOrderNodeAlias.PaymentType)
                                                                  .Select(orderSumProjection).WithAlias(() => extendedReceiptForOrderNodeAlias.OrderSum)
                                                                  .Select(CustomProjections.Date(() => orderAlias.DeliveryDate))
                                                                  .WithAlias(() => extendedReceiptForOrderNodeAlias.DeliveryDate)
                                                                  .Select(() => cashReceiptAlias.Id).WithAlias(() => extendedReceiptForOrderNodeAlias.ReceiptId)
                                                                  .Select(() => cashReceiptAlias.Sent).WithAlias(() => extendedReceiptForOrderNodeAlias.WasSent))
                                                      .TransformUsing(Transformers.AliasToBean <ExtendedReceiptForOrderNode>())
                                                      .Future <ExtendedReceiptForOrderNode>();

                var notUniqueOrderSumSendOrders = notUniqueOrderSumSendOrdersTemp.Where(x =>
                                                                                        x.PaymentType != PaymentType.cash ||
                                                                                        x.PaymentType == PaymentType.cash && x.OrderSum < 20000).ToList();

                var alreadySentOrders =
                    new List <ExtendedReceiptForOrderNode>(notUniqueOrderSumSendOrders.Where(x => x.WasSent.HasValue && x.WasSent.Value));
                var uniqueOrderSumSendNodes = new List <ExtendedReceiptForOrderNode>();

                foreach (var node in notUniqueOrderSumSendOrders.Where(x => !x.WasSent.HasValue || !x.WasSent.Value))
                {
                    if (alreadySentOrders.All(x => x.OrderSum != node.OrderSum || x.DeliveryDate != node.DeliveryDate) &&
                        uniqueOrderSumSendNodes.All(x => x.OrderSum != node.OrderSum || x.DeliveryDate != node.DeliveryDate))
                    {
                        uniqueOrderSumSendNodes.Add(node);
                    }
                }
                var uniqueOrderSumSendOrderNodes = uniqueOrderSumSendNodes.Select(x => new ReceiptForOrderNode
                {
                    OrderId = x.OrderId, ReceiptId = x.ReceiptId, WasSent = x.WasSent
                });

                result = result.Union(uniqueOrderSumSendOrderNodes);
            }

            #endregion

            return(result);
        }
 public CashDistributionCommonOrganisationProvider(IOrganizationParametersProvider organisationParametersProvider)
 {
     this.organisationParametersProvider =
         organisationParametersProvider ?? throw new ArgumentNullException(nameof(organisationParametersProvider));
 }
예제 #12
0
 public ExpenseParametersProvider(IParametersProvider parametersProvider, IOrganizationParametersProvider organizationParametersProvider)
 {
     _parametersProvider             = parametersProvider ?? throw new ArgumentNullException(nameof(parametersProvider));
     _organizationParametersProvider = organizationParametersProvider;
 }