protected override void GenerateItems(IMaterialInventory forInventory, int year, int month, IInvoiceFormGenerationContext context,
                                              IReleasingFormsGenerationTask task, Action <DateTime, IMaterialBatch, Amount, DirectSaleDescriptor> itemCallback)
        {
            if (!forInventory.CanBeConnectedToTag)
            {
                context.Info($"Pro sklad \"{forInventory.Name}\" se výdejky typu \"Přímý prodej\" negenerují - přeskakuji");
                return;
            }

            if (forInventory.AllowedUnitId == null)
            {
                throw new InvalidOperationException($"Pro sklad \"{forInventory.Name}\" musi byt nastavena dovolena merna jednotka");
            }

            var unit = m_unitRepository.GetUnit(forInventory.AllowedUnitId.Value);

            DateUtil.GetMonthDt(year, month, out var fromDt, out var toDt);

            var events = m_saleEventRepository.GetEvents(fromDt, toDt);

            foreach (var evt in events)
            {
                foreach (var allocation in evt.Allocations.Where(e => e.ReturnDt != null))
                {
                    var soldAmount = new Amount(allocation.AllocatedQuantity - allocation.ReturnedQuantity ?? 0m, allocation.Unit);
                    itemCallback(evt.EventDt, allocation.Batch, soldAmount, new DirectSaleDescriptor()
                    {
                        Event      = evt,
                        Allocation = allocation
                    });
                }
            }
        }
Beispiel #2
0
        public SaleEventsCollection GetEvents(int pageNumber)
        {
            var evts = m_saleEventRepository.GetEvents(pageNumber, 10).Select(Map).ToList();

            return(new SaleEventsCollection(evts.Count == 10 ? pageNumber + 1 : (int?)null, evts));
        }