public async Task AddAsync(QuotationAddModel model)
        {
            // var items = (await _itemRepository.GetAsync(model.Items)).ToList();

            //model.TotalAmount = items.Sum(x => x.Rate);

            //model.Tax = items.Where(x => x.IsTaxable).Sum(x => x.Rate * x.SalesTax.TaxPercentage / 100);

            //var customer = await _customerRepository.GetAsync(model.CustomerId);

            //if (customer.Discount != null)
            //{
            //    model.Discount = model.TotalAmount * customer.Discount / 100;
            //    model.TotalAmount = model.TotalAmount - (model.Discount ?? 0);
            //}

            //if (model.Tax != null)
            //{
            //    model.TotalAmount = model.TotalAmount + (model.Tax ?? 0);
            //}
            model.LineAmountSubTotal = model.Items.Sum(x => x.LineAmount);
            var count = await _quotationRepository.getCount();

            //await _invoiceRepository.AddAsync(InvoiceFactory.Create(model, _userId, items));
            await _quotationRepository.AddAsync(QuotationFactory.Create(model, _userId, count));

            await _unitOfWork.SaveChangesAsync();
        }
Exemple #2
0
        private Task <bool> ExecutionAsync(QuotationCreateEvent @event)
        {
            Quotation newOrder = new Quotation
            {
                OrderId     = @event.Id,
                OfferPrice  = @event.Price,
                ActualPrice = @event.InitialPrice,
                OfType      = @event.OrderType,
                CreateDate  = @event.Timestamp
            };

            _quotationRepository.AddAsync(newOrder);

            return(Task.FromResult(true));
        }