コード例 #1
0
        public ReturnPageViewModel(INavigationService navigationService,
                                   IGlobalService globalService,
                                   IDialogService dialogService,
                                   IAllocationService allocationService,
                                   IAdvanceReceiptService advanceReceiptService,
                                   IReceiptCashService receiptCashService,
                                   ICostContractService costContractService,
                                   ICostExpenditureService costExpenditureService,
                                   IInventoryService inventoryService,
                                   IPurchaseBillService purchaseBillService,
                                   IReturnReservationBillService returnReservationBillService,
                                   IReturnBillService returnBillService,
                                   ISaleReservationBillService saleReservationBillService,
                                   ISaleBillService saleBillService
                                   ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "退货单";

            this.BillType = BillTypeEnum.ReturnBill;

            this.Load = ReactiveCommand.Create(async() =>
            {
                ItemTreshold = 1;
                PageCounter  = 0;

                try
                {
                    Bills?.Clear();
                    int?terminalId     = Filter.TerminalId;
                    int?businessUserId = Filter.BusinessUserId;
                    string billNumber  = Filter.SerchKey;
                    DateTime?startTime = Filter.StartTime ?? DateTime.Now;
                    DateTime?endTime   = Filter.EndTime ?? DateTime.Now;

                    int?makeuserId = Settings.UserId;
                    if (Filter.BusinessUserId == Settings.UserId)
                    {
                        businessUserId = 0;
                    }
                    int?wareHouseId     = 0;
                    string terminalName = "";
                    string remark       = "";
                    int?districtId      = 0;
                    int?deliveryUserId  = 0;
                    //获取未审核
                    bool?auditedStatus     = false;
                    bool?sortByAuditedTime = null;
                    bool?showReverse       = null;
                    bool?showReturn        = null;
                    bool?handleStatus      = null;
                    int?paymentMethodType  = null;
                    int?billSourceType     = null;

                    var pending = new List <ReturnBillModel>();


                    var result = await _returnBillService.GetReturnBillsAsync(makeuserId, terminalId, terminalName, businessUserId, deliveryUserId, wareHouseId, districtId, remark, billNumber, startTime, endTime, auditedStatus, sortByAuditedTime, showReverse, showReturn, paymentMethodType, billSourceType, handleStatus, 0, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm    = s;
                            sm.IsLast = !(result.LastOrDefault()?.BillNumber == s.BillNumber);
                            return(sm);
                        }).Where(s => s.MakeUserId == Settings.UserId || s.BusinessUserId == Settings.UserId).ToList();
                    }
                    if (pending.Any())
                    {
                        Bills = new System.Collections.ObjectModel.ObservableCollection <ReturnBillModel>(pending);
                    }
                    UpdateTitle();
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            });

            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                int pageIdex = 0;
                if (Bills?.Count != 0)
                {
                    pageIdex = Bills.Count / (PageSize == 0 ? 1 : PageSize);
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            int?terminalId     = Filter.TerminalId;
                            int?businessUserId = Filter.BusinessUserId;
                            string billNumber  = Filter.SerchKey;
                            DateTime?startTime = Filter.StartTime ?? DateTime.Now;
                            DateTime?endTime   = Filter.EndTime ?? DateTime.Now;

                            int?makeuserId = Settings.UserId;
                            if (Filter.BusinessUserId == Settings.UserId)
                            {
                                businessUserId = 0;
                            }
                            int?wareHouseId     = 0;
                            string terminalName = "";
                            string remark       = "";
                            int?districtId      = 0;
                            int?deliveryUserId  = 0;
                            //获取未审核
                            bool?auditedStatus     = false;
                            bool?sortByAuditedTime = null;
                            bool?showReverse       = null;
                            bool?showReturn        = null;
                            bool?handleStatus      = null;
                            int?paymentMethodType  = null;
                            int?billSourceType     = null;

                            var pending = new List <ReturnBillModel>();

                            var items = await _returnBillService.GetReturnBillsAsync(makeuserId, terminalId, terminalName, businessUserId, deliveryUserId, wareHouseId, districtId, remark, billNumber, startTime, endTime, auditedStatus, sortByAuditedTime, showReverse, showReturn, paymentMethodType, billSourceType, handleStatus, pageIdex, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());
                            if (items != null)
                            {
                                foreach (var item in items)
                                {
                                    if (Bills.Count(s => s.Id == item.Id) == 0)
                                    {
                                        Bills.Add(item);
                                    }
                                }

                                foreach (var s in Bills)
                                {
                                    s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                                }
                            }
                            UpdateTitle();
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                }
            }, this.WhenAny(x => x.Bills, x => x.GetValue().Count > 0));

            //选择单据
            this.SelectedCommand = ReactiveCommand.Create <ReturnBillModel>(async x =>
            {
                if (x != null)
                {
                    await NavigateAsync(nameof(ReturnBillPage), ("Bill", x), ("IsSubmitBill", true));
                }
            });

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.SUBMIT30:
                    {
                        Filter.StartTime = dtime.AddMonths(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case Enums.MenuEnum.CLEARHISTORY:    //清空一个月历史单据
                    {
                        ClearHistory(() => _globalService.UpdateHistoryBillStatusAsync((int)this.BillType));
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_VIEW_KEY, 3));

            this.BindBusyCommand(Load);
        }
コード例 #2
0
        public SaleDetailPageViewModel(INavigationService navigationService,
                                       IReceiptCashService receiptCashService,
                                       IDialogService dialogService,
                                       IProductService productService,
                                       IUserService userService,
                                       ITerminalService terminalService,
                                       IWareHousesService wareHousesService,
                                       IAccountingService accountingService,
                                       IReportingService reportingService) : base(navigationService, productService, terminalService, userService, wareHousesService, accountingService, dialogService)
        {
            Title = "商品销售明细";


            this.Load = ReactiveCommand.CreateFromTask(async() =>
            {
                if (!string.IsNullOrEmpty(ProductName))
                {
                    Title = $"{ProductName}-明细";
                }

                //重载时排它
                ItemTreshold = 1;

                try
                {
                    this.Bills?.Clear();
                    PageCounter = 0;

                    var rankings       = new List <SaleReportItem>();
                    int?productId      = ProductId;
                    int?businessUserId = Filter.BusinessUserId;
                    DateTime?startTime = Filter.StartTime ?? DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01 00:00:00"));
                    DateTime?endTime   = Filter.EndTime ?? DateTime.Now;

                    var result = await reportingService.GetHotSaleReportItemAsync(productId,
                                                                                  businessUserId,
                                                                                  startTime.Value,
                                                                                  endTime.Value,
                                                                                  this.ForceRefresh,
                                                                                  0,
                                                                                  new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        foreach (var item in result)
                        {
                            this.Bills.Add(item);
                        }

                        if (this.Bills.Any())
                        {
                            this.Bills = new ObservableRangeCollection <SaleReportItem>(Bills);
                        }
                    }

                    UpdateUI();
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            });


            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                if (ItemTreshold == -1)
                {
                    return;
                }

                int pageIdex = 0;

                var p = Bills.Count;

                if (this.Bills?.Count != 0)
                {
                    pageIdex = Bills.Count / 30;
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            var rankings       = new List <SaleReportItem>();
                            int?productId      = ProductId;
                            int?businessUserId = Filter.BusinessUserId;
                            DateTime?startTime = Filter.StartTime ?? DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01 00:00:00"));
                            DateTime?endTime   = Filter.EndTime ?? DateTime.Now;

                            var result = await reportingService.GetHotSaleReportItemAsync(productId,
                                                                                          businessUserId,
                                                                                          startTime.Value,
                                                                                          endTime.Value,
                                                                                          this.ForceRefresh,
                                                                                          pageIdex,
                                                                                          new System.Threading.CancellationToken());

                            if (result != null && result.Any())
                            {
                                foreach (var item in result)
                                {
                                    Bills.Add(item);
                                }
                            }
                            else
                            {
                                ItemTreshold = -1;
                            }
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                            ItemTreshold = -1;
                        }
                    }
                }
            }, this.WhenAny(x => x.Bills, x => x.GetValue().Count > 0));


            this.BindBusyCommand(Load);
        }
コード例 #3
0
        public AllocationSummeryPageViewModel(INavigationService navigationService,
                                              IGlobalService globalService,
                                              IDialogService dialogService,
                                              IAllocationService allocationService,
                                              IAdvanceReceiptService advanceReceiptService,
                                              IReceiptCashService receiptCashService,
                                              ICostContractService costContractService,
                                              ICostExpenditureService costExpenditureService,
                                              IInventoryService inventoryService,
                                              IPurchaseBillService purchaseBillService,
                                              IReturnReservationBillService returnReservationBillService,
                                              IReturnBillService returnBillService,
                                              ISaleReservationBillService saleReservationBillService,

                                              ISaleBillService saleBillService
                                              ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "调拨单";

            this.BillType = BillTypeEnum.AllocationBill;

            Filter.StartTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
            Filter.EndTime   = DateTime.Now;

            this.Load = ReactiveCommand.Create(async() =>
            {
                //重载时排它
                ItemTreshold = 1;
                PageCounter  = 0;
                try
                {
                    DateTime?startTime = Filter.StartTime;
                    DateTime?endTime   = Filter.EndTime;
                    int?businessUserId = Filter.BusinessUserId;
                    int?customerId     = Filter.TerminalId;
                    string billNumber  = Filter.SerchKey;

                    int?makeuserId = Settings.UserId;
                    if (businessUserId.HasValue && businessUserId > 0)
                    {
                        makeuserId = 0;
                    }

                    int?shipmentWareHouseId = 0;
                    int?incomeWareHouseId   = 0;
                    //获取已审核
                    bool?auditedStatus     = true;
                    bool?showReverse       = null;
                    bool?sortByAuditedTime = null;

                    //清除列表
                    Bills?.Clear();

                    var items = await _allocationService.GetAllocationsAsync(makeuserId,
                                                                             businessUserId ?? 0,
                                                                             shipmentWareHouseId,
                                                                             incomeWareHouseId,
                                                                             billNumber,
                                                                             "",
                                                                             auditedStatus,
                                                                             startTime,
                                                                             endTime,
                                                                             showReverse,
                                                                             sortByAuditedTime,
                                                                             0,
                                                                             PageSize,
                                                                             this.ForceRefresh,
                                                                             new System.Threading.CancellationToken());

                    if (items != null)
                    {
                        foreach (var item in items)
                        {
                            if (Bills.Count(s => s.Id == item.Id) == 0)
                            {
                                Bills.Add(item);
                            }
                        }

                        if (items.Count() == 0 || items.Count() == Bills.Count)
                        {
                            ItemTreshold = -1;
                        }

                        foreach (var s in Bills)
                        {
                            s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                        }


                        if (Bills.Count > 0)
                        {
                            this.Bills = new ObservableRangeCollection <AllocationBillModel>(Bills);
                        }
                        UpdateTitle();
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            });
            //以增量方式加载数据
            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                int pageIdex = 0;
                if (Bills?.Count != 0)
                {
                    pageIdex = Bills.Count / (PageSize == 0 ? 1 : PageSize);
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            string billNumber  = Filter.SerchKey;
                            DateTime?startTime = Filter.StartTime;
                            DateTime?endTime   = Filter.EndTime;
                            int?businessUserId = Filter.BusinessUserId;
                            int?customerId     = Filter.TerminalId;

                            int?makeuserId = Settings.UserId;
                            if (businessUserId.HasValue && businessUserId > 0)
                            {
                                makeuserId = 0;
                            }

                            int?shipmentWareHouseId = 0;
                            int?incomeWareHouseId   = 0;
                            //获取已审核
                            bool?auditedStatus     = true;
                            bool?showReverse       = null;
                            bool?sortByAuditedTime = null;


                            var items = await _allocationService.GetAllocationsAsync(makeuserId, businessUserId ?? 0, shipmentWareHouseId, incomeWareHouseId, billNumber, "", auditedStatus, startTime, endTime, showReverse, sortByAuditedTime, pageIdex, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());
                            if (items != null)
                            {
                                foreach (var item in items)
                                {
                                    if (Bills.Count(s => s.Id == item.Id) == 0)
                                    {
                                        Bills.Add(item);
                                    }
                                }

                                if (items.Count() == 0)
                                {
                                    ItemTreshold = -1;
                                }

                                foreach (var s in Bills)
                                {
                                    s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                                }
                                UpdateTitle();
                            }
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                }
            }, this.WhenAny(x => x.Bills, x => x.GetValue().Count > 0));


            //选择单据
            this.WhenAnyValue(x => x.Selecter).Throttle(TimeSpan.FromMilliseconds(500))
            .Skip(1)
            .Where(x => x != null)
            .SubOnMainThread(async x =>
            {
                if (x != null)
                {
                    await NavigateAsync(nameof(AllocationBillPage), ("Bill", x));
                }
                this.Selecter = null;
            }).DisposeWith(DeactivateWith);

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.SUBMIT30:
                    {
                        Filter.StartTime = dtime.AddMonths(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case Enums.MenuEnum.CLEARHISTORY:    //清空一个月历史单据
                    {
                        ClearHistory(() => _globalService.UpdateHistoryBillStatusAsync((int)this.BillType));
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_KEY, 4));

            this.BindBusyCommand(Load);
        }
コード例 #4
0
        public UnCostExpenditurePageViewModel(INavigationService navigationService,
                                              IGlobalService globalService,
                                              IDialogService dialogService,
                                              IAllocationService allocationService,
                                              IAdvanceReceiptService advanceReceiptService,
                                              IReceiptCashService receiptCashService,
                                              ICostContractService costContractService,
                                              ICostExpenditureService costExpenditureService,
                                              IInventoryService inventoryService,
                                              IPurchaseBillService purchaseBillService,
                                              IReturnReservationBillService returnReservationBillService,
                                              IReturnBillService returnBillService,
                                              ISaleReservationBillService saleReservationBillService,
                                              ISaleBillService saleBillService
                                              ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "费用支出(0)";

            this.Bills = new ObservableCollection <CostExpenditureBillModel>();

            //载入未签收费用支出单据
            this.Load = ReactiveCommand.Create(async() =>
            {
                var pending = new List <CostExpenditureBillModel>();
                try
                {
                    DateTime?startTime = Filter.StartTime;
                    DateTime?endTime   = Filter.EndTime;
                    int?customerId     = Filter.TerminalId;
                    int?employeeId     = Filter.BusinessUserId;
                    int?makeuserId     = Settings.UserId;

                    string billNumber = "";
                    //获取已审核
                    bool?auditedStatus     = true;
                    bool?showReverse       = null;
                    bool sortByAuditedTime = false;
                    int pagenumber         = 0;
                    int pageSize           = 20;

                    var result = await _costExpenditureService.GetCostExpendituresAsync(makeuserId,
                                                                                        customerId,
                                                                                        "",
                                                                                        employeeId,
                                                                                        billNumber,
                                                                                        auditedStatus,
                                                                                        startTime,
                                                                                        endTime,
                                                                                        showReverse,
                                                                                        sortByAuditedTime,
                                                                                        0,
                                                                                        pagenumber,
                                                                                        pageSize, this.ForceRefresh, new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm       = s;
                            sm.IsLast    = !(result.LastOrDefault()?.BillNumber == s.BillNumber);
                            sm.SumAmount = s.Items?.Sum(i => i.Amount) ?? 0;

                            return(sm);
                        }).ToList();

                        TotalAmount = pending.Select(b => b.SumAmount).Sum();
                        Title       = $"费用支出({pending.Count})";

                        if (pending != null && pending.Any())
                        {
                            Bills = new ObservableCollection <CostExpenditureBillModel>(pending);
                        }
                    }
                }
                catch (System.Exception) { }
            });

            //费用支出单签收
            this.SelecterCommand = ReactiveCommand.CreateFromTask <CostExpenditureBillModel>(async(item) =>
            {
                if (item != null)
                {
                    using (UserDialogs.Instance.Loading("稍等..."))
                    {
                        await this.NavigateAsync("CostExpenditureBillPage",
                                                 ("Reference", this.PageName),
                                                 ("DispatchItemModel", null),
                                                 ("Bill", item));
                    }
                }
                item = null;
            });

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_DEV_KEY, 1));


            this.BindBusyCommand(Load);
        }
コード例 #5
0
ファイル: UnSalePageViewModel.cs プロジェクト: dorisoy/Wesley
        public UnSalePageViewModel(INavigationService navigationService,
               IGlobalService globalService,
               IDialogService dialogService,
               IAllocationService allocationService,
               IAdvanceReceiptService advanceReceiptService,
               IReceiptCashService receiptCashService,
               ICostContractService costContractService,
               ICostExpenditureService costExpenditureService,
               IInventoryService inventoryService,
               IPurchaseBillService purchaseBillService,
               IReturnReservationBillService returnReservationBillService,
               IReturnBillService returnBillService,
               ISaleReservationBillService saleReservationBillService,
               ISaleBillService saleBillService
            ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {

            Title = "销售签收(0)";

            this.Bills = new ObservableCollection<SaleBillModel>();

            this.Load = ReactiveCommand.Create(async () =>
            {
                var pending = new List<SaleBillModel>();

                try
                {
                    int? terminalId = 0;
                    int? businessUserId = 0;
                    DateTime? startTime = DateTime.Now.AddMonths(-7);
                    DateTime? endTime = DateTime.Now;

                    int? makeuserId = Settings.UserId;
                    int? wareHouseId = 0;
                    string billNumber = "";
                    string terminalName = "";
                    string remark = "";
                    int? districtId = 0;
                    int? deliveryUserId = 0;
                    //获取已经审核,未签收单据
                    bool? auditedStatus = true;
                    bool? sortByAuditedTime = null;
                    bool? showReverse = null;
                    bool? showReturn = null;
                    bool? handleStatus = null;
                    int? paymentMethodType = 0;
                    int? billSourceType = 0;
                    int pageIndex = 0;
                    int pageSize = 20;

                    //获取待签收
                    var result = await _saleBillService.GetSalebillsAsync(makeuserId,
                        terminalId,
                        terminalName,
                        businessUserId,
                        districtId,
                        deliveryUserId,
                        wareHouseId,
                        billNumber,
                        remark,
                        startTime,
                        endTime,
                        auditedStatus,
                        sortByAuditedTime,
                        showReverse,
                        showReturn,
                        paymentMethodType,
                        billSourceType,
                        handleStatus,
                        0,
                        pageIndex,
                        pageSize,
                        this.ForceRefresh,
                        new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm = s;
                            sm.IsLast = !(result.LastOrDefault()?.BillNumber == s.BillNumber);
                            return sm;
                        }).ToList();

                        TotalAmount = pending.Select(b => b.SumAmount).Sum();
                        Title = $"销售单({pending.Count})";

                        if (pending != null && pending.Any())
                            Bills = new ObservableCollection<SaleBillModel>(pending);
                    }
                }
                catch (System.Exception) { }
            });


            //签收 
            this.SelecterCommand = ReactiveCommand.CreateFromTask<SaleBillModel>(async (item) =>
            {
                if (item != null)
                {
                    using (UserDialogs.Instance.Loading("稍等..."))
                    {
                        await this.NavigateAsync("SaleBillPage",
                            ("Reference", this.PageName),
                            ("DispatchItemModel", null),
                            ("Bill", item));
                    }
                }
                item = null;
            });

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                    case MenuEnum.TODAY:
                        {
                            Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                            Filter.EndTime = dtime;
                            ((ICommand)Load)?.Execute(null);
                        }
                        break;
                    case MenuEnum.YESTDAY:
                        {
                            Filter.StartTime = dtime.AddDays(-1);
                            Filter.EndTime = dtime;
                            ((ICommand)Load)?.Execute(null);
                        }
                        break;
                    case MenuEnum.OTHER:
                        {
                            SelectDateRang();
                            ((ICommand)Load)?.Execute(null);
                        }
                        break;
                }

            }, string.Format(Constants.MENU_DEV_KEY, 2));

            this.BindBusyCommand(Load);

        }
コード例 #6
0
        public InventoryReportViewPageViewModel(INavigationService navigationService,
                                                IGlobalService globalService,
                                                IDialogService dialogService,
                                                IAllocationService allocationService,
                                                IAdvanceReceiptService advanceReceiptService,
                                                IReceiptCashService receiptCashService,
                                                ICostContractService costContractService,
                                                ICostExpenditureService costExpenditureService,
                                                IInventoryService inventoryService,
                                                IPurchaseBillService purchaseBillService,
                                                IReturnReservationBillService returnReservationBillService,
                                                IReturnBillService returnBillService,
                                                ISaleReservationBillService saleReservationBillService,
                                                IWareHousesService wareHousesService,
                                                ISaleBillService saleBillService
                                                ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "库存上报";

            _wareHousesService = wareHousesService;

            this.Load = ReactiveCommand.Create(async() =>
            {
                ItemTreshold = 1;
                PageCounter  = 0;

                try
                {
                    Bills?.Clear();
                    var pending = new List <InventoryReportSummaryModel>();

                    int?makeuserId     = Settings.UserId;
                    int?terminalId     = null;
                    int?businessUserId = null;
                    int?productId      = null;
                    int?channelId      = null;
                    int?rankId         = null;
                    int?districtId     = null;

                    string billNumber  = Filter.SerchKey;
                    DateTime?startTime = Filter.StartTime ?? DateTime.Now.AddMonths(-1);
                    DateTime?endTime   = Filter.EndTime ?? DateTime.Now;


                    var result = await _wareHousesService.GetInventoryReportAsync(makeuserId, businessUserId, terminalId, channelId, rankId, districtId, productId, startTime, endTime, 0, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());


                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm    = s;
                            sm.IsLast = !(result?.LastOrDefault()?.BillNumber == s.BillNumber);
                            return(sm);
                        }).Where(s => s.MakeUserId == Settings.UserId || s.BusinessUserId == Settings.UserId).ToList();
                    }
                    if (pending.Any())
                    {
                        Bills = new System.Collections.ObjectModel.ObservableCollection <InventoryReportSummaryModel>(pending);
                    }


                    UpdateTitle();
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            });


            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                int pageIdex = 0;
                if (Bills?.Count != 0)
                {
                    pageIdex = Bills.Count / (PageSize == 0 ? 1 : PageSize);
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            int?makeuserId     = Settings.UserId;
                            int?terminalId     = null;
                            int?businessUserId = null;
                            int?productId      = null;
                            int?channelId      = null;
                            int?rankId         = null;
                            int?districtId     = null;

                            string billNumber  = Filter.SerchKey;
                            DateTime?startTime = Filter.StartTime ?? DateTime.Now.AddMonths(-1);
                            DateTime?endTime   = Filter.EndTime ?? DateTime.Now;


                            var result = await _wareHousesService.GetInventoryReportAsync(makeuserId, businessUserId, terminalId, channelId, rankId, districtId, productId, startTime, endTime, 0, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());

                            if (result != null)
                            {
                                foreach (var item in result)
                                {
                                    if ((item.MakeUserId == Settings.UserId || item.BusinessUserId == Settings.UserId) && Bills.Count(s => s.Id == item.Id) == 0)
                                    {
                                        Bills.Add(item);
                                    }
                                }

                                foreach (var s in Bills)
                                {
                                    s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                                }
                            }

                            UpdateTitle();
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                }
            }, this.WhenAny(x => x.Bills, x => x.GetValue().Count > 0));

            this.BindBusyCommand(Load);
        }
コード例 #7
0
        //
        public ReceiptBillPageViewModel(INavigationService navigationService,
                                        IProductService productService,
                                        ITerminalService terminalService,
                                        IUserService userService,
                                        IWareHousesService wareHousesService,
                                        IAccountingService accountingService,
                                        IReceiptCashService receiptCashService,
                                        IDialogService dialogService

                                        ) : base(navigationService, productService, terminalService, userService, wareHousesService, accountingService, dialogService)
        {
            Title = "收款单";

            _receiptCashService = receiptCashService;

            InitBill();

            //验证
            var valid_IsVieweBill    = this.ValidationRule(x => x.Bill.AuditedStatus, _isBool, "已审核单据不能操作");
            var valid_TerminalId     = this.ValidationRule(x => x.Bill.TerminalId, _isZero, "客户未指定");
            var valid_BusinessUserId = this.ValidationRule(x => x.Bill.BusinessUserId, _isZero, "业务员未指定");
            var valid_ProductCount   = this.ValidationRule(x => x.Bill.Items.Count, _isZero, "无收款单据信息");
            var valid_SelectesCount  = this.ValidationRule(x => x.Bill.CashReceiptBillAccountings.Count, _isZero, "请选择支付方式");

            //更改时间
            this.WhenAnyValue(x => x.Filter.EndTime).Subscribe(x =>
            {
                if (x.HasValue)
                {
                    ClearIcon = "fas-times-circle";
                }
                else
                {
                    ClearIcon = "fas-clock";
                    ((ICommand)Load)?.Execute(null);
                }
            }).DisposeWith(DeactivateWith);

            //绑定数据
            this.Load = BillItemsLoader.Load(async() =>
            {
                if (Bill.Id == 0)
                {
                    var inits = await _receiptCashService.GetInitDataAsync(calToken: new System.Threading.CancellationToken());
                    if (inits != null)
                    {
                        Bill.CashReceiptBillAccountings = inits.CashReceiptBillAccountings;
                        if (this.PaymentMethods.Selectes.Count == 0)
                        {
                            var defaultPaymentMethods = inits.CashReceiptBillAccountings.Select(a =>
                            {
                                return(new AccountingModel()
                                {
                                    Name = a.Name,
                                    AccountingOptionId = a.AccountingOptionId,
                                    CollectionAmount = 0,
                                    AccountCodeTypeId = a.AccountCodeTypeId,
                                    Number = a.AccountCodeTypeId
                                });
                            }).ToList();
                            this.PaymentMethods.Selectes = new ObservableCollection <AccountingModel>(defaultPaymentMethods);;
                        }
                    }

                    var pending = new List <CashReceiptItemModel>();

                    int?terminalId     = Filter.TerminalId;
                    int?businessUserId = Filter.BusinessUserId;

                    string billNumber  = "";
                    string remark      = "";
                    DateTime?startTime = Filter.StartTime;
                    DateTime?endTime   = Filter.EndTime;
                    int pageIndex      = 0;
                    int pageSize       = 20;

                    if (terminalId.HasValue && terminalId.Value != 0)
                    {
                        var result = await _receiptCashService.GetOwecashBillsAsync(Settings.UserId, terminalId, null, billNumber, remark, startTime, endTime, pageIndex, pageSize, calToken: new System.Threading.CancellationToken());

                        if (result != null)
                        {
                            var curBills = result?.Where(s => s?.BillTypeId != (int)BillTypeEnum.FinancialIncomeBill).ToList();
                            if (curBills != null && curBills.Count > 0)
                            {
                                foreach (var bill in curBills)
                                {
                                    pending.Add(new CashReceiptItemModel()
                                    {
                                        CashReceiptBillId = 0,
                                        BillId            = bill.BillId,
                                        BillNumber        = bill.BillNumber,
                                        BillTypeId        = bill.BillTypeId,
                                        BillTypeName      = bill.BillTypeName,
                                        BillLink          = bill.BillLink,
                                        MakeBillDate      = bill.MakeBillDate,

                                        //单据金额
                                        Amount = bill.Amount,
                                        //优惠
                                        DiscountAmount = bill.DiscountAmount,
                                        //已收金额
                                        PaymentedAmount = bill.PaymentedAmount,
                                        //欠款金额
                                        ArrearsAmount = bill.ArrearsAmount,

                                        //本次优惠金额
                                        DiscountAmountOnce = 0,
                                        //本次收款金额
                                        ReceivableAmountOnce = 0,
                                        //收款后尚欠金额 = 欠款金额
                                        AmountOwedAfterReceipt = bill.ArrearsAmount,
                                        //应收金额 = 欠款金额
                                        AmountReceivable = bill.ArrearsAmount,
                                        Remark           = bill.Remark,
                                        //预览单据
                                        RedirectCommand = ReactiveCommand.Create <CashReceiptItemModel>(async e =>
                                        {
                                            //销售单
                                            if (e?.BillTypeId == (int)BillTypeEnum.SaleBill)
                                            {
                                                await this.NavigateAsync("SaleBillPage", ("BillId", e.BillId.ToString()));
                                            }
                                            //退货单
                                            else if (e?.BillTypeId == (int)BillTypeEnum.ReturnBill)
                                            {
                                                await this.NavigateAsync("ReturnBillPage", ("BillId", e.BillId.ToString()));
                                            }
                                            //预收款单
                                            else if (e?.BillTypeId == (int)BillTypeEnum.AdvanceReceiptBill)
                                            {
                                                await this.NavigateAsync("AdvanceReceiptBillPage", ("BillId", e.BillId.ToString()));
                                            }
                                            //费用支出
                                            else if (e?.BillTypeId == (int)BillTypeEnum.CostExpenditureBill)
                                            {
                                                await this.NavigateAsync("CostExpenditureBillPage", ("BillId", e.BillId.ToString()));
                                            }
                                            //其它收入
                                            else if (e?.BillTypeId == (int)BillTypeEnum.FinancialIncomeBill)
                                            {
                                                //移动端不支持(财务其它收入)收款
                                            }
                                        })
                                    });
                                }
コード例 #8
0
        public ReceivablesPageViewModel(INavigationService navigationService,
                                        IReceiptCashService receiptCashService,
                                        IDialogService dialogService,
                                        IProductService productService,
                                        IUserService userService,
                                        ITerminalService terminalService,
                                        IWareHousesService wareHousesService,
                                        IAccountingService accountingService

                                        ) : base(navigationService, productService, terminalService, userService, wareHousesService, accountingService, dialogService)
        {
            Title = "应收款";

            _receiptCashService = receiptCashService;

            //绑定数据
            this.Load = AmountReceivableGroupsLoader.Load(async() =>
            {
                var pending = new List <AmountReceivableGroupModel>();

                try
                {
                    //这里只取选择客户
                    int?terminalId     = Filter.TerminalId;
                    int businessUserId = Filter.BusinessUserId;
                    if (businessUserId == 0)
                    {
                        businessUserId = Settings.UserId;
                    }
                    DateTime?startTime = Filter.StartTime ?? null;
                    DateTime?endTime   = Filter.EndTime ?? null;

                    string billNumber = "";
                    string remark     = "";

                    var result = await _receiptCashService.GetOwecashBillsAsync(
                        businessUserId,
                        terminalId,
                        null,
                        billNumber,
                        remark,
                        startTime,
                        endTime,
                        0,
                        PageSize,
                        this.ForceRefresh,
                        new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        foreach (IGrouping <int, BillSummaryModel> group in result.GroupBy(c => c.CustomerId))
                        {
                            var code = result.FirstOrDefault(c => c.CustomerId == group.Key)?.CustomerPointCode;
                            var name = result.FirstOrDefault(c => c.CustomerId == group.Key)?.CustomerName;
                            if (!string.IsNullOrEmpty(name))
                            {
                                pending.Add(new AmountReceivableGroupModel()
                                {
                                    CustomerId        = group.Key,
                                    CustomerName      = result.FirstOrDefault(c => c.CustomerId == group.Key)?.CustomerName,
                                    CustomerPointCode = code,
                                    Amount            = result.Where(c => c.CustomerId == group.Key)?.Sum(s => s.ArrearsAmount) ?? 0
                                });
                            }
                        }
                    }

                    if (pending.Any())
                    {
                        TotalAmount = pending.Sum(p => p.Amount);
                        BillItems   = new ObservableRangeCollection <AmountReceivableGroupModel>(pending);
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }

                return(pending);
            });


            //以增量方式加载数据
            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                int pageIdex = 0;
                if (BillItems.Count != 0)
                {
                    pageIdex = BillItems.Count / (PageSize == 0 ? 1 : PageSize);
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            int?terminalId     = Filter.TerminalId;
                            int businessUserId = Filter.BusinessUserId;
                            if (businessUserId == 0)
                            {
                                businessUserId = Settings.UserId;
                            }
                            DateTime?startTime = Filter.StartTime ?? null;
                            DateTime?endTime   = Filter.EndTime ?? null;

                            string billNumber = "";
                            string remark     = "";

                            var items = await _receiptCashService.GetOwecashBillsAsync(
                                businessUserId,
                                terminalId,
                                null,
                                billNumber,
                                remark,
                                startTime,
                                endTime,
                                pageIdex,
                                PageSize,
                                this.ForceRefresh,
                                new System.Threading.CancellationToken());

                            if (items != null)
                            {
                                var pending = new List <AmountReceivableGroupModel>();
                                foreach (IGrouping <int, BillSummaryModel> group in items.GroupBy(c => c.CustomerId))
                                {
                                    var code = items.FirstOrDefault(c => c.CustomerId == group.Key)?.CustomerPointCode;
                                    var name = items.FirstOrDefault(c => c.CustomerId == group.Key)?.CustomerName;
                                    if (!string.IsNullOrEmpty(name))
                                    {
                                        pending.Add(new AmountReceivableGroupModel()
                                        {
                                            CustomerId        = group.Key,
                                            CustomerName      = items.FirstOrDefault(c => c.CustomerId == group.Key)?.CustomerName,
                                            CustomerPointCode = code,
                                            Amount            = items.Where(c => c.CustomerId == group.Key)?.Sum(s => s.ArrearsAmount) ?? 0
                                        });
                                    }
                                }

                                foreach (var p in pending)
                                {
                                    if (BillItems.Where(s => s.CustomerId == p.CustomerId).Count() == 0)
                                    {
                                        BillItems.Add(p);
                                    }
                                }

                                if (pending.Count() == 0 || pending.Count() == BillItems.Count)
                                {
                                    ItemTreshold = -1;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                            ItemTreshold = -1;
                        }
                    }
                }
            }, this.WhenAny(x => x.BillItems, x => x.GetValue().Count > 0));


            //选择转向收款单
            this.WhenAnyValue(x => x.Selecter).Throttle(TimeSpan.FromMilliseconds(500))
            .Skip(1)
            .Where(x => x != null)
            .SubOnMainThread(async x =>
            {
                await this.NavigateAsync("ReceiptBillPage", ("Terminaler",
                                                             new TerminalModel()
                {
                    Id = Selecter.CustomerId,
                    Name = Selecter.CustomerName
                }));
                Selecter = null;
            }).DisposeWith(DeactivateWith);

            this.BindBusyCommand(Load);
        }