public RetailSalesInvoiceDetail UnconfirmObject(RetailSalesInvoiceDetail retailSalesInvoiceDetail, IWarehouseItemService _warehouseItemService,
                                                 IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService)
 {
     if (_validator.ValidUnconfirmObject(retailSalesInvoiceDetail))
     {
         IList <StockMutation> stockMutations = _stockMutationService.GetObjectsBySourceDocumentDetailForItem(retailSalesInvoiceDetail.ItemId, Core.Constants.Constant.SourceDocumentDetailType.RetailSalesInvoiceDetail, retailSalesInvoiceDetail.Id);
         foreach (var stockMutation in stockMutations)
         {
             stockMutation.Errors = new Dictionary <string, string>();
             _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
             _stockMutationService.SoftDeleteObject(stockMutation, _warehouseService, _warehouseItemService, _itemService, _barringService);
         }
         retailSalesInvoiceDetail.CoGS = 0;
         retailSalesInvoiceDetail      = _repository.UnconfirmObject(retailSalesInvoiceDetail);
     }
     return(retailSalesInvoiceDetail);
 }
        public RetailSalesInvoice VIsUnconfirmableRetailSalesInvoiceDetails(RetailSalesInvoice retailSalesInvoice, IRetailSalesInvoiceDetailService _retailSalesInvoiceDetailService)
        {
            IList <RetailSalesInvoiceDetail> retailSalesInvoiceDetails = _retailSalesInvoiceDetailService.GetObjectsByRetailSalesInvoiceId(retailSalesInvoice.Id);

            if (!retailSalesInvoiceDetails.Any())
            {
                retailSalesInvoice.Errors.Add("Generic", "RetailSalesInvoiceDetails Tidak ada");
            }
            else
            {
                IRetailSalesInvoiceDetailValidator validator = _retailSalesInvoiceDetailService.GetValidator();
                foreach (var retailSalesInvoiceDetail in retailSalesInvoiceDetails)
                {
                    retailSalesInvoiceDetail.Errors = new Dictionary <string, string>();
                    if (!validator.ValidUnconfirmObject(retailSalesInvoiceDetail))
                    {
                        retailSalesInvoice.Errors.Add("Generic", "RetailSalesInvoiceDetails harus unconfirmable semua");
                        return(retailSalesInvoice);
                    }
                }
            }
            return(retailSalesInvoice);
        }