Пример #1
0
        public dynamic GetListBlanket(string _search, long nd, int rows, int?page, string sidx, string sord, string filters = "")
        {
            // Construct where statement

            string strWhere = GeneralFunction.ConstructWhere(filters);

            // Get Data
            int itemtypeId = _itemTypeService.GetObjectByName("Blanket").Id;
            var query      = _itemService.GetAll().Where(d => d.IsDeleted == false && d.ItemTypeId == itemtypeId);

            var list = query as IEnumerable <Item>;

            var pageIndex    = Convert.ToInt32(page) - 1;
            var pageSize     = rows;
            var totalRecords = query.Count();
            var totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            // default last page
            if (totalPages > 0)
            {
                if (!page.HasValue)
                {
                    pageIndex = totalPages - 1;
                    page      = totalPages;
                }
            }

            list = list.Skip(pageIndex * pageSize).Take(pageSize);

            return(Json(new
            {
                total = totalPages,
                page = page,
                records = totalRecords,
                rows = (
                    from model in list
                    select new
                {
                    id = model.Id,
                    cell = new object[] {
                        model.Id,
                        model.Name,
                        model.Sku,
                        model.Category,
                        model.UoMId,
                        _uomService.GetObjectById(model.UoMId).Name,
                        model.Quantity,
                        model.PendingReceival,
                        model.PendingDelivery,
                        model.CreatedAt,
                        model.UpdatedAt
                    }
                }).ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public IList <Item> GetAllAccessories(IItemService _itemService, IItemTypeService _itemTypeService)
        {
            ItemType     itemType = _itemTypeService.GetObjectByName(Core.Constants.Constant.ItemTypeCase.Accessory);
            IList <Item> items    = _repository.GetObjectsByItemTypeId(itemType.Id);

            return(items.ToList());
        }
Пример #3
0
        public IQueryable <Item> GetQueryableAccessories(IItemService _itemService, IItemTypeService _itemTypeService)
        {
            ItemType          itemType = _itemTypeService.GetObjectByName(Core.Constants.Constant.ItemTypeCase.Accessory);
            IQueryable <Item> items    = _repository.GetQueryableObjectsByItemTypeId(itemType.Id);

            return(items);
        }
        public RecoveryAccessoryDetail VIsAccessory(RecoveryAccessoryDetail recoveryAccessoryDetail, IItemService _itemService, IItemTypeService _itemTypeService)
        {
            Item     item     = _itemService.GetObjectById(recoveryAccessoryDetail.ItemId);
            ItemType itemType = _itemTypeService.GetObjectByName(Core.Constants.Constant.ItemTypeCase.Accessory);

            if (item.ItemTypeId != itemType.Id)
            {
                recoveryAccessoryDetail.Errors.Add("ItemId", "Bukan sebuah accessory");
            }
            return(recoveryAccessoryDetail);
        }
Пример #5
0
        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());
                _itemService                  = new ItemService(new ItemRepository(), new ItemValidator());
                _stockAdjustmentService       = new StockAdjustmentService(new StockAdjustmentRepository(), new StockAdjustmentValidator());
                _stockAdjustmentDetailService = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator());
                _accountService               = new AccountService(new AccountRepository(), new AccountValidator());
                _closingService               = new ClosingService(new ClosingRepository(), new ClosingValidator());
                _generalLedgerJournalService  = new GeneralLedgerJournalService(new GeneralLedgerJournalRepository(), new GeneralLedgerJournalValidator());
                _priceMutationService         = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator());
                _contactGroupService          = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator());

                if (!_accountService.GetLegacyObjects().Any())
                {
                    Asset = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Asset", Code = Constant.AccountCode.Asset, LegacyCode = Constant.AccountLegacyCode.Asset, Level = 1, Group = Constant.AccountGroup.Asset, IsLegacy = true
                    }, _accountService);
                    CashBank = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "CashBank", Code = Constant.AccountCode.CashBank, LegacyCode = Constant.AccountLegacyCode.CashBank, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                    }, _accountService);
                    AccountReceivable = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Account Receivable", IsLeaf = true, Code = Constant.AccountCode.AccountReceivable, LegacyCode = Constant.AccountLegacyCode.AccountReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                    }, _accountService);
                    GBCHReceivable = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "GBCH Receivable", IsLeaf = true, Code = Constant.AccountCode.GBCHReceivable, LegacyCode = Constant.AccountLegacyCode.GBCHReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                    }, _accountService);
                    Inventory = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Inventory", IsLeaf = true, Code = Constant.AccountCode.Inventory, LegacyCode = Constant.AccountLegacyCode.Inventory, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                    }, _accountService);

                    Expense = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Expense", Code = Constant.AccountCode.Expense, LegacyCode = Constant.AccountLegacyCode.Expense, Level = 1, Group = Constant.AccountGroup.Expense, IsLegacy = true
                    }, _accountService);
                    CashBankAdjustmentExpense = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "CashBank Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.CashBankAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.CashBankAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                    }, _accountService);
                    COGS = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Cost Of Goods Sold", IsLeaf = true, Code = Constant.AccountCode.COGS, LegacyCode = Constant.AccountLegacyCode.COGS, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                    }, _accountService);
                    Discount = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Discount", IsLeaf = true, Code = Constant.AccountCode.Discount, LegacyCode = Constant.AccountLegacyCode.Discount, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                    }, _accountService);
                    SalesAllowance = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Sales Allowance", IsLeaf = true, Code = Constant.AccountCode.SalesAllowance, LegacyCode = Constant.AccountLegacyCode.SalesAllowance, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                    }, _accountService);
                    StockAdjustmentExpense = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Stock Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.StockAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.StockAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                    }, _accountService);

                    Liability = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Liability", Code = Constant.AccountCode.Liability, LegacyCode = Constant.AccountLegacyCode.Liability, Level = 1, Group = Constant.AccountGroup.Liability, IsLegacy = true
                    }, _accountService);
                    AccountPayable = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Account Payable", IsLeaf = true, Code = Constant.AccountCode.AccountPayable, LegacyCode = Constant.AccountLegacyCode.AccountPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true
                    }, _accountService);
                    GBCHPayable = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "GBCH Payable", IsLeaf = true, Code = Constant.AccountCode.GBCHPayable, LegacyCode = Constant.AccountLegacyCode.GBCHPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true
                    }, _accountService);
                    GoodsPendingClearance = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Goods Pending Clearance", IsLeaf = true, Code = Constant.AccountCode.GoodsPendingClearance, LegacyCode = Constant.AccountLegacyCode.GoodsPendingClearance, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true
                    }, _accountService);

                    Equity = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Equity", Code = Constant.AccountCode.Equity, LegacyCode = Constant.AccountLegacyCode.Equity, Level = 1, Group = Constant.AccountGroup.Equity, IsLegacy = true
                    }, _accountService);
                    OwnersEquity = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Owners Equity", Code = Constant.AccountCode.OwnersEquity, LegacyCode = Constant.AccountLegacyCode.OwnersEquity, Level = 2, Group = Constant.AccountGroup.Equity, ParentId = Equity.Id, IsLegacy = true
                    }, _accountService);
                    EquityAdjustment = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Equity Adjustment", IsLeaf = true, Code = Constant.AccountCode.EquityAdjustment, LegacyCode = Constant.AccountLegacyCode.EquityAdjustment, Level = 3, Group = Constant.AccountGroup.Equity, ParentId = OwnersEquity.Id, IsLegacy = true
                    }, _accountService);

                    Revenue = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Revenue", IsLeaf = true, Code = Constant.AccountCode.Revenue, LegacyCode = Constant.AccountLegacyCode.Revenue, Level = 1, Group = Constant.AccountGroup.Revenue, IsLegacy = true
                    }, _accountService);
                }

                baseGroup = _contactGroupService.CreateObject(Core.Constants.Constant.GroupType.Base, "Base Group", true);

                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, _contactGroupService);

                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, _priceMutationService, _contactGroupService);

                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, _priceMutationService, _contactGroupService);

                StockAdjustment sa = new StockAdjustment()
                {
                    AdjustmentDate = DateTime.Today, WarehouseId = warehouse.Id, Description = "item adjustment"
                };
                _stockAdjustmentService.CreateObject(sa, _warehouseService);
                StockAdjustmentDetail sadItem1 = new StockAdjustmentDetail()
                {
                    ItemId            = item1.Id,
                    Quantity          = 1000,
                    StockAdjustmentId = sa.Id
                };
                _stockAdjustmentDetailService.CreateObject(sadItem1, _stockAdjustmentService, _itemService, _warehouseItemService);

                StockAdjustmentDetail sadItem2 = new StockAdjustmentDetail()
                {
                    ItemId            = item2.Id,
                    Quantity          = 1000,
                    StockAdjustmentId = sa.Id
                };
                _stockAdjustmentDetailService.CreateObject(sadItem2, _stockAdjustmentService, _itemService, _warehouseItemService);

                _stockAdjustmentService.ConfirmObject(sa, DateTime.Today, _stockAdjustmentDetailService, _stockMutationService,
                                                      _itemService, _barringService, _warehouseItemService, _generalLedgerJournalService,
                                                      _accountService, _closingService);
            }
        }
Пример #6
0
        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);
            }
        }
Пример #7
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,
                SellingPrice = 50000,
                AvgPrice     = 50000
            };

            blanket1 = _itemService.CreateObject(blanket1, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService);

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

            blanket2 = _itemService.CreateObject(blanket2, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService);

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

            blanket3 = _itemService.CreateObject(blanket3, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService);

            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, _contactGroupService);

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

            cashBankAdjustment = new CashBankAdjustment()
            {
                CashBankId     = cashBank.Id,
                Amount         = 1000000000,
                AdjustmentDate = DateTime.Today
            };
            _cashBankAdjustmentService.CreateObject(cashBankAdjustment, _cashBankService);
            _cashBankAdjustmentService.ConfirmObject(cashBankAdjustment, DateTime.Now, _cashMutationService, _cashBankService,
                                                     _generalLedgerJournalService, _accountService, _closingService);

            StockAdjustment sa = new StockAdjustment()
            {
                AdjustmentDate = DateTime.Now,
                Code           = "SA001",
                WarehouseId    = localWarehouse.Id
            };

            _stockAdjustmentService.CreateObject(sa, _warehouseService);

            StockAdjustmentDetail sad1 = new StockAdjustmentDetail()
            {
                StockAdjustmentId = sa.Id,
                ItemId            = blanket1.Id,
                Quantity          = 100000,
                Code  = "SAD001",
                Price = 50000
            };

            _stockAdjustmentDetailService.CreateObject(sad1, _stockAdjustmentService, _itemService, _warehouseItemService);

            StockAdjustmentDetail sad2 = new StockAdjustmentDetail()
            {
                StockAdjustmentId = sa.Id,
                ItemId            = blanket2.Id,
                Quantity          = 100000,
                Code  = "SAD002",
                Price = 50000
            };

            _stockAdjustmentDetailService.CreateObject(sad2, _stockAdjustmentService, _itemService, _warehouseItemService);

            StockAdjustmentDetail sad3 = new StockAdjustmentDetail()
            {
                StockAdjustmentId = sa.Id,
                ItemId            = blanket3.Id,
                Quantity          = 100000,
                Code  = "SAD003",
                Price = 50000
            };

            _stockAdjustmentDetailService.CreateObject(sad3, _stockAdjustmentService, _itemService, _warehouseItemService);

            _stockAdjustmentService.ConfirmObject(sa, DateTime.Today, _stockAdjustmentDetailService, _stockMutationService, _itemService, _barringService,
                                                  _warehouseItemService, _generalLedgerJournalService, _accountService, _closingService);
        }
Пример #8
0
        public RollerBuilder CreateObject(RollerBuilder rollerBuilder, IMachineService _machineService, IUoMService _uomService,
                                          IItemService _itemService, IItemTypeService _itemTypeService, ICoreBuilderService _coreBuilderService,
                                          IRollerTypeService _rollerTypeService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService)
        {
            rollerBuilder.Errors = new Dictionary <String, String>();
            ItemType typeRoller = _itemTypeService.GetObjectByName(Core.Constants.Constant.ItemTypeCase.Roller);

            if (typeRoller == null)
            {
                rollerBuilder.Errors.Add("Generic", "ItemType [Roller] Legacy harus dibuat terlebih dahulu");
            }

            Item RollerUsedCore = new Item()
            {
                Name       = rollerBuilder.Name,
                Category   = rollerBuilder.Category,
                UoMId      = rollerBuilder.UoMId,
                Quantity   = 0,
                ItemTypeId = _itemTypeService.GetObjectByName(Core.Constants.Constant.ItemTypeCase.Roller).Id,
                Sku        = rollerBuilder.SkuRollerUsedCore
            };

            RollerUsedCore.Errors = new Dictionary <string, string>();

            Item RollerNewCore = new Item()
            {
                Name       = rollerBuilder.Name,
                Category   = rollerBuilder.Category,
                UoMId      = rollerBuilder.UoMId,
                Quantity   = 0,
                ItemTypeId = _itemTypeService.GetObjectByName(Core.Constants.Constant.ItemTypeCase.Roller).Id,
                Sku        = rollerBuilder.SkuRollerNewCore
            };

            RollerNewCore.Errors = new Dictionary <string, string>();

            if (_itemService.GetValidator().ValidCreateLegacyObject(RollerUsedCore, _uomService, _itemService, _itemTypeService) &&
                _itemService.GetValidator().ValidCreateLegacyObject(RollerNewCore, _uomService, _itemService, _itemTypeService))
            {
                if (_validator.ValidCreateObject(rollerBuilder, this, _machineService, _uomService, _itemService, _coreBuilderService, _rollerTypeService))
                {
                    RollerUsedCore    = _itemService.CreateLegacyObject(RollerUsedCore, _uomService, _itemTypeService, _warehouseItemService, _warehouseService);
                    RollerUsedCore.Id = RollerUsedCore.Id;
                    RollerNewCore     = _itemService.CreateLegacyObject(RollerNewCore, _uomService, _itemTypeService, _warehouseItemService, _warehouseService);
                    RollerNewCore.Id  = RollerNewCore.Id;
                    rollerBuilder.RollerUsedCoreItemId = RollerUsedCore.Id;
                    rollerBuilder.RollerNewCoreItemId  = RollerNewCore.Id;
                    rollerBuilder = _repository.CreateObject(rollerBuilder);
                }
            }
            else
            {
                if (RollerUsedCore.Errors.Count() > 0)
                {
                    rollerBuilder.Errors.Add(RollerUsedCore.Errors.First().Key, RollerUsedCore.Errors.First().Value);
                }
                else if (RollerNewCore.Errors.Count() > 0)
                {
                    rollerBuilder.Errors.Add(RollerNewCore.Errors.First().Key, RollerNewCore.Errors.First().Value);
                }
                else
                {
                    rollerBuilder.Errors.Add("Generic", "Item tidak dapat di update");
                }
            }
            return(rollerBuilder);
        }
Пример #9
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);
        }
Пример #10
0
        public CoreBuilder CreateObject(CoreBuilder coreBuilder, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService,
                                        IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService,
                                        IPriceMutationService _priceMutationService, IContactGroupService _contactGroupService)
        {
            coreBuilder.Errors = new Dictionary <String, String>();

            ItemType typeCore = _itemTypeService.GetObjectByName(Core.Constants.Constant.ItemTypeCase.Core);

            if (typeCore == null)
            {
                coreBuilder.Errors.Add("Generic", "ItemType [Core] Legacy harus dibuat terlebih dahulu");
            }

            Item UsedCore = new Item()
            {
                Name       = coreBuilder.Name,
                Category   = coreBuilder.Category,
                UoMId      = coreBuilder.UoMId,
                Quantity   = 0,
                ItemTypeId = typeCore.Id,
                Sku        = coreBuilder.SkuUsedCore
            };

            UsedCore.Errors = new Dictionary <string, string>();

            Item NewCore = new Item()
            {
                Name       = coreBuilder.Name,
                Category   = coreBuilder.Category,
                UoMId      = coreBuilder.UoMId,
                Quantity   = 0,
                ItemTypeId = typeCore.Id,
                Sku        = coreBuilder.SkuNewCore
            };

            NewCore.Errors = new Dictionary <string, string>();

            if (_itemService.GetValidator().ValidCreateLegacyObject(UsedCore, _uomService, _itemService, _itemTypeService) &&
                _itemService.GetValidator().ValidCreateLegacyObject(NewCore, _uomService, _itemService, _itemTypeService))
            {
                if (_validator.ValidCreateObject(coreBuilder, this, _uomService, _itemService))
                {
                    UsedCore    = _itemService.CreateLegacyObject(UsedCore, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService);
                    UsedCore.Id = UsedCore.Id;
                    NewCore     = _itemService.CreateLegacyObject(NewCore, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService);
                    NewCore.Id  = NewCore.Id;
                    coreBuilder.UsedCoreItemId = UsedCore.Id;
                    coreBuilder.NewCoreItemId  = NewCore.Id;
                    coreBuilder = _repository.CreateObject(coreBuilder);
                }
            }
            else
            {
                if (UsedCore.Errors.Count() > 0)
                {
                    coreBuilder.Errors.Add(UsedCore.Errors.First().Key, UsedCore.Errors.First().Value);
                }
                else if (NewCore.Errors.Count() > 0)
                {
                    coreBuilder.Errors.Add(NewCore.Errors.First().Key, NewCore.Errors.First().Value);
                }
                else
                {
                    coreBuilder.Errors.Add("Generic", "Item tidak dapat di register");
                }
            }
            return(coreBuilder);
        }
Пример #11
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);
            }
        }