public bool ValidUnconfirmObject(RollerWarehouseMutationDetail rollerWarehouseMutationDetail, IRollerWarehouseMutationService _rollerWarehouseMutationService,
                                  IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     rollerWarehouseMutationDetail.Errors.Clear();
     VUnconfirmObject(rollerWarehouseMutationDetail, _rollerWarehouseMutationService, _itemService, _barringService, _warehouseItemService);
     return(isValid(rollerWarehouseMutationDetail));
 }
Beispiel #2
0
 public PurchaseReceivalDetail UnconfirmObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalService _purchaseReceivalService,
                                               IPurchaseOrderService _purchaseOrderService, IPurchaseOrderDetailService _purchaseOrderDetailService,
                                               IPurchaseInvoiceDetailService _purchaseInvoiceDetailService, IStockMutationService _stockMutationService,
                                               IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     if (_validator.ValidUnconfirmObject(purchaseReceivalDetail, _purchaseInvoiceDetailService, _itemService))
     {
         purchaseReceivalDetail = _repository.UnconfirmObject(purchaseReceivalDetail);
         PurchaseReceival      purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseReceivalDetail.PurchaseReceivalId);
         WarehouseItem         warehouseItem    = _warehouseItemService.FindOrCreateObject(purchaseReceival.WarehouseId, purchaseReceivalDetail.ItemId);
         Item                  item             = _itemService.GetObjectById(purchaseReceivalDetail.ItemId);
         IList <StockMutation> stockMutations   = _stockMutationService.SoftDeleteStockMutationForPurchaseReceival(purchaseReceivalDetail, warehouseItem);
         foreach (var stockMutation in stockMutations)
         {
             //decimal itemPrice = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId).Price;
             //item.AvgCost = _itemService.CalculateAvgCost(item, purchaseReceivalDetail.Quantity * (-1), itemPrice);
             //item.PendingReceival += purchaseReceivalDetail.Quantity;
             //item.Quantity -= purchaseReceivalDetail.Quantity;
             _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
         }
         PurchaseOrderDetail purchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId);
         _purchaseOrderDetailService.UnsetReceivalComplete(purchaseOrderDetail, purchaseReceivalDetail.Quantity, _purchaseOrderService);
     }
     return(purchaseReceivalDetail);
 }
Beispiel #3
0
 public bool ValidUnconfirmObject(StockAdjustment stockAdjustment, IStockAdjustmentService _stockAdjustmentService, IStockAdjustmentDetailService _stockAdjustmentDetailService,
                                  IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService, IClosingService _closingService)
 {
     stockAdjustment.Errors.Clear();
     VUnconfirmObject(stockAdjustment, _stockAdjustmentService, _stockAdjustmentDetailService, _itemService, _barringService, _warehouseItemService, _closingService);
     return(isValid(stockAdjustment));
 }
Beispiel #4
0
 public StockAdjustment VConfirmObject(StockAdjustment stockAdjustment, IStockAdjustmentService _stockAdjustmentService, IStockAdjustmentDetailService _stockAdjustmentDetailService,
                                       IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService, IClosingService _closingService)
 {
     VHasConfirmationDate(stockAdjustment);
     if (!isValid(stockAdjustment))
     {
         return(stockAdjustment);
     }
     VHasNotBeenConfirmed(stockAdjustment);
     if (!isValid(stockAdjustment))
     {
         return(stockAdjustment);
     }
     VHasStockAdjustmentDetails(stockAdjustment, _stockAdjustmentDetailService);
     if (!isValid(stockAdjustment))
     {
         return(stockAdjustment);
     }
     VDetailsAreVerifiedConfirmable(stockAdjustment, _stockAdjustmentService, _stockAdjustmentDetailService, _itemService, _barringService, _warehouseItemService);
     if (!isValid(stockAdjustment))
     {
         return(stockAdjustment);
     }
     VGeneralLedgerPostingHasNotBeenClosed(stockAdjustment, _closingService, 1);
     return(stockAdjustment);
 }
Beispiel #5
0
 public PurchaseReceivalDetail ConfirmObject(PurchaseReceivalDetail purchaseReceivalDetail, DateTime ConfirmationDate, IPurchaseReceivalService _purchaseReceivalService,
                                             IPurchaseOrderDetailService _purchaseOrderDetailService, IStockMutationService _stockMutationService,
                                             IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     purchaseReceivalDetail.ConfirmationDate = ConfirmationDate;
     if (_validator.ValidConfirmObject(purchaseReceivalDetail, this, _purchaseOrderDetailService))
     {
         purchaseReceivalDetail = _repository.ConfirmObject(purchaseReceivalDetail);
         PurchaseReceival      purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseReceivalDetail.PurchaseReceivalId);
         WarehouseItem         warehouseItem    = _warehouseItemService.FindOrCreateObject(purchaseReceival.WarehouseId, purchaseReceivalDetail.ItemId);
         Item                  item             = _itemService.GetObjectById(purchaseReceivalDetail.ItemId);
         IList <StockMutation> stockMutations   = _stockMutationService.CreateStockMutationForPurchaseReceival(purchaseReceivalDetail, warehouseItem);
         foreach (var stockMutation in stockMutations)
         {
             // decimal itemPrice = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId).Price;
             // item.AvgCost = _itemService.CalculateAvgCost(item, purchaseReceivalDetail.Quantity, itemPrice);
             //item.PendingReceival -= purchaseReceivalDetail.Quantity;
             //item.Quantity += purchaseReceivalDetail.Quantity;
             _stockMutationService.StockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
         }
         PurchaseOrderDetail purchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId);
         _purchaseOrderDetailService.SetReceivalComplete(purchaseOrderDetail, purchaseReceivalDetail.Quantity);
     }
     return(purchaseReceivalDetail);
 }
Beispiel #6
0
        public Item UpdateLegacyObject(Item item, IUoMService _uomService, IItemTypeService _itemTypeService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService,
                                       IBarringService _barringService, IContactService _contactService, IMachineService _machineService,
                                       IPriceMutationService _priceMutationService, IContactGroupService _contactGroupService)
        {
            Barring barring = _barringService.GetObjectById(item.Id);

            if (barring != null)
            {
                _barringService.UpdateObject(barring, _barringService, _uomService, this, _itemTypeService,
                                             _contactService, _machineService, _warehouseItemService, _warehouseService,
                                             _contactGroupService, _priceMutationService);
                return(barring);
            }

            if (_validator.ValidUpdateLegacyObject(item, _uomService, this, _itemTypeService))
            {
                ContactGroup  contactGroup     = _contactGroupService.GetObjectByIsLegacy(true);
                Item          olditem          = _repository.GetObjectById(item.Id); // Note: olditem might be pointing to the same memory with item (share the same contents)
                PriceMutation oldpriceMutation = _priceMutationService.GetObjectById(item.PriceMutationId);
                if (olditem.SellingPrice != item.SellingPrice)
                {
                    DateTime      priceMutationTimeStamp = DateTime.Now;
                    PriceMutation priceMutation          = _priceMutationService.CreateObject(item, /*contactGroup,*/ priceMutationTimeStamp);
                    item.PriceMutationId = priceMutation.Id;
                    _priceMutationService.DeactivateObject(oldpriceMutation, priceMutationTimeStamp);
                }
                item = _repository.UpdateObject(item);
            }
            return(item);
        }
Beispiel #7
0
 public bool ValidUpdateObject(Barring barring, IBarringService _barringService, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService,
                               IContactService _contactService, IMachineService _machineService)
 {
     barring.Errors.Clear();
     VUpdateObject(barring, _barringService, _uomService, _itemService, _itemTypeService, _contactService, _machineService);
     return(isValid(barring));
 }
 public bool ValidUnconfirmObject(WarehouseMutationOrderDetail warehouseMutationOrderDetail, IWarehouseMutationOrderService _warehouseMutationOrderService,
                                  IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     warehouseMutationOrderDetail.Errors.Clear();
     VUnconfirmObject(warehouseMutationOrderDetail, _warehouseMutationOrderService, _itemService, _barringService, _warehouseItemService);
     return(isValid(warehouseMutationOrderDetail));
 }
Beispiel #9
0
 public Barring UpdateObject(Barring barring, IBarringService _barringService, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService,
                             IContactService _contactService, IMachineService _machineService,
                             IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService)
 {
     return(barring = _validator.ValidUpdateObject(barring, _barringService, _uomService, _itemService, _itemTypeService, _contactService, _machineService) ?
                      _repository.UpdateObject(barring) : barring);
 }
 public bool ValidConfirmObject(StockAdjustmentDetail stockAdjustmentDetail, IStockAdjustmentService _stockAdjustmentService,
                                IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     stockAdjustmentDetail.Errors.Clear();
     VConfirmObject(stockAdjustmentDetail, _stockAdjustmentService, _itemService, _barringService, _warehouseItemService);
     return(isValid(stockAdjustmentDetail));
 }
 public CustomPurchaseInvoiceController()
 {
     _contactService                     = new ContactService(new ContactRepository(), new ContactValidator());
     _itemService                        = new ItemService(new ItemRepository(), new ItemValidator());
     _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());
     _stockMutationService               = new StockMutationService(new StockMutationRepository(), new StockMutationValidator());
     _barringService                     = new BarringService(new BarringRepository(), new BarringValidator());
     _priceMutationService               = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator());
     _contactGroupService                = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator());
     _purchaseOrderDetailService         = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator());
     _salesOrderDetailService            = new SalesOrderDetailService(new SalesOrderDetailRepository(), new SalesOrderDetailValidator());
     _stockAdjustmentDetailService       = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator());
     _cashBankService                    = new CashBankService(new CashBankRepository(), new CashBankValidator());
     _cashMutationService                = new CashMutationService(new CashMutationRepository(), new CashMutationValidator());
     _customPurchaseInvoiceService       = new CustomPurchaseInvoiceService(new CustomPurchaseInvoiceRepository(), new CustomPurchaseInvoiceValidator());
     _customPurchaseInvoiceDetailService = new CustomPurchaseInvoiceDetailService(new CustomPurchaseInvoiceDetailRepository(), new CustomPurchaseInvoiceDetailValidator());
     _cashSalesReturnService             = new CashSalesReturnService(new CashSalesReturnRepository(), new CashSalesReturnValidator());
     _quantityPricingService             = new QuantityPricingService(new QuantityPricingRepository(), new QuantityPricingValidator());
     _payableService                     = new PayableService(new PayableRepository(), new PayableValidator());
     _paymentVoucherService              = new PaymentVoucherService(new PaymentVoucherRepository(), new PaymentVoucherValidator());
     _paymentVoucherDetailService        = new PaymentVoucherDetailService(new PaymentVoucherDetailRepository(), new PaymentVoucherDetailValidator());
     _receivableService                  = new ReceivableService(new ReceivableRepository(), new ReceivableValidator());
     _accountService                     = new AccountService(new AccountRepository(), new AccountValidator());
     _generalLedgerJournalService        = new GeneralLedgerJournalService(new GeneralLedgerJournalRepository(), new GeneralLedgerJournalValidator());
     _closingService                     = new ClosingService(new ClosingRepository(), new ClosingValidator());
     _validCombService                   = new ValidCombService(new ValidCombRepository(), new ValidCombValidator());
 }
 public CoreIdentificationDetail UnfinishObject(CoreIdentificationDetail coreIdentificationDetail, ICoreIdentificationService _coreIdentificationService,
                                                ICoreBuilderService _coreBuilderService, IStockMutationService _stockMutationService,
                                                IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     if (_validator.ValidUnfinishObject(coreIdentificationDetail, _coreIdentificationService, this, _coreBuilderService, _warehouseItemService))
     {
         CoreIdentification coreIdentification = _coreIdentificationService.GetObjectById(coreIdentificationDetail.CoreIdentificationId);
         if (coreIdentification.ContactId != null)
         {
             // reduce contact core
             int  MaterialCase = coreIdentificationDetail.MaterialCase;
             Item item         = (MaterialCase == Core.Constants.Constant.MaterialCase.New ?
                                  _coreBuilderService.GetNewCore(coreIdentificationDetail.CoreBuilderId) :
                                  _coreBuilderService.GetUsedCore(coreIdentificationDetail.CoreBuilderId));
             WarehouseItem         warehouseItem  = _warehouseItemService.FindOrCreateObject(coreIdentification.WarehouseId, item.Id);
             IList <StockMutation> stockMutations = _stockMutationService.SoftDeleteStockMutationForCoreIdentification(coreIdentificationDetail, warehouseItem);
             foreach (var stockMutation in stockMutations)
             {
                 _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
             }
         }
         _repository.UnfinishObject(coreIdentificationDetail);
     }
     return(coreIdentificationDetail);
 }
Beispiel #13
0
 public bool ValidConfirmObject(BarringOrder barringOrder, IBarringOrderDetailService _barringOrderDetailService,
                                IBarringService _barringService, IItemService _itemService, IWarehouseItemService _warehouseItemService)
 {
     barringOrder.Errors.Clear();
     VConfirmObject(barringOrder, _barringOrderDetailService, _barringService, _itemService, _warehouseItemService);
     return(isValid(barringOrder));
 }
 public CashSalesInvoice UnconfirmObject(CashSalesInvoice cashSalesInvoice, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService,
                                         IReceivableService _receivableService, IReceiptVoucherDetailService _receiptVoucherDetailService,
                                         IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService,
                                         IBarringService _barringService, IStockMutationService _stockMutationService,
                                         IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService,
                                         IClosingService _closingService)
 {
     if (_validator.ValidUnconfirmObject(cashSalesInvoice, _cashSalesInvoiceDetailService, _receivableService, _receiptVoucherDetailService,
                                         _closingService))
     {
         IList <CashSalesInvoiceDetail> cashSalesInvoiceDetails = _cashSalesInvoiceDetailService.GetObjectsByCashSalesInvoiceId(cashSalesInvoice.Id);
         foreach (var cashSalesInvoiceDetail in cashSalesInvoiceDetails)
         {
             cashSalesInvoiceDetail.Errors = new Dictionary <string, string>();
             _cashSalesInvoiceDetailService.UnconfirmObject(cashSalesInvoiceDetail, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService);
         }
         Receivable receivable = _receivableService.GetObjectBySource(Core.Constants.Constant.ReceivableSource.CashSalesInvoice, cashSalesInvoice.Id);
         _receivableService.SoftDeleteObject(receivable);
         _generalLedgerJournalService.CreateUnconfirmationJournalForCashSalesInvoice(cashSalesInvoice, _accountService);
         cashSalesInvoice.CoGS     = 0;
         cashSalesInvoice.Total    = 0;
         cashSalesInvoice.Discount = 0;
         cashSalesInvoice.Tax      = 0;
         cashSalesInvoice          = _repository.UnconfirmObject(cashSalesInvoice);
     }
     return(cashSalesInvoice);
 }
 public MstMachineController()
 {
     _MachineService                  = new MachineService(new MachineRepository(), new MachineValidator());
     _itemService                     = new ItemService(new ItemRepository(), new ItemValidator());
     _rollerBuilderService            = new RollerBuilderService(new RollerBuilderRepository(), new RollerBuilderValidator());
     _coreIdentificationDetailService = new CoreIdentificationDetailService(new CoreIdentificationDetailRepository(), new CoreIdentificationDetailValidator());
     _barringService                  = new BarringService(new BarringRepository(), new BarringValidator());
 }
 public MstContactController()
 {
     _contactService            = new ContactService(new ContactRepository(), new ContactValidator());
     _coreIdentificationService = new CoreIdentificationService(new CoreIdentificationRepository(), new CoreIdentificationValidator());
     _barringService            = new BarringService(new BarringRepository(), new BarringValidator());
     _purchaseOrderService      = new PurchaseOrderService(new PurchaseOrderRepository(), new PurchaseOrderValidator());
     _salesOrderService         = new SalesOrderService(new SalesOrderRepository(), new SalesOrderValidator());
 }
Beispiel #17
0
 public StockMutationController()
 {
     _itemService          = new ItemService(new ItemRepository(), new ItemValidator());
     _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator());
     _warehouseService     = new WarehouseService(new WarehouseRepository(), new WarehouseValidator());
     _stockMutationService = new StockMutationService(new StockMutationRepository(), new StockMutationValidator());
     _barringService       = new BarringService(new BarringRepository(), new BarringValidator());
     _uomService           = new UoMService(new UoMRepository(), new UoMValidator());
 }
        public BarringOrderDetail VHasBarring(BarringOrderDetail barringOrderDetail, IBarringService _barringService)
        {
            Barring barring = _barringService.GetObjectById(barringOrderDetail.BarringId);

            if (barring == null)
            {
                barringOrderDetail.Errors.Add("BarringId", "Tidak terasosiasi dengan Barring");
            }
            return(barringOrderDetail);
        }
 public StockAdjustmentController()
 {
     _stockAdjustmentService       = new StockAdjustmentService(new StockAdjustmentRepository(), new StockAdjustmentValidator());
     _stockAdjustmentDetailService = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator());
     _warehouseService             = new WarehouseService(new WarehouseRepository(), new WarehouseValidator());
     _itemService          = new ItemService(new ItemRepository(), new ItemValidator());
     _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator());
     _stockMutationService = new StockMutationService(new StockMutationRepository(), new StockMutationValidator());
     _barringService       = new BarringService(new BarringRepository(), new BarringValidator());
 }
Beispiel #20
0
        public Machine VHasBarring(Machine machine, IBarringService _barringService)
        {
            IList <Barring> barrings = _barringService.GetObjectsByMachineId(machine.Id);

            if (barrings.Any())
            {
                machine.Errors.Add("Generic", "Machine masih memiliki asosiasi dengan Barring");
            }
            return(machine);
        }
 public WarehouseMutationOrderController()
 {
     _warehouseService                    = new WarehouseService(new WarehouseRepository(), new WarehouseValidator());
     _itemService                         = new ItemService(new ItemRepository(), new ItemValidator());
     _warehouseItemService                = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator());
     _stockMutationService                = new StockMutationService(new StockMutationRepository(), new StockMutationValidator());
     _barringService                      = new BarringService(new BarringRepository(), new BarringValidator());
     _warehouseMutationOrderService       = new WarehouseMutationOrderService(new WarehouseMutationOrderRepository(), new WarehouseMutationOrderValidator());
     _warehouseMutationOrderDetailService = new WarehouseMutationOrderDetailService(new WarehouseMutationOrderDetailRepository(), new WarehouseMutationOrderDetailValidator());
 }
Beispiel #22
0
        public Contact VHasBarring(Contact contact, IBarringService _barringService)
        {
            IList <Barring> barrings = _barringService.GetObjectsByContactId(contact.Id);

            if (barrings.Any())
            {
                contact.Errors.Add("Generic", "Contact masih memiliki asosiasi dengan Barring");
            }
            return(contact);
        }
Beispiel #23
0
        public Barring VCreateObject(Barring barring, IBarringService _barringService, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService,
                                     IContactService _contactService, IMachineService _machineService)
        {
            // Item Validation

            VHasItemTypeAndIsLegacy(barring, _itemTypeService);
            if (!isValid(barring))
            {
                return(barring);
            }
            VHasUniqueSku(barring, _barringService);
            if (!isValid(barring))
            {
                return(barring);
            }
            VHasName(barring);
            if (!isValid(barring))
            {
                return(barring);
            }
            VHasCategory(barring);
            if (!isValid(barring))
            {
                return(barring);
            }
            VHasUoM(barring, _uomService);
            if (!isValid(barring))
            {
                return(barring);
            }
            VNonNegativeQuantity(barring);
            if (!isValid(barring))
            {
                return(barring);
            }

            // Bar Validation
            VHasBlanket(barring, _itemService);
            if (!isValid(barring))
            {
                return(barring);
            }
            VHasContact(barring, _contactService);
            if (!isValid(barring))
            {
                return(barring);
            }
            VHasMachine(barring, _machineService);
            if (!isValid(barring))
            {
                return(barring);
            }
            VHasMeasurement(barring);
            return(barring);
        }
 public StockAdjustmentDetail VConfirmObject(StockAdjustmentDetail stockAdjustmentDetail, IStockAdjustmentService _stockAdjustmentService,
                                             IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     VHasConfirmationDate(stockAdjustmentDetail);
     if (!isValid(stockAdjustmentDetail))
     {
         return(stockAdjustmentDetail);
     }
     VNonNegativeStockQuantity(stockAdjustmentDetail, _stockAdjustmentService, _itemService, _barringService, _warehouseItemService, true);
     return(stockAdjustmentDetail);
 }
Beispiel #25
0
 public StockAdjustment VUnconfirmObject(StockAdjustment stockAdjustment, IStockAdjustmentService _stockAdjustmentService, IStockAdjustmentDetailService _stockAdjustmentDetailService,
                                         IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService, IClosingService _closingService)
 {
     VHasBeenConfirmed(stockAdjustment);
     if (!isValid(stockAdjustment))
     {
         return(stockAdjustment);
     }
     VGeneralLedgerPostingHasNotBeenClosed(stockAdjustment, _closingService, 2);
     return(stockAdjustment);
 }
Beispiel #26
0
 public Barring CreateObject(Barring barring, IBarringService _barringService, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService,
                             IContactService _contactService, IMachineService _machineService,
                             IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService)
 {
     barring.Errors = new Dictionary <String, String>();
     if (_validator.ValidCreateObject(barring, _barringService, _uomService, _itemService, _itemTypeService, _contactService, _machineService))
     {
         barring = _repository.CreateObject(barring);
     }
     return(barring);
 }
 public MstBarringController()
 {
     _itemTypeService      = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator());
     _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator());
     _itemService          = new ItemService(new ItemRepository(), new ItemValidator());
     _uomService           = new UoMService(new UoMRepository(), new UoMValidator());
     _warehouseService     = new WarehouseService(new WarehouseRepository(), new WarehouseValidator());
     _machineService       = new MachineService(new MachineRepository(), new MachineValidator());
     _barringService       = new BarringService(new BarringRepository(), new BarringValidator());
     _contactService       = new ContactService(new ContactRepository(), new ContactValidator());
 }
        public BarringOrderDetail UnfinishObject(BarringOrderDetail barringOrderDetail, IBarringOrderService _barringOrderService, IStockMutationService _stockMutationService,
                                                 IBarringService _barringService, IItemService _itemService, IWarehouseItemService _warehouseItemService)
        {
            if (_validator.ValidUnfinishObject(barringOrderDetail, _barringOrderService))
            {
                _repository.UnfinishObject(barringOrderDetail);
                // deduce barring order quantity final
                BarringOrder barringOrder = _barringOrderService.GetObjectById(barringOrderDetail.BarringOrderId);
                barringOrder.QuantityFinal -= 1;
                _barringOrderService.AdjustQuantity(barringOrder);

                // reverse stock mutation
                Barring               barring          = _barringService.GetObjectById(barringOrderDetail.BarringId);
                WarehouseItem         warehouseBarring = _warehouseItemService.FindOrCreateObject(barringOrder.WarehouseId, barring.Id);
                IList <StockMutation> stockMutations   = _stockMutationService.SoftDeleteStockMutationForBarringOrder(barringOrderDetail, warehouseBarring);
                foreach (var stockMutation in stockMutations)
                {
                    _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
                }

                if (barringOrderDetail.IsBarRequired)
                {
                    Item leftbar  = (barringOrderDetail.HasLeftBar && barring.LeftBarItemId != null) ? _itemService.GetObjectById((int)barring.LeftBarItemId) : null;
                    Item rightbar = (barringOrderDetail.HasRightBar && barring.RightBarItemId != null) ? _itemService.GetObjectById((int)barring.RightBarItemId) : null;
                    if (leftbar != null)
                    {
                        WarehouseItem         warehouseLeftBar      = _warehouseItemService.FindOrCreateObject(barringOrder.WarehouseId, leftbar.Id);
                        IList <StockMutation> stockMutationLeftBars = _stockMutationService.SoftDeleteStockMutationForBarringOrder(barringOrderDetail, warehouseLeftBar);
                        foreach (var stockMutationLeftBar in stockMutationLeftBars)
                        {
                            _stockMutationService.ReverseStockMutateObject(stockMutationLeftBar, _itemService, _barringService, _warehouseItemService);
                        }
                    }
                    if (rightbar != null)
                    {
                        WarehouseItem         warehouseRightBar      = _warehouseItemService.FindOrCreateObject(barringOrder.WarehouseId, rightbar.Id);
                        IList <StockMutation> stockMutationRightBars = _stockMutationService.SoftDeleteStockMutationForBarringOrder(barringOrderDetail, warehouseRightBar);
                        foreach (var stockMutationRightBar in stockMutationRightBars)
                        {
                            _stockMutationService.ReverseStockMutateObject(stockMutationRightBar, _itemService, _barringService, _warehouseItemService);
                        }
                    }
                }

                WarehouseItem         warehouseBlanket      = _warehouseItemService.FindOrCreateObject(barringOrder.WarehouseId, barring.BlanketItemId);
                IList <StockMutation> stockMutationBlankets = _stockMutationService.SoftDeleteStockMutationForBarringOrder(barringOrderDetail, warehouseBlanket);
                foreach (var stockMutationBlanket in stockMutationBlankets)
                {
                    _stockMutationService.ReverseStockMutateObject(stockMutationBlanket, _itemService, _barringService, _warehouseItemService);
                }
            }
            return(barringOrderDetail);
        }
Beispiel #29
0
 public SalesOrderController()
 {
     _itemService                = new ItemService(new ItemRepository(), new ItemValidator());
     _warehouseItemService       = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator());
     _stockMutationService       = new StockMutationService(new StockMutationRepository(), new StockMutationValidator());
     _barringService             = new BarringService(new BarringRepository(), new BarringValidator());
     _contactService             = new ContactService(new ContactRepository(), new ContactValidator());
     _salesOrderService          = new SalesOrderService(new SalesOrderRepository(), new SalesOrderValidator());
     _salesOrderDetailService    = new SalesOrderDetailService(new SalesOrderDetailRepository(), new SalesOrderDetailValidator());
     _deliveryOrderService       = new DeliveryOrderService(new DeliveryOrderRepository(), new DeliveryOrderValidator());
     _deliveryOrderDetailService = new DeliveryOrderDetailService(new DeliveryOrderDetailRepository(), new DeliveryOrderDetailValidator());
 }
Beispiel #30
0
 public Barring VHasUniqueSku(Barring barring, IBarringService _barringService)
 {
     if (String.IsNullOrEmpty(barring.Sku) || barring.Sku.Trim() == "")
     {
         barring.Errors.Add("Sku", "Tidak boleh kosong");
     }
     else if (_barringService.IsSkuDuplicated(barring))
     {
         barring.Errors.Add("Sku", "Tidak boleh diduplikasi");
     }
     return(barring);
 }