/// <summary> /// This method is used for fetch supplier purchase order in database. - JJ /// </summary> /// <param name="id">id of spo</param> /// <returns>object of SupplierPOAC</returns> public SupplierPOAC GetSupplierPO(int id) { try { if (_supplierPOContext.Fetch(x => x.Id == id).Any()) { var spo = _supplierPOContext.Find(id); SupplierPOAC supplierPOAC = new SupplierPOAC(); supplierPOAC.PurchaseOrderNumber = spo.PurchaseOrderNumber; supplierPOAC.Id = spo.Id; supplierPOAC.UserId = spo.UserId; supplierPOAC.SupplierId = spo.SupplierId; supplierPOAC.DueDate = spo.DueDate; supplierPOAC.ReceivingDate = spo.DueDate; supplierPOAC.CreatedDateTime = spo.CreatedDateTime; supplierPOAC.ParentRecordId = spo.RecordId; supplierPOAC.SupplierName = spo.SupplierProfile.NameEn; supplierPOAC.SupplierProfile = spo.SupplierProfile; supplierPOAC.SupplierTypeId = spo.SupplierProfile.SupplierTypeId; supplierPOAC.IsApproved = spo.IsApproved; supplierPOAC.IsCanceled = spo.IsCanceled; supplierPOAC.IsConfirmed = spo.IsConfirmed; supplierPOAC.InitiationBranchId = spo.InitiationBranchId; supplierPOAC.InitiationBranchName = spo.InitiatorBranch.Name; supplierPOAC.IsRejected = spo.IsRejected; supplierPOAC.IsPartiallyReceived = spo.IsPartiallyReceived; supplierPOAC.IsSend = spo.IsSend; supplierPOAC.SPOBranch = _supplierPOWorkListContext.GetSPOBranchList(id); return(supplierPOAC); } else { return(null); } } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
/// <summary> /// This method is used for fetching supplier purchase order from database. - JJ /// </summary> /// <param name="POID">ID OF PO</param> /// <returns>object of SPOReceivingAC</returns> public SPOReceivingAC GetSupplierPO(int POId) { try { if (_supplierPOContext.Fetch(x => x.Id == POId).Any()) { var supplierPurchaseOrder = _supplierPOContext.Find(POId); var isCashPO = false; var SupplierDaysLimit = new List <DiscountDaysAC>(); if (supplierPurchaseOrder.SupplierProfile.SupplierType.ValueEn == "Cash") { isCashPO = true; } else { var daysLimit = _supplierDaysLimitContext.Fetch(x => x.SupplierId == supplierPurchaseOrder.SupplierId).ToList(); foreach (var day in daysLimit) { var dayAC = new DiscountDaysAC { CreatedDateTime = day.CreatedDateTime, Days = day.Days, Discount = day.Discount, SupplierId = day.SupplierId }; SupplierDaysLimit.Add(dayAC); } } var itemList = _supplierPOWorkListRepository.GetSupplierPOItemList(supplierPurchaseOrder.Id, supplierPurchaseOrder.PurchaseOrderNumber); var branchList = _supplierPOWorkListRepository.GetSPOBranchList(supplierPurchaseOrder.Id); SupplierPOAC supplierPO = new SupplierPOAC(); supplierPO.Id = supplierPurchaseOrder.Id; supplierPO.DueDate = supplierPurchaseOrder.DueDate; supplierPO.IsApproved = supplierPurchaseOrder.IsApproved; supplierPO.IsCashPO = isCashPO; supplierPO.IsConfirmed = supplierPurchaseOrder.IsConfirmed; supplierPO.IsRejected = supplierPurchaseOrder.IsRejected; supplierPO.IsCanceled = supplierPurchaseOrder.IsCanceled; supplierPO.IsSend = supplierPurchaseOrder.IsSend; supplierPO.IsPartiallyReceived = supplierPurchaseOrder.IsPartiallyReceived; supplierPO.IsCancelApproved = supplierPurchaseOrder.IsCancelApproved; supplierPO.PurchaseOrderNumber = supplierPurchaseOrder.PurchaseOrderNumber; supplierPO.IssueDate = supplierPurchaseOrder.CreatedDateTime; supplierPO.SupplierId = supplierPurchaseOrder.SupplierId; supplierPO.SupplierName = supplierPurchaseOrder.SupplierProfile.NameEn; supplierPO.SupplierCode = supplierPurchaseOrder.SupplierProfile.Code; supplierPO.SPOBranch = branchList; supplierPO.ParentRecordId = supplierPurchaseOrder.RecordId; if (SupplierDaysLimit.Count > 0) { supplierPO.TotalDaysLimit = supplierPurchaseOrder.SupplierProfile.TotalDaysLimit; supplierPO.DiscountDays = SupplierDaysLimit; } var spoReceiving = new SPOReceivingAC { POItem = itemList, SupplierPOAC = supplierPO, SPOBill = GetSPOBill(POId) }; return(spoReceiving); } else { return(null); } } catch (Exception ex) { _errorLog.LogException(ex); throw; } }