/// <summary> /// This method is used for insert temp data for puchase item by customer. - PS /// </summary> /// <returns></returns> private bool InsertTempTranscation(CustomerPOAC cpoDetailData) { POSTempTrans tempTrans = new POSTempTrans(); tempTrans.BranchID = SettingHelpers.CurrentBranchId; tempTrans.CreatedDateTime = DateTime.UtcNow; tempTrans.CustomerID = cpoDetailData.Customer.Id; tempTrans.IsSuspendedBill = false; tempTrans.PurchaseOrderNo = cpoDetailData.PurchaseOrderNo; tempTrans.ReturnedBillNo = null; tempTrans.TransDate = DateTime.UtcNow; tempTrans.TransReference = string.Empty; tempTrans.UserID = SettingHelpers.CurrentUserId; tempTrans.CpoDownPayment = cpoDetailData.DownPaymentAmount; tempTrans.AdditionalAmount = SettingHelpers.AdditionalAmount; HttpClients httpClient = new HttpClients(); string jsonString = JsonConvert.SerializeObject(tempTrans); var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json"); var response = httpClient.PostAsync("api/posprocess/insertpostemptransdata", httpContent); if (response.IsSuccessStatusCode) { var tempTranscation = response.Content.ReadAsAsync <POSTempTrans>().Result; SettingHelpers.CurrentTempTransId = tempTranscation.Id; // bool result = InsertTempTranscationItemData(cpoDetailData.CPOItemDetailPOS.ToList()); return(true); } return(false); }
/// <summary> /// this method is used for fetching customer purchase order list. /// </summary> /// <param name="companyId"></param> /// <returns>list of object of CustomerPOAC</returns> public List <CustomerPOAC> GetCustomerPOList(int companyId) { try { var date = DateTime.UtcNow.Subtract(TimeSpan.FromDays(14)); var customerpoList = new List <CustomerPOAC>(); var cpoList = _customerPOContext.Fetch(x => x.UserDetail.Branch.CompanyId == companyId).OrderByDescending(x => x.CreatedDateTime).ToList(); foreach (var cpo in cpoList) { var isInList = false; if (cpo.CollectionDate != null) { if (cpo.CollectionDate > date) { isInList = true; } } else { isInList = true; } if (isInList) { CustomerPOAC cpoAC = new CustomerPOAC { CollectingBranchId = cpo.CollectingBranchId, CancelationDate = cpo.CancelationDate, CollectingBranchName = cpo.CollectingBranch.Name, CollectionDate = cpo.CollectionDate, Comments = cpo.Comments, CustomerId = cpo.CustomerId, CustomerPOId = cpo.Id, MembershipCode = cpo.CustomerProfile.MembershipCode, DueDate = cpo.DueDate, InitiationBranchId = cpo.InitiationBranchId, InitiationBranchName = cpo.InitiationBranch.Name, InitiationDate = cpo.InitiationDate, InitiatorId = cpo.InitiatorId, IsCancel = cpo.IsCancel, IsSPORequired = cpo.IsSPORequired, IsCollected = cpo.IsCollected, ModifiedBy = cpo.ModifiedBy, PurchaseOrderNo = cpo.PurchaseOrderNo, Total = cpo.TotalCPOAmount, CustomerName = cpo.CustomerProfile.Name, CustomerMobile = cpo.CustomerProfile.Mobile }; customerpoList.Add(cpoAC); } } return(customerpoList); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
/// <summary> /// this method is used for fetching customer purchase order. /// </summary> /// <param name="Id">Id of the Customer Purchase Order</param> /// <returns>object of CustomerPOAC</returns> public CustomerPOAC GetCustomerPO(int Id) { try { var cpo = _customerPOContext.Find(Id); var cpoItemList = _CPOItemContext.Fetch(x => x.CPOId == Id).ToList(); var additionalCostList = _CPOAdditionalCostContext.Fetch(x => x.CPOId == Id).ToList(); var cpoPaymentList = _cpoPaymentContext.Fetch(x => x.CPOId == Id).ToList(); CustomerPOAC cpoAC = new CustomerPOAC(); cpoAC.CustomerPOId = cpo.Id; cpoAC.InitiationDate = cpo.InitiationDate; cpoAC.Comments = cpo.Comments; cpoAC.TotalCPOAmount = cpo.TotalCPOAmount; cpoAC.Customer = cpo.CustomerProfile; cpoAC.PurchaseOrderNo = cpo.PurchaseOrderNo; cpoAC.InitiationBranchId = cpo.InitiationBranchId; cpoAC.InitiationBranchName = cpo.InitiationBranch.Name; cpoAC.InitiatorId = cpo.InitiatorId; cpoAC.IsCancel = cpo.IsCancel; cpoAC.IsSPORequired = cpo.IsSPORequired; cpoAC.DueDate = cpo.DueDate; cpoAC.CancelationDate = cpo.CancelationDate; cpoAC.IsCollected = cpo.IsCollected; cpoAC.CollectingBranchId = cpo.CollectingBranchId; cpoAC.CollectingBranchName = cpo.CollectingBranch.Name; cpoAC.CollectionDate = cpo.CollectionDate; cpoAC.ModifiedBy = cpo.ModifiedBy; cpoAC.CPOPayment = cpoPaymentList; cpoAC.CPOItem = cpoItemList; cpoAC.CPOAdditionalCost = additionalCostList; return(cpoAC); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }