Exemplo n.º 1
0
        public dynamic InsertDetail(StockAdjustmentDetail model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.StockAdjustment, Core.Constants.Constant.MenuGroupName.Master))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Edit record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                model = _stockAdjustmentDetailService.CreateObject(model, _stockAdjustmentService, _itemService, _warehouseItemService);
            }
            catch (Exception ex)
            {
                LOG.Error("Insert Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
        public dynamic InsertDetail(StockAdjustmentDetail model)
        {
            try
            {
                model = _stockAdjustmentDetailService.CreateObject(model, _stockAdjustmentService, _itemService, _warehouseItemService);
            }
            catch (Exception ex)
            {
                LOG.Error("Insert Failed", ex);
                model.Errors.Add("Generic", "Error : " + ex);
            }

            return(Json(new
            {
                model.Errors
            }));
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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);
        }