public PurchaseReceivalDetail UpdateObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalService _purchaseReceivalService, IPurchaseOrderDetailService _purchaseOrderDetailService, IPurchaseOrderService _purchaseOrderService, IItemService _itemService) { return(_validator.ValidUpdateObject(purchaseReceivalDetail, this, _purchaseReceivalService, _purchaseOrderDetailService, _itemService) ? _repository.UpdateObject(purchaseReceivalDetail) : purchaseReceivalDetail); }
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); }
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); }
public bool ValidUpdateObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService, IPurchaseReceivalService _purchaseReceivalService, IPurchaseOrderDetailService _purchaseOrderDetailService, IItemService _itemService) { purchaseReceivalDetail.Errors.Clear(); VUpdateObject(purchaseReceivalDetail, _purchaseReceivalDetailService, _purchaseReceivalService, _purchaseOrderDetailService, _itemService); return(isValid(purchaseReceivalDetail)); }
public dynamic DeleteDetail(PurchaseReceivalDetail model) { try { if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.PurchaseReceival, 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)); } var data = _purchaseReceivalDetailService.GetObjectById(model.Id); model = _purchaseReceivalDetailService.SoftDeleteObject(data); } catch (Exception ex) { LOG.Error("Delete 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 bool ValidConfirmObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService, IPurchaseOrderDetailService _purchaseOrderDetailService) { purchaseReceivalDetail.Errors.Clear(); VConfirmObject(purchaseReceivalDetail, _purchaseReceivalDetailService, _purchaseOrderDetailService); return(isValid(purchaseReceivalDetail)); }
public dynamic GetInfoDetail(int Id) { PurchaseReceivalDetail model = new PurchaseReceivalDetail(); try { model = _purchaseReceivalDetailService.GetObjectById(Id); } catch (Exception ex) { LOG.Error("GetInfo", ex); model.Errors.Add("Generic", "Error : " + ex); } return(Json(new { model.Id, model.Code, model.PurchaseOrderDetailId, PurchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(model.PurchaseOrderDetailId).Code, model.ItemId, Item = _itemService.GetObjectById(model.ItemId).Name, model.Errors }, JsonRequestBehavior.AllowGet)); }
public dynamic InsertDetail(PurchaseReceivalDetail model) { try { if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.PurchaseReceival, 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 = _purchaseReceivalDetailService.CreateObject(model, _purchaseReceivalService, _purchaseOrderDetailService, _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 })); }
public PurchaseReceivalDetail VNonNegativeQuantity(PurchaseReceivalDetail purchaseReceivalDetail) { if (purchaseReceivalDetail.Quantity < 0) { purchaseReceivalDetail.Errors.Add("Quantity", "Tidak boleh negatif"); } return(purchaseReceivalDetail); }
public PurchaseReceivalDetail CreateObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalService _purchaseReceivalService, IPurchaseOrderDetailService _purchaseOrderDetailService, IPurchaseOrderService _purchaseOrderService, IItemService _itemService) { purchaseReceivalDetail.Errors = new Dictionary <String, String>(); return(_validator.ValidCreateObject(purchaseReceivalDetail, this, _purchaseReceivalService, _purchaseOrderDetailService, _itemService) ? _repository.CreateObject(purchaseReceivalDetail) : purchaseReceivalDetail); }
public PurchaseReceivalDetail VHasConfirmationDate(PurchaseReceivalDetail purchaseReceivalDetail) { if (purchaseReceivalDetail.ConfirmationDate == null) { purchaseReceivalDetail.Errors.Add("ConfirmationDate", "Tidak boleh kosong"); } return(purchaseReceivalDetail); }
public PurchaseReceivalDetail VHasBeenConfirmed(PurchaseReceivalDetail purchaseReceivalDetail) { if (!purchaseReceivalDetail.IsConfirmed) { purchaseReceivalDetail.Errors.Add("Generic", "Belum selesai"); } return(purchaseReceivalDetail); }
public PurchaseReceivalDetail VHasNotBeenConfirmed(PurchaseReceivalDetail purchaseReceivalDetail) { if (purchaseReceivalDetail.IsConfirmed) { purchaseReceivalDetail.Errors.Add("Generic", "Tidak boleh sudah selesai"); } return(purchaseReceivalDetail); }
public IList <StockMutation> SoftDeleteStockMutationForPurchaseReceival(PurchaseReceivalDetail purchaseReceivalDetail, WarehouseItem warehouseItem) { IList <StockMutation> stockMutations = _repository.GetObjectsBySourceDocumentDetailForWarehouseItem(warehouseItem.Id, Constant.SourceDocumentDetailType.PurchaseReceivalDetail, purchaseReceivalDetail.Id); foreach (var stockMutation in stockMutations) { _repository.Delete(stockMutation); } return(stockMutations); }
public PurchaseReceivalDetail VHasPurchaseOrderDetail(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseOrderDetailService _purchaseOrderDetailService) { PurchaseOrderDetail purchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId); if (purchaseOrderDetail == null) { purchaseReceivalDetail.Errors.Add("PurchaseOrderDetailId", "Tidak terasosiasi dengan purchase order detail"); } return(purchaseReceivalDetail); }
public PurchaseReceivalDetail VHasItem(PurchaseReceivalDetail purchaseReceivalDetail, IItemService _itemService) { Item item = _itemService.GetObjectById(purchaseReceivalDetail.ItemId); if (item == null) { purchaseReceivalDetail.Errors.Add("ItemId", "Tidak terasosiasi dengan item"); } return(purchaseReceivalDetail); }
public PurchaseReceivalDetail VHasNoPurchaseInvoiceDetail(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService) { IList <PurchaseInvoiceDetail> purchaseInvoiceDetails = _purchaseInvoiceDetailService.GetObjectsByPurchaseReceivalDetailId(purchaseReceivalDetail.Id); if (purchaseInvoiceDetails.Any()) { purchaseReceivalDetail.Errors.Add("Generic", "Sudah memiliki purchase invoice detail"); } return(purchaseReceivalDetail); }
public PurchaseInvoiceDetail VQuantityIsLessThanOrEqualPendingInvoiceQuantity(PurchaseInvoiceDetail purchaseInvoiceDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService) { PurchaseReceivalDetail purchaseReceivalDetail = _purchaseReceivalDetailService.GetObjectById(purchaseInvoiceDetail.PurchaseReceivalDetailId); if (purchaseInvoiceDetail.Quantity > purchaseReceivalDetail.PendingInvoicedQuantity) { purchaseInvoiceDetail.Errors.Add("Generic", "Quantity harus kurang dari atau sama dengan pending invoice quantity"); } return(purchaseInvoiceDetail); }
public PurchaseReceivalDetail VPurchaseOrderDetailHasBeenConfirmed(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseOrderDetailService _purchaseOrderDetailService) { PurchaseOrderDetail purchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId); if (!purchaseOrderDetail.IsConfirmed) { purchaseReceivalDetail.Errors.Add("Generic", "Purchase Order Detail belum dikonfirmasi"); } return(purchaseReceivalDetail); }
public PurchaseInvoiceDetail VHasPurchaseReceivalDetail(PurchaseInvoiceDetail purchaseInvoiceDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService) { PurchaseReceivalDetail prd = _purchaseReceivalDetailService.GetObjectById(purchaseInvoiceDetail.PurchaseReceivalDetailId); if (prd == null) { purchaseInvoiceDetail.Errors.Add("PurchaseReceivalDetail", "Tidak boleh tidak ada"); } return(purchaseInvoiceDetail); }
public PurchaseReceivalDetail InvoiceObject(PurchaseReceivalDetail purchaseReceivalDetail, int Quantity) { purchaseReceivalDetail.PendingInvoicedQuantity -= Quantity; if (purchaseReceivalDetail.PendingInvoicedQuantity == 0) { purchaseReceivalDetail.IsAllInvoiced = true; } _repository.UpdateObject(purchaseReceivalDetail); return(purchaseReceivalDetail); }
public PurchaseReceivalDetail VUpdateObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService, IPurchaseReceivalService _purchaseReceivalService, IPurchaseOrderDetailService _purchaseOrderDetailService, IItemService _itemService) { VCreateObject(purchaseReceivalDetail, _purchaseReceivalDetailService, _purchaseReceivalService, _purchaseOrderDetailService, _itemService); if (!isValid(purchaseReceivalDetail)) { return(purchaseReceivalDetail); } VHasNotBeenConfirmed(purchaseReceivalDetail); return(purchaseReceivalDetail); }
public PurchaseReceivalDetail VUnconfirmObject(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService, IItemService _itemService) { VHasItemQuantity(purchaseReceivalDetail, _itemService); if (!isValid(purchaseReceivalDetail)) { return(purchaseReceivalDetail); } VHasNoPurchaseInvoiceDetail(purchaseReceivalDetail, _purchaseInvoiceDetailService); return(purchaseReceivalDetail); }
public PurchaseReceivalDetail UndoInvoiceObject(PurchaseReceivalDetail purchaseReceivalDetail, int Quantity, IPurchaseReceivalService _purchaseReceivalService) { PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseReceivalDetail.PurchaseReceivalId); _purchaseReceivalService.UnsetInvoiceComplete(purchaseReceival); purchaseReceivalDetail.IsAllInvoiced = false; purchaseReceivalDetail.PendingInvoicedQuantity += Quantity; _repository.UpdateObject(purchaseReceivalDetail); return(purchaseReceivalDetail); }
public PurchaseInvoiceDetail VPurchaseReceivalDetailAndPurchaseInvoiceMustHaveTheSamePurchaseReceival(PurchaseInvoiceDetail purchaseInvoiceDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService, IPurchaseInvoiceService _purchaseInvoiceService) { PurchaseReceivalDetail purchaseReceivalDetail = _purchaseReceivalDetailService.GetObjectById(purchaseInvoiceDetail.PurchaseReceivalDetailId); PurchaseInvoice purchaseInvoice = _purchaseInvoiceService.GetObjectById(purchaseInvoiceDetail.PurchaseInvoiceId); if (purchaseReceivalDetail.PurchaseReceivalId != purchaseInvoice.PurchaseReceivalId) { purchaseReceivalDetail.Errors.Add("Generic", "Purchase receival detail dan purchase invoice memiliki purchase receival berbeda"); } return(purchaseInvoiceDetail); }
public PurchaseInvoiceDetail UnconfirmObject(PurchaseInvoiceDetail purchaseInvoiceDetail, IPurchaseReceivalService _purchaseReceivalService, IPurchaseReceivalDetailService _purchaseReceivalDetailService) { if (_validator.ValidUnconfirmObject(purchaseInvoiceDetail)) { purchaseInvoiceDetail = _repository.UnconfirmObject(purchaseInvoiceDetail); // reverse purchase receival detail PendingInvoiceQuantity PurchaseReceivalDetail purchaseReceivalDetail = _purchaseReceivalDetailService.GetObjectById(purchaseInvoiceDetail.PurchaseReceivalDetailId); _purchaseReceivalDetailService.UndoInvoiceObject(purchaseReceivalDetail, purchaseInvoiceDetail.Quantity, _purchaseReceivalService); } return(purchaseInvoiceDetail); }
public string PrintError(PurchaseReceivalDetail obj) { string erroroutput = ""; KeyValuePair <string, string> first = obj.Errors.ElementAt(0); erroroutput += first.Key + "," + first.Value; foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1)) { erroroutput += Environment.NewLine; erroroutput += pair.Key + "," + pair.Value; } return(erroroutput); }
public PurchaseInvoiceDetail ConfirmObject(PurchaseInvoiceDetail purchaseInvoiceDetail, DateTime ConfirmationDate, IPurchaseReceivalDetailService _purchaseReceivalDetailService) { purchaseInvoiceDetail.ConfirmationDate = ConfirmationDate; if (_validator.ValidConfirmObject(purchaseInvoiceDetail, this, _purchaseReceivalDetailService)) { purchaseInvoiceDetail = _repository.ConfirmObject(purchaseInvoiceDetail); // update purchase receival detail PendingInvoiceQuantity PurchaseReceivalDetail purchaseReceivalDetail = _purchaseReceivalDetailService.GetObjectById(purchaseInvoiceDetail.PurchaseReceivalDetailId); _purchaseReceivalDetailService.InvoiceObject(purchaseReceivalDetail, purchaseInvoiceDetail.Quantity); } return(purchaseInvoiceDetail); }
public PurchaseReceivalDetail VUniquePurchaseOrderDetail(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService, IItemService _itemService) { IList <PurchaseReceivalDetail> details = _purchaseReceivalDetailService.GetObjectsByPurchaseReceivalId(purchaseReceivalDetail.PurchaseReceivalId); foreach (var detail in details) { if (detail.PurchaseOrderDetailId == purchaseReceivalDetail.PurchaseOrderDetailId && detail.Id != purchaseReceivalDetail.Id) { purchaseReceivalDetail.Errors.Add("Generic", "Tidak boleh memiliki lebih dari 2 Purchase Receival Detail dalam satu purchase receival"); } } return(purchaseReceivalDetail); }
public PurchaseReceivalDetail CreateObject(int purchaseReceivalId, int itemId, int quantity, int purchaseOrderDetailId, IPurchaseReceivalService _purchaseReceivalService, IPurchaseOrderDetailService _purchaseOrderDetailService, IPurchaseOrderService _purchaseOrderService, IItemService _itemService) { PurchaseReceivalDetail purchaseReceivalDetail = new PurchaseReceivalDetail { PurchaseReceivalId = purchaseReceivalId, ItemId = itemId, Quantity = quantity, PurchaseOrderDetailId = purchaseOrderDetailId }; return(this.CreateObject(purchaseReceivalDetail, _purchaseReceivalService, _purchaseOrderDetailService, _purchaseOrderService, _itemService)); }