Ejemplo n.º 1
0
        public void Write(Assemblage assemblage)
        {
            var select = assemblage.ListOfNomenc.GroupBy(i => i.Nomenclature).Select(g => new LineItem()
            {
                Nomenclature = g.Key,
                Quantity     = g.Sum(i => i.Quantity),
                Sum          = g.Sum(i => i.Sum)
            });

            foreach (var item in select)
            {
                var recordNomenclature = new RemainNomenclature
                {
                    Nomenclature = item.Nomenclature,
                    RecordType   = RecordType.Expose,
                    Quantity     = item.Quantity,
                };
                var recordCostPrice = new RemainCostPrice
                {
                    Nomenclature = item.Nomenclature,
                    RecordType   = RecordType.Expose,
                    Amount       = item.Quantity,
                };

                recordNomenclature.Warehouse = assemblage.Warehouse;
                _remainNomenclature.Create(recordNomenclature);
                _remainCostPrice.Create(recordCostPrice);
            }
            _repository.Create(assemblage);
            _remainNomenclature.RecalcBalances();
            _remainCostPrice.RecalcBalances();
        }
Ejemplo n.º 2
0
        public void Update(RemainCostPrice item)
        {
            var itemForRemove = _table.Find(n => n.Id == item.Id);
            var index         = _table.IndexOf(itemForRemove);

            _table.RemoveAt(index);
            _table.Insert(index, item);
        }
Ejemplo n.º 3
0
        public void Write(Consumption consumption)
        {
            var select = consumption.ListOfNomenc.GroupBy(i => i.Nomenclature).Select(g => new LineItem()
            {
                Nomenclature = g.Key,
                Quantity     = g.Sum(i => i.Quantity),
                Sum          = g.Sum(i => i.Sum)
            });

            foreach (var item in select)
            {
                var availableQuantity = _table
                                        .Where(t => t.Nomenclature.Id == item.Nomenclature.Id)
                                        .Select(q => q.Quantity)
                                        .ToList();
                if (availableQuantity[0] < item.Quantity)
                {
                    throw new System.ArgumentException("Not enough goods in warehouse");
                }
                var recordNomenclature = new RemainNomenclature
                {
                    Nomenclature = item.Nomenclature,
                    RecordType   = RecordType.Expose,
                    Quantity     = item.Quantity,
                    Warehouse    = consumption.Warehouse
                };

                var recordCostPrice = new RemainCostPrice
                {
                    Nomenclature = item.Nomenclature,
                    Amount       = item.Quantity,
                    Sum          = item.Sum,
                    RecordType   = RecordType.Expose,
                };

                _remainNomenclature.Create(recordNomenclature);
                _remainCostPrice.Create(recordCostPrice);
            }

            _repository.Create(consumption);
            _remainNomenclature.RecalcBalances();
            _remainCostPrice.RecalcBalances();
        }
Ejemplo n.º 4
0
        public void Write(Incoming incoming)
        {
            var select = incoming.ListOfNomenc.GroupBy(i => i.Nomenclature).Select(g => new LineItem()
            {
                Nomenclature = g.Key,
                Quantity     = g.Sum(i => i.Quantity),
                Sum          = g.Sum(i => i.Sum)
            });

            foreach (var item in select)
            {
                var recordNomenclature = new RemainNomenclature
                {
                    Nomenclature = item.Nomenclature,
                    RecordType   = RecordType.Receipt,
                    Quantity     = item.Quantity,
                    Warehouse    = incoming.Warehouse
                };

                var recordCostPrice = new RemainCostPrice
                {
                    Nomenclature = item.Nomenclature,
                    Incoming     = incoming,
                    Amount       = item.Quantity,
                    Sum          = item.Sum,
                    RecordType   = RecordType.Receipt
                };

                _remainNomenclature.Create(recordNomenclature);
                _remainCostPrice.Create(recordCostPrice);
            }

            _repository.Create(incoming);
            _remainNomenclature.RecalcBalances();
            _remainCostPrice.RecalcBalances();
        }
Ejemplo n.º 5
0
        public void Delete(RemainCostPrice item)
        {
            var itemForRemove = _table.Find(n => n == item);

            _table.Remove(itemForRemove);
        }
Ejemplo n.º 6
0
 public void Create(RemainCostPrice item)
 {
     _table.Add(item);
 }