public void StockMutateObject(StockMutation stockMutation, IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
        {
            // decimal stockAdjustmentDetailPrice = (stockMutation.Status == Constant.MutationStatus.Addition) ? stockAdjustmentDetail.Price : ((-1) * stockAdjustmentDetail.Price);
            // item.AvgCost = _barringService.CalculateAvgCost(item, stockAdjustmentDetail.Quantity, stockAdjustmentDetailPrice);
            // barring.AvgCost = _barringService.CalculateAvgCost(barring, stockAdjustmentDetail.Quantity, stockAdjustmentDetailPrice);

            int           Quantity      = (stockMutation.Status == Constant.MutationStatus.Addition) ? stockMutation.Quantity : (-1) * stockMutation.Quantity;
            WarehouseItem warehouseItem = _warehouseItemService.GetObjectById(stockMutation.WarehouseItemId);
            Item          item          = _itemService.GetObjectById(stockMutation.ItemId);
            Barring       barring       = _barringService.GetObjectById(stockMutation.ItemId);

            if (warehouseItem != null)
            {
                if (stockMutation.ItemCase == Constant.ItemCase.Ready)
                {
                    _warehouseItemService.AdjustQuantity(warehouseItem, Quantity);
                }
            }

            if (barring == null)
            {
                // itemService in action
                if (stockMutation.ItemCase == Constant.ItemCase.Ready)
                {
                    _itemService.AdjustQuantity(item, Quantity);
                }
                else if (stockMutation.ItemCase == Constant.ItemCase.PendingDelivery)
                {
                    _itemService.AdjustPendingDelivery(item, Quantity);
                }
                else if (stockMutation.ItemCase == Constant.ItemCase.PendingReceival)
                {
                    _itemService.AdjustPendingReceival(item, Quantity);
                }
            }
            else
            {
                // barringService in action
                if (stockMutation.ItemCase == Constant.ItemCase.Ready)
                {
                    _barringService.AdjustQuantity(barring, Quantity);
                }
                else if (stockMutation.ItemCase == Constant.ItemCase.PendingDelivery)
                {
                    _barringService.AdjustPendingDelivery(barring, Quantity);
                }
                else if (stockMutation.ItemCase == Constant.ItemCase.PendingReceival)
                {
                    _barringService.AdjustPendingReceival(barring, Quantity);
                }
            }
        }
        void before_each()
        {
            var db = new OffsetPrintingSuppliesEntities();

            using (db)
            {
                db.DeleteAllTables();
                itemService           = new ItemService(new ItemRepository(), new ItemValidator());
                contactService        = new ContactService(new ContactRepository(), new ContactValidator());
                poService             = new PurchaseOrderService(new PurchaseOrderRepository(), new PurchaseOrderValidator());
                poDetailService       = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator());
                stockMutationService  = new StockMutationService(new StockMutationRepository(), new StockMutationValidator());
                _itemTypeService      = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator());
                _uomService           = new UoMService(new UoMRepository(), new UoMValidator());
                _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator());
                _warehouseService     = new WarehouseService(new WarehouseRepository(), new WarehouseValidator());
                _barringService       = new BarringService(new BarringRepository(), new BarringValidator());

                Pcs = new UoM()
                {
                    Name = "Pcs"
                };
                _uomService.CreateObject(Pcs);

                contact = new Contact()
                {
                    Name         = "President of Indonesia",
                    Address      = "Istana Negara Jl. Veteran No. 16 Jakarta Pusat",
                    ContactNo    = "021 3863777",
                    PIC          = "Mr. President",
                    PICContactNo = "021 3863777",
                    Email        = "*****@*****.**"
                };
                contact = contactService.CreateObject(contact);

                type = _itemTypeService.CreateObject("Item", "Item");

                warehouse = new Warehouse()
                {
                    Name        = "Sentral Solusi Data",
                    Description = "Kali Besar Jakarta",
                    Code        = "LCL"
                };
                warehouse = _warehouseService.CreateObject(warehouse, _warehouseItemService, itemService);

                item1 = new Item()
                {
                    ItemTypeId = _itemTypeService.GetObjectByName("Item").Id,
                    Name       = "Batik Tulis",
                    Category   = "Item",
                    Sku        = "bt123",
                    UoMId      = Pcs.Id
                };
                itemService.CreateObject(item1, _uomService, _itemTypeService, _warehouseItemService, _warehouseService);
                itemService.AdjustQuantity(item1, 1000);
                _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(warehouse.Id, item1.Id), 1000);

                item2 = new Item()
                {
                    ItemTypeId = _itemTypeService.GetObjectByName("Item").Id,
                    Name       = "Buku Gambar",
                    Category   = "Item",
                    Sku        = "bg123",
                    UoMId      = Pcs.Id
                };
                itemService.CreateObject(item2, _uomService, _itemTypeService, _warehouseItemService, _warehouseService);
                itemService.AdjustQuantity(item2, 1000);
                _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(warehouse.Id, item2.Id), 1000);
            }
        }
Beispiel #3
0
        public void PopulateMasterData()
        {
            localWarehouse = new Warehouse()
            {
                Name        = "Sentral Solusi Data",
                Description = "Kali Besar Jakarta",
                Code        = "LCL"
            };
            localWarehouse = _warehouseService.CreateObject(localWarehouse, _warehouseItemService, _itemService);

            Pcs = new UoM()
            {
                Name = "Pcs"
            };
            _uomService.CreateObject(Pcs);

            Boxes = new UoM()
            {
                Name = "Boxes"
            };
            _uomService.CreateObject(Boxes);

            Tubs = new UoM()
            {
                Name = "Tubs"
            };
            _uomService.CreateObject(Tubs);

            blanket1 = new Item()
            {
                ItemTypeId = _itemTypeService.GetObjectByName("Blanket").Id,
                Name       = "Blanket1",
                Category   = "Blanket",
                Sku        = "BLK1",
                UoMId      = Pcs.Id
            };

            blanket1 = _itemService.CreateObject(blanket1, _uomService, _itemTypeService, _warehouseItemService, _warehouseService);
            _itemService.AdjustQuantity(blanket1, 100000);
            _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(localWarehouse.Id, blanket1.Id), 100000);

            blanket2 = new Item()
            {
                ItemTypeId = _itemTypeService.GetObjectByName("Blanket").Id,
                Name       = "Blanket2",
                Category   = "Blanket",
                Sku        = "BLK2",
                UoMId      = Pcs.Id
            };

            blanket2 = _itemService.CreateObject(blanket2, _uomService, _itemTypeService, _warehouseItemService, _warehouseService);
            _itemService.AdjustQuantity(blanket2, 100000);
            _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(localWarehouse.Id, blanket2.Id), 100000);

            blanket3 = new Item()
            {
                ItemTypeId = _itemTypeService.GetObjectByName("Blanket").Id,
                Name       = "Blanket3",
                Category   = "Blanket",
                Sku        = "BLK3",
                UoMId      = Pcs.Id
            };

            blanket3 = _itemService.CreateObject(blanket3, _uomService, _itemTypeService, _warehouseItemService, _warehouseService);
            _itemService.AdjustQuantity(blanket3, 100000);
            _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(localWarehouse.Id, blanket3.Id), 100000);

            contact = new Contact()
            {
                Name         = "President of Indonesia",
                Address      = "Istana Negara Jl. Veteran No. 16 Jakarta Pusat",
                ContactNo    = "021 3863777",
                PIC          = "Mr. President",
                PICContactNo = "021 3863777",
                Email        = "*****@*****.**"
            };
            contact = _contactService.CreateObject(contact);

            cashBank = new CashBank()
            {
                Name        = "Rekening BRI",
                Description = "Untuk cashflow"
            };
            _cashBankService.CreateObject(cashBank);

            cashBankAdjustment = new CashBankAdjustment()
            {
                CashBankId     = cashBank.Id,
                Amount         = 1000000000,
                AdjustmentDate = DateTime.Today
            };
            _cashBankAdjustmentService.CreateObject(cashBankAdjustment, _cashBankService);
            _cashBankAdjustmentService.ConfirmObject(cashBankAdjustment, DateTime.Now, _cashMutationService, _cashBankService);
        }
Beispiel #4
0
        void before_each()
        {
            var db = new OffsetPrintingSuppliesEntities();

            using (db)
            {
                db.DeleteAllTables();
                _contactService                = new ContactService(new ContactRepository(), new ContactValidator());
                _itemService                   = new ItemService(new ItemRepository(), new ItemValidator());
                _stockMutationService          = new StockMutationService(new StockMutationRepository(), new StockMutationValidator());
                _purchaseInvoiceService        = new PurchaseInvoiceService(new PurchaseInvoiceRepository(), new PurchaseInvoiceValidator());
                _purchaseInvoiceDetailService  = new PurchaseInvoiceDetailService(new PurchaseInvoiceDetailRepository(), new PurchaseInvoiceDetailValidator());
                _purchaseOrderService          = new PurchaseOrderService(new PurchaseOrderRepository(), new PurchaseOrderValidator());
                _purchaseOrderDetailService    = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator());
                _purchaseReceivalService       = new PurchaseReceivalService(new PurchaseReceivalRepository(), new PurchaseReceivalValidator());
                _purchaseReceivalDetailService = new PurchaseReceivalDetailService(new PurchaseReceivalDetailRepository(), new PurchaseReceivalDetailValidator());
                _stockAdjustmentService        = new StockAdjustmentService(new StockAdjustmentRepository(), new StockAdjustmentValidator());
                _stockAdjustmentDetailService  = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator());
                _itemTypeService               = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator());
                _uomService           = new UoMService(new UoMRepository(), new UoMValidator());
                _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator());
                _warehouseService     = new WarehouseService(new WarehouseRepository(), new WarehouseValidator());
                _barringService       = new BarringService(new BarringRepository(), new BarringValidator());

                Pcs = new UoM()
                {
                    Name = "Pcs"
                };
                _uomService.CreateObject(Pcs);

                contact = new Contact()
                {
                    Name         = "President of Indonesia",
                    Address      = "Istana Negara Jl. Veteran No. 16 Jakarta Pusat",
                    ContactNo    = "021 3863777",
                    PIC          = "Mr. President",
                    PICContactNo = "021 3863777",
                    Email        = "*****@*****.**"
                };
                contact = _contactService.CreateObject(contact);

                type = _itemTypeService.CreateObject("Item", "Item");

                warehouse = new Warehouse()
                {
                    Name        = "Sentral Solusi Data",
                    Description = "Kali Besar Jakarta",
                    Code        = "LCL"
                };
                warehouse = _warehouseService.CreateObject(warehouse, _warehouseItemService, _itemService);

                item_batiktulis = new Item()
                {
                    ItemTypeId = _itemTypeService.GetObjectByName("Item").Id,
                    Name       = "Batik Tulis",
                    Category   = "Item",
                    Sku        = "bt123",
                    UoMId      = Pcs.Id
                };

                item_batiktulis = _itemService.CreateObject(item_batiktulis, _uomService, _itemTypeService, _warehouseItemService, _warehouseService);
                _itemService.AdjustQuantity(item_batiktulis, 1000);
                _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(warehouse.Id, item_batiktulis.Id), 1000);

                item_busway = new Item()
                {
                    ItemTypeId = _itemTypeService.GetObjectByName("Item").Id,
                    Name       = "Busway",
                    Category   = "Untuk disumbangkan bagi kebutuhan DKI Jakarta",
                    Sku        = "DKI002",
                    UoMId      = Pcs.Id
                };
                item_busway = _itemService.CreateObject(item_busway, _uomService, _itemTypeService, _warehouseItemService, _warehouseService);
                _itemService.AdjustQuantity(item_busway, 200);
                _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(warehouse.Id, item_busway.Id), 200);

                item_botolaqua = new Item()
                {
                    ItemTypeId = _itemTypeService.GetObjectByName("Item").Id,
                    Name       = "Botol Aqua",
                    Category   = "Minuman",
                    Sku        = "DKI003",
                    UoMId      = Pcs.Id
                };
                item_botolaqua = _itemService.CreateObject(item_botolaqua, _uomService, _itemTypeService, _warehouseItemService, _warehouseService);
                _itemService.AdjustQuantity(item_botolaqua, 20000);
                _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(warehouse.Id, item_botolaqua.Id), 20000);

                purchaseOrder1 = _purchaseOrderService.CreateObject(contact.Id, new DateTime(2014, 07, 09), _contactService);
                purchaseOrder2 = _purchaseOrderService.CreateObject(contact.Id, new DateTime(2014, 04, 09), _contactService);
                purchaseOrderDetail_batiktulis_so1 = _purchaseOrderDetailService.CreateObject(purchaseOrder1.Id, item_batiktulis.Id, 500, 2000000, _purchaseOrderService, _itemService);
                purchaseOrderDetail_busway_so1     = _purchaseOrderDetailService.CreateObject(purchaseOrder1.Id, item_busway.Id, 91, 800000000, _purchaseOrderService, _itemService);
                purchaseOrderDetail_botolaqua_so1  = _purchaseOrderDetailService.CreateObject(purchaseOrder1.Id, item_botolaqua.Id, 2000, 5000, _purchaseOrderService, _itemService);
                purchaseOrderDetail_batiktulis_so2 = _purchaseOrderDetailService.CreateObject(purchaseOrder2.Id, item_batiktulis.Id, 40, 2000500, _purchaseOrderService, _itemService);
                purchaseOrderDetail_busway_so2     = _purchaseOrderDetailService.CreateObject(purchaseOrder2.Id, item_busway.Id, 3, 810000000, _purchaseOrderService, _itemService);
                purchaseOrderDetail_botolaqua_so2  = _purchaseOrderDetailService.CreateObject(purchaseOrder2.Id, item_botolaqua.Id, 340, 5500, _purchaseOrderService, _itemService);
                purchaseOrder1 = _purchaseOrderService.ConfirmObject(purchaseOrder1, DateTime.Today, _purchaseOrderDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService);
                purchaseOrder2 = _purchaseOrderService.ConfirmObject(purchaseOrder2, DateTime.Today, _purchaseOrderDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService);
            }
        }