Ejemplo n.º 1
0
        public async Task HandleAsync(UserMessageInfo userMessageInfo, int amount, string caption)
        {
            BillingPeriod lastBillingPeriod = await _billingPeriodService.GetLastByGroupIdAsync(userMessageInfo.Group.Id);

            if (lastBillingPeriod == null)
            {
                await _messenger.SendMessageAsync(userMessageInfo, "В группе ещё не начат ни один расчётный период", true);

                return;
            }

            var newReceipt = await _receiptService.AddAsync(new Receipt
            {
                BillingPeriodId = lastBillingPeriod.Id,
                TotalAmount     = amount,
                Status          = ReceiptStatus.NewManual,
                Comment         = caption
            });

            IMenu menu = _menuProvider.GetMenu(userMessageInfo, new AddReceiptQueryData
            {
                MenuType            = MenuType.NewReceiptSelectCustomer,
                ReceiptId           = newReceipt.Id,
                SelectedCustomerId  = null,
                SelectedConsumerIds = new long[0],
                TargetId            = null,
                Version             = AddReceiptQueryData.ServerVersion,
            });
            await _messenger.SendMessageAsync(userMessageInfo, Resources.SelectCustomer, true, menu);
        }
Ejemplo n.º 2
0
        public async Task HandleAsync(UserMessageInfo userMessageInfo)
        {
            ReceiptMainInfo data = userMessageInfo.Message.ReceiptInfo;

            if (data == null)
            {
                await Messenger.SendMessageAsync(userMessageInfo, Resources.ParsePhotoError, true);

                Logger.Trace(Resources.ParsePhotoError);
                return;
            }

            BillingPeriod lastBillingPeriod = await _billingPeriodService.GetLastByGroupIdAsync(userMessageInfo.Group.Id);

            if (lastBillingPeriod == null)
            {
                await Messenger.SendMessageAsync(userMessageInfo, Resources.BillingPeriodNotCreated, true);

                return;
            }

            var receipt = new Receipt
            {
                BillingPeriodId = lastBillingPeriod.Id,
                TotalAmount     = data.TotalAmount,
                FiscalSign      = data.FiscalSign,
                FiscalDocument  = data.FiscalDocument,
                FiscalNumber    = data.FiscalNumber,
                PurchaseTime    = data.PurchaseTime,
                Status          = ReceiptStatus.New,
                Comment         = "Чек",
            };

            if (await ReceiptService.IsReceiptExists(receipt))
            {
                await Messenger.SendMessageAsync(userMessageInfo, Resources.ReceiptAlredyAdded, true);

                return;
            }

            var newReceipt = await ReceiptService.AddAsync(receipt);

            IMenu menu = MenuProvider.GetMenu(userMessageInfo, new AddReceiptQueryData
            {
                MenuType            = MenuType.NewReceiptSelectCustomer,
                ReceiptId           = newReceipt.Id,
                SelectedCustomerId  = null,
                SelectedConsumerIds = new long[0],
                TargetId            = null,
                Version             = AddReceiptQueryData.ServerVersion,
            });
            await Messenger.SendMessageAsync(userMessageInfo, Resources.SelectCustomer, true, menu);
        }