public dynamic GetInfo(int Id) { PurchaseReceival model = new PurchaseReceival(); try { model = _purchaseReceivalService.GetObjectById(Id); } catch (Exception ex) { LOG.Error("GetInfo", ex); model.Errors.Add("Generic", "Error : " + ex); } return(Json(new { model.Id, model.Code, model.PurchaseOrderId, PurchaseOrder = _purchaseOrderService.GetObjectById(model.PurchaseOrderId).Code, model.ReceivalDate, model.WarehouseId, Warehouse = _warehouseService.GetObjectById(model.WarehouseId).Name, model.Errors }, JsonRequestBehavior.AllowGet)); }
public PurchaseInvoice ConfirmObject(PurchaseInvoice purchaseInvoice, DateTime ConfirmationDate, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService, IPurchaseOrderService _purchaseOrderService, IPurchaseReceivalService _purchaseReceivalService, IPurchaseReceivalDetailService _purchaseReceivalDetailService, IPayableService _payableService) { purchaseInvoice.ConfirmationDate = ConfirmationDate; if (_validator.ValidConfirmObject(purchaseInvoice, _purchaseInvoiceDetailService, _purchaseReceivalService, _purchaseReceivalDetailService)) { // confirm details // add all amount into amountpayable IList <PurchaseInvoiceDetail> details = _purchaseInvoiceDetailService.GetObjectsByPurchaseInvoiceId(purchaseInvoice.Id); foreach (var detail in details) { detail.Errors = new Dictionary <string, string>(); _purchaseInvoiceDetailService.ConfirmObject(detail, ConfirmationDate, _purchaseReceivalDetailService); } purchaseInvoice = CalculateAmountPayable(purchaseInvoice, _purchaseInvoiceDetailService); // confirm object // create payable purchaseInvoice = _repository.ConfirmObject(purchaseInvoice); PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseInvoice.PurchaseReceivalId); _purchaseReceivalService.CheckAndSetInvoiceComplete(purchaseReceival, _purchaseReceivalDetailService); PurchaseOrder purchaseOrder = _purchaseOrderService.GetObjectById(purchaseReceival.PurchaseOrderId); Payable payable = _payableService.CreateObject(purchaseOrder.ContactId, Constant.PayableSource.PurchaseInvoice, purchaseInvoice.Id, purchaseInvoice.AmountPayable, purchaseInvoice.DueDate); } return(purchaseInvoice); }
public dynamic GetInfo(int Id) { PurchaseInvoice model = new PurchaseInvoice(); try { model = _purchaseInvoiceService.GetObjectById(Id); } catch (Exception ex) { LOG.Error("GetInfo", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Id, model.Code, model.PurchaseReceivalId, PurchaseReceival = _purchaseReceivalService.GetObjectById(model.PurchaseReceivalId).Code, model.Discount, model.Description, model.IsTaxable, model.InvoiceDate, model.DueDate, model.AmountPayable, model.Errors }, JsonRequestBehavior.AllowGet)); }
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 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 PurchaseInvoice VPurchaseReceivalHasNotBeenInvoiceCompleted(PurchaseInvoice purchaseInvoice, IPurchaseReceivalService _purchaseReceivalService) { PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseInvoice.PurchaseReceivalId); if (purchaseReceival.IsInvoiceCompleted) { purchaseInvoice.Errors.Add("Generic", "Tidak boleh memilih Purchase Receival dengan invoice yang sudah terbayar"); } return(purchaseInvoice); }
public PurchaseInvoice VHasPurchaseReceival(PurchaseInvoice purchaseInvoice, IPurchaseReceivalService _purchaseReceivalService) { PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseInvoice.PurchaseReceivalId); if (purchaseReceival == null) { purchaseInvoice.Errors.Add("PurchaseReceivalId", "Tidak terasosiasi dengan Purchase Receival"); } return(purchaseInvoice); }
public PurchaseReceivalDetail VHasPurchaseReceival(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalService _purchaseReceivalService) { PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseReceivalDetail.PurchaseReceivalId); if (purchaseReceival == null) { purchaseReceivalDetail.Errors.Add("PurchaseReceivalId", "Tidak terasosiasi dengan purchase receival"); } 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 PurchaseReceivalDetail VPurchaseReceivalAndPurchaseOrderDetailHaveTheSamePurchaseOrder(PurchaseReceivalDetail purchaseReceivalDetail, IPurchaseReceivalService _purchaseReceivalService, IPurchaseOrderDetailService _purchaseOrderDetailService) { PurchaseOrderDetail purchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId); PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseReceivalDetail.PurchaseReceivalId); if (purchaseOrderDetail.PurchaseOrderId != purchaseReceival.PurchaseOrderId) { purchaseReceivalDetail.Errors.Add("Generic", "Purchase receival dan purchase order detail memiliki purchase order yang berbeda"); } return(purchaseReceivalDetail); }
public PurchaseInvoice UnconfirmObject(PurchaseInvoice purchaseInvoice, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService, IPurchaseReceivalService _purchaseReceivalService, IPurchaseReceivalDetailService _purchaseReceivalDetailService, IPaymentVoucherDetailService _paymentVoucherDetailService, IPayableService _payableService) { if (_validator.ValidUnconfirmObject(purchaseInvoice, _purchaseInvoiceDetailService, _paymentVoucherDetailService, _payableService)) { IList <PurchaseInvoiceDetail> details = _purchaseInvoiceDetailService.GetObjectsByPurchaseInvoiceId(purchaseInvoice.Id); foreach (var detail in details) { detail.Errors = new Dictionary <string, string>(); _purchaseInvoiceDetailService.UnconfirmObject(detail, _purchaseReceivalService, _purchaseReceivalDetailService); } _repository.UnconfirmObject(purchaseInvoice); PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseInvoice.PurchaseReceivalId); _purchaseReceivalService.UnsetInvoiceComplete(purchaseReceival); Payable payable = _payableService.GetObjectBySource(Constant.PayableSource.PurchaseInvoice, purchaseInvoice.Id); _payableService.SoftDeleteObject(payable); } return(purchaseInvoice); }