public dynamic InsertDetail(PurchaseOrderDetail model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.PurchaseOrder, Core.Constants.Constant.MenuGroupName.Transaction))
                {
                    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 = _purchaseOrderDetailService.CreateObject(model, _purchaseOrderService, _itemService);
            }
            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
            }));
        }
Exemple #2
0
        public dynamic InsertDetail(PurchaseOrderDetail model)
        {
            try
            {
                model = _purchaseOrderDetailService.CreateObject(model, _purchaseOrderService, _itemService);
            }
            catch (Exception ex)
            {
                LOG.Error("Insert Failed", ex);
                model.Errors.Add("Generic", "Error : " + ex);
            }

            return(Json(new
            {
                model.Errors
            }));
        }
Exemple #3
0
        void po_validation()
        {
            it["prepares_valid_data"] = () =>
            {
                item1.Errors.Count().should_be(0);
                item2.Errors.Count().should_be(0);
                contact.Errors.Count().should_be(0);
            };

            it["creates_po"] = () =>
            {
                newPO = new PurchaseOrder
                {
                    ContactId    = contact.Id,
                    PurchaseDate = DateTime.Now
                };
                newPO = poService.CreateObject(newPO, contactService);
                newPO.Errors.Count().should_be(0);
                poService.GetObjectById(newPO.Id).should_not_be_null();
            };

            context["when creating PO Detail"] = () =>
            {
                before = () =>
                {
                    newPO = new PurchaseOrder
                    {
                        ContactId    = contact.Id,
                        PurchaseDate = DateTime.Now
                    };
                    newPO = poService.CreateObject(newPO, contactService);
                };

                it["creates po detail"] = () =>
                {
                    PurchaseOrderDetail poDetail = new PurchaseOrderDetail
                    {
                        PurchaseOrderId = newPO.Id,
                        ItemId          = item1.Id,
                        Quantity        = 5,
                        Price           = 30000
                    };
                    poDetail = poDetailService.CreateObject(poDetail, poService, itemService);
                    poDetail.Errors.Count().should_be(0);
                };

                it["must not allow PO confirmation if there is no PO Detail"] = () =>
                {
                    newPO = poService.ConfirmObject(newPO, DateTime.Today, poDetailService, _stockMutationService, itemService, _barringService, _warehouseItemService);
                    newPO.Errors.Count().should_not_be(0);
                };

                it["should not create po detail if there is no item id"] = () =>
                {
                    PurchaseOrderDetail poDetail = new PurchaseOrderDetail
                    {
                        PurchaseOrderId = newPO.Id,
                        ItemId          = 0,
                        Quantity        = 5,
                        Price           = 25000
                    };
                    poDetail = poDetailService.CreateObject(poDetail, poService, itemService);
                    poDetail.Errors.Count().should_not_be(0);
                };

                context["when creating PO Detail"] = () =>
                {
                    before = () =>
                    {
                        poDetail1 = new PurchaseOrderDetail
                        {
                            PurchaseOrderId = newPO.Id,
                            ItemId          = item1.Id,
                            Quantity        = 5,
                            Price           = 30000
                        };
                        poDetail1 = poDetailService.CreateObject(poDetail1, poService, itemService);
                    };

                    it["should be valid when creating PO Detail 1"] = () =>
                    {
                        poDetail1.Errors.Count.should_be(0);
                    };

                    it["should not be valid when creating PO Detail 2 with the same item"] = () =>
                    {
                        poDetail2 = new PurchaseOrderDetail
                        {
                            PurchaseOrderId = newPO.Id,
                            ItemId          = item1.Id,
                            Quantity        = 5,
                            Price           = 2500000
                        };
                        poDetail2 = poDetailService.CreateObject(poDetail2, poService, itemService);
                        poDetail2.Errors.Count().should_not_be(0);
                    };

                    context["should not be valid when creating PO Detail 2 with the same item"] = () =>
                    {
                        before = () =>
                        {
                            poDetail2 = new PurchaseOrderDetail
                            {
                                PurchaseOrderId = newPO.Id,
                                ItemId          = item2.Id,
                                Quantity        = 5,
                                Price           = 2500000
                            };
                            poDetail2 = poDetailService.CreateObject(poDetail2, poService, itemService);
                        };

                        it["should be valid when creating a new PO Detail 2"] = () =>
                        {
                            poDetail2.Errors.Count().should_be(0);
                        };

                        it["should not be valid when updating PO Detail 2 item to the same item as POD1"] = () =>
                        {
                            poDetail2.ItemId = item1.Id;
                            poDetailService.UpdateObject(poDetail2, poService, itemService);
                            poDetail2.Errors.Count().should_not_be(0);
                        };
                    };
                };
            };

            context["when confirming PO"] = () =>
            {
                before = () =>
                {
                    newPO = new PurchaseOrder
                    {
                        ContactId    = contact.Id,
                        PurchaseDate = DateTime.Now
                    };
                    newPO = poService.CreateObject(newPO, contactService);

                    poDetail1 = new PurchaseOrderDetail
                    {
                        PurchaseOrderId = newPO.Id,
                        ItemId          = item1.Id,
                        Quantity        = 5,
                        Price           = 30000
                    };
                    poDetail1 = poDetailService.CreateObject(poDetail1, poService, itemService);

                    poDetail2 = new PurchaseOrderDetail
                    {
                        PurchaseOrderId = newPO.Id,
                        ItemId          = item2.Id,
                        Quantity        = 5,
                        Price           = 25000
                    };
                    poDetail2 = poDetailService.CreateObject(poDetail2, poService, itemService);
                };

                it["allows confirmation"] = () =>
                {
                    newPO = poService.ConfirmObject(newPO, DateTime.Today, poDetailService, _stockMutationService, itemService, _barringService, _warehouseItemService);
                    newPO.IsConfirmed.should_be(true);
                };

                context["post PO confirm"] = () =>
                {
                    before = () =>
                    {
                        item1     = itemService.GetObjectById(item1.Id);
                        item2     = itemService.GetObjectById(item2.Id);
                        Quantity1 = item1.PendingReceival;
                        Quantity2 = item2.PendingReceival;

                        newPO = poService.ConfirmObject(newPO, DateTime.Today, poDetailService, _stockMutationService, itemService, _barringService, _warehouseItemService);
                    };

                    it["should increase pending receival in item"] = () =>
                    {
                        int diff_1 = item1.PendingReceival - Quantity1;
                        diff_1.should_be(poDetail1.Quantity);

                        int diff_2 = item2.PendingReceival - Quantity2;
                        diff_2.should_be(poDetail2.Quantity);
                    };

                    it["should create StockMutation"] = () =>
                    {
                        _stockMutationService.GetObjectsBySourceDocumentDetailForItem(item1.Id, Core.Constants.Constant.SourceDocumentDetailType.PurchaseOrderDetail, poDetail1.Id).Count().should_be(1);
                        _stockMutationService.GetObjectsBySourceDocumentDetailForItem(item2.Id, Core.Constants.Constant.SourceDocumentDetailType.PurchaseOrderDetail, poDetail2.Id).Count().should_be(1);
                    };
                };
            };
        }
Exemple #4
0
        public void PopulateOrderAndReceivalData()
        {
            TimeSpan purchaseDate     = new TimeSpan(10, 0, 0, 0);
            TimeSpan receivedDate     = new TimeSpan(3, 0, 0, 0);
            TimeSpan lateReceivedDate = new TimeSpan(2, 0, 0, 0);

            po1 = new PurchaseOrder()
            {
                PurchaseDate = DateTime.Today.Subtract(purchaseDate),
                ContactId    = contact.Id
            };
            _purchaseOrderService.CreateObject(po1, _contactService);

            po2 = new PurchaseOrder()
            {
                PurchaseDate = DateTime.Today.Subtract(purchaseDate),
                ContactId    = contact.Id
            };
            _purchaseOrderService.CreateObject(po2, _contactService);

            po1a = new PurchaseOrderDetail()
            {
                ItemId          = blanket1.Id,
                PurchaseOrderId = po1.Id,
                Quantity        = 300,
                Price           = 50000
            };
            _purchaseOrderDetailService.CreateObject(po1a, _purchaseOrderService, _itemService);

            po1b = new PurchaseOrderDetail()
            {
                ItemId          = blanket2.Id,
                PurchaseOrderId = po1.Id,
                Quantity        = 250,
                Price           = 72000
            };
            _purchaseOrderDetailService.CreateObject(po1b, _purchaseOrderService, _itemService);

            po1c = new PurchaseOrderDetail()
            {
                ItemId          = blanket3.Id,
                PurchaseOrderId = po1.Id,
                Quantity        = 100,
                Price           = 100000
            };
            _purchaseOrderDetailService.CreateObject(po1c, _purchaseOrderService, _itemService);

            po2a = new PurchaseOrderDetail()
            {
                ItemId          = blanket1.Id,
                PurchaseOrderId = po2.Id,
                Quantity        = 300,
                Price           = 50000
            };
            _purchaseOrderDetailService.CreateObject(po2a, _purchaseOrderService, _itemService);

            po2b = new PurchaseOrderDetail()
            {
                ItemId          = blanket2.Id,
                PurchaseOrderId = po2.Id,
                Quantity        = 250,
                Price           = 72000
            };
            _purchaseOrderDetailService.CreateObject(po2b, _purchaseOrderService, _itemService);

            _purchaseOrderService.ConfirmObject(po1, po1.PurchaseDate, _purchaseOrderDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService);
            _purchaseOrderService.ConfirmObject(po2, po2.PurchaseDate, _purchaseOrderDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService);

            pr1 = new PurchaseReceival()
            {
                PurchaseOrderId = po1.Id,
                ReceivalDate    = DateTime.Now.Subtract(receivedDate),
                WarehouseId     = localWarehouse.Id
            };
            _purchaseReceivalService.CreateObject(pr1, _purchaseOrderService, _warehouseService);

            pr2 = new PurchaseReceival()
            {
                PurchaseOrderId = po2.Id,
                ReceivalDate    = DateTime.Now.Subtract(receivedDate),
                WarehouseId     = localWarehouse.Id
            };
            _purchaseReceivalService.CreateObject(pr2, _purchaseOrderService, _warehouseService);

            pr1a = new PurchaseReceivalDetail()
            {
                PurchaseOrderDetailId = po1a.Id,
                PurchaseReceivalId    = pr1.Id,
                ItemId   = po1a.ItemId,
                Quantity = po1a.Quantity - 100
            };
            _purchaseReceivalDetailService.CreateObject(pr1a, _purchaseReceivalService, _purchaseOrderDetailService, _purchaseOrderService, _itemService);

            pr1b = new PurchaseReceivalDetail()
            {
                PurchaseOrderDetailId = po1b.Id,
                PurchaseReceivalId    = pr1.Id,
                ItemId   = po1b.ItemId,
                Quantity = po1b.Quantity
            };
            _purchaseReceivalDetailService.CreateObject(pr1b, _purchaseReceivalService, _purchaseOrderDetailService, _purchaseOrderService, _itemService);

            pr2a = new PurchaseReceivalDetail()
            {
                PurchaseOrderDetailId = po2a.Id,
                PurchaseReceivalId    = pr2.Id,
                ItemId   = po2a.ItemId,
                Quantity = po2a.Quantity
            };
            _purchaseReceivalDetailService.CreateObject(pr2a, _purchaseReceivalService, _purchaseOrderDetailService, _purchaseOrderService, _itemService);

            pr2b = new PurchaseReceivalDetail()
            {
                PurchaseOrderDetailId = po2b.Id,
                PurchaseReceivalId    = pr2.Id,
                ItemId   = po2b.ItemId,
                Quantity = po2b.Quantity
            };
            _purchaseReceivalDetailService.CreateObject(pr2b, _purchaseReceivalService, _purchaseOrderDetailService, _purchaseOrderService, _itemService);

            pr3 = new PurchaseReceival()
            {
                PurchaseOrderId = po1.Id,
                ReceivalDate    = DateTime.Now.Subtract(lateReceivedDate),
                WarehouseId     = localWarehouse.Id
            };
            _purchaseReceivalService.CreateObject(pr3, _purchaseOrderService, _warehouseService);

            pr1c = new PurchaseReceivalDetail()
            {
                PurchaseReceivalId    = pr3.Id,
                PurchaseOrderDetailId = po1c.Id,
                Quantity = po1c.Quantity,
                ItemId   = po1c.ItemId
            };
            _purchaseReceivalDetailService.CreateObject(pr1c, _purchaseReceivalService, _purchaseOrderDetailService, _purchaseOrderService, _itemService);

            pr1a2 = new PurchaseReceivalDetail()
            {
                PurchaseReceivalId    = pr3.Id,
                PurchaseOrderDetailId = po1a.Id,
                Quantity = 100,
                ItemId   = po1a.ItemId
            };
            _purchaseReceivalDetailService.CreateObject(pr1a2, _purchaseReceivalService, _purchaseOrderDetailService, _purchaseOrderService, _itemService);
        }
        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());

                _priceMutationService        = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator());
                _contactGroupService         = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator());
                _accountService              = new AccountService(new AccountRepository(), new AccountValidator());
                _generalLedgerJournalService = new GeneralLedgerJournalService(new GeneralLedgerJournalRepository(), new GeneralLedgerJournalValidator());
                _closingService              = new ClosingService(new ClosingRepository(), new ClosingValidator());

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

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

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

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

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

                StockAdjustmentDetail sadBusWay = new StockAdjustmentDetail()
                {
                    ItemId            = item_busway.Id,
                    Quantity          = 200,
                    StockAdjustmentId = sa.Id
                };
                _stockAdjustmentDetailService.CreateObject(sadBusWay, _stockAdjustmentService, _itemService, _warehouseItemService);

                StockAdjustmentDetail sadBotolAqua = new StockAdjustmentDetail()
                {
                    ItemId            = item_botolaqua.Id,
                    Quantity          = 20000,
                    StockAdjustmentId = sa.Id
                };
                _stockAdjustmentDetailService.CreateObject(sadBotolAqua, _stockAdjustmentService, _itemService, _warehouseItemService);

                _stockAdjustmentService.ConfirmObject(sa, DateTime.Today, _stockAdjustmentDetailService, _stockMutationService,
                                                      _itemService, _barringService, _warehouseItemService, _generalLedgerJournalService, _accountService, _closingService);


                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);
            }
        }
Exemple #6
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);
            }
        }