/// <summary> /// Created By : Ashwajit Bansod /// Created Date : 10-Jan-2018 /// Created For : To get Quick book bill id. /// </summary> /// <param name="BillId"></param> /// <returns></returns> public long GetBillQBKId(long BillId) { long bllQbk_Id = 0; var data = new BillDataServiceModel(); try { if (BillId > 0) { data = _workorderems.Bills.Where(x => x.BLL_Id == BillId).Select(a => new BillDataServiceModel { QuickBookBillId = a.BLL_QBKId }).FirstOrDefault(); bllQbk_Id = data.QuickBookBillId; } else { return(bllQbk_Id); } } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public long GetBillQBKId(long BillId)", "Exception While Getting quickbook Id of bill.", BillId); throw; } return(bllQbk_Id); }
/// <summary> /// Created By : Ashwajit bansod /// Created Date : 12-OCT-2018 /// Created For : To Save Bill /// </summary> /// <param name="objBillDataServiceModel"></param> /// <returns></returns> public bool SaveBillDetails(BillDataServiceModel objBillDataServiceModel) { bool isBillSaved = false; string Action = ""; string DeliverStatus = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); string LocationName = string.Empty; string UserName = string.Empty; try { if (objBillDataServiceModel != null && objBillDataServiceModel.VendorId > 0 && objBillDataServiceModel.LocationId > 0 && objBillDataServiceModel.UserId > 0) { Action = "I"; if (objBillDataServiceModel.PODId > 0) { DeliverStatus = "Y"; var saveBillData = _workorderems.spSetBill(Action, objBillDataServiceModel.QuickBookBillId, objBillDataServiceModel.PODId, null, null, objBillDataServiceModel.VendorId, objBillDataServiceModel.LocationId, objBillDataServiceModel.BillType, objBillDataServiceModel.PoMisBdaAmount, objBillDataServiceModel.InvoiceAmount, objBillDataServiceModel.InvoiceDate, objBillDataServiceModel.InvoiceDocument, objBillDataServiceModel.UserId, null, DeliverStatus); string[] Quantity = { }; string[] POF = { }; string[] ActiveId = objBillDataServiceModel.IsActive.Split(','); if (objBillDataServiceModel.Quantity != null) { Quantity = objBillDataServiceModel.Quantity.Split(','); } if (objBillDataServiceModel.POF_ID != null) { POF = objBillDataServiceModel.POF_ID.Split(','); } if (objBillDataServiceModel.IsActive != "") { for (int i = 0; i < ActiveId.Length; i++) { if (ActiveId[i] != null) { //ActiveId[i] = "N"; Action = "U"; long POF_ID = Convert.ToInt64(POF[i]); long QantityData = Convert.ToInt64(Quantity[i]); long FacilityId = Convert.ToInt64(ActiveId[i]); DeliverStatus = "N"; var saveFacilityData = _workorderems.spSetPOFacilityItem(Action, POF_ID, objBillDataServiceModel.PODId, FacilityId, QantityData, DeliverStatus); } } } var userData = _workorderems.UserRegistrations.Where(x => x.UserId == objBillDataServiceModel.UserId && x.IsDeleted == false && x.IsEmailVerify == true).FirstOrDefault(); var locationData = _workorderems.LocationMasters.Where(x => x.LocationId == objBillDataServiceModel.LocationId && x.IsDeleted == false).FirstOrDefault(); #region Save DAR LocationName = locationData.LocationServices.ToString(); UserName = userData.FirstName + " " + userData.LastName; objDAR.ActivityDetails = DarMessage.BillCreated(userData.FirstName + "" + userData.LastName, locationData.LocationName, objBillDataServiceModel.PODId); objDAR.TaskType = (long)TaskTypeCategory.BillCreated; objDAR.UserId = objBillDataServiceModel.UserId; objDAR.CreatedBy = objBillDataServiceModel.UserId; objDAR.LocationId = objBillDataServiceModel.LocationId; objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } else { var savePreBill = _workorderems.spSetPreBill(Action, objBillDataServiceModel.BillNumber, objBillDataServiceModel.LocationId, objBillDataServiceModel.VendorId, objBillDataServiceModel.Comment, objBillDataServiceModel.InvoiceAmount, objBillDataServiceModel.InvoiceDate, objBillDataServiceModel.InvoiceDocument, objBillDataServiceModel.UserId, null, "N"); if (objBillDataServiceModel.FacilityListForManualBill != null && objBillDataServiceModel.FacilityListForManualBill.Count() > 0) { foreach (var item in objBillDataServiceModel.FacilityListForManualBill) { if (item.UnitPrice > 0) { var saveFacility = _workorderems.spSetBillFacilityItem(Action, null, objBillDataServiceModel.BillNumber, item.COM_FacilityId, item.Quantity, item.UnitPrice, item.Status); } } } //var saveBillData = _workorderems.spSetBill(Action,null, null, null, // objBillDataServiceModel.VendorId, objBillDataServiceModel.LocationId, // objBillDataServiceModel.BillType, null, // objBillDataServiceModel.InvoiceAmount, objBillDataServiceModel.InvoiceDate, objBillDataServiceModel.InvoiceDocument, // objBillDataServiceModel.UserId, null, "Y"); } var objNotify = new NotificationDetailModel(); var _ICommonMethod = new CommonMethodManager(); var objModel = new CommonApproval <ApprovalInput>(); var approvalInput = new ApprovalInput(); approvalInput.Amount = Convert.ToDecimal(objBillDataServiceModel.InvoiceAmount); approvalInput.UserId = objBillDataServiceModel.UserId; approvalInput.ModuleName = "eCounting"; var getRuleData = objModel.GetApprovalRuleData(approvalInput); if (getRuleData != null) { objNotify.CreatedBy = objBillDataServiceModel.UserId; objNotify.CreatedDate = DateTime.UtcNow; objNotify.AssignTo = getRuleData.UserId; if (objBillDataServiceModel.PODId > 0) { objNotify.BillID = objBillDataServiceModel.PODId; } else { objNotify.BillID = objBillDataServiceModel.BillNumber; } var saveDataForNotification = _ICommonMethod.SaveNotificationDetail(objNotify); } if (getRuleData.DeviceId != null) { var objEmailHelper = new EmailHelper(); var objTemplateModel = new TemplateModel(); objEmailHelper.emailid = getRuleData.Email; objEmailHelper.ManagerName = getRuleData.ManagerName; objEmailHelper.LocationName = LocationName; objEmailHelper.UserName = UserName; objEmailHelper.BillId = objNotify.BillID.ToString(); //objEmailHelper.InfractionStatus = obj.Status; objEmailHelper.MailType = "BILLAPPROVE"; objEmailHelper.SentBy = objBillDataServiceModel.UserId; objEmailHelper.LocationID = objDAR.LocationId; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); objEmailHelper.IsWorkable = true; string message = PushNotificationMessages.BillCreate(objNotify.BillID.ToString(), objEmailHelper.UserName, objEmailHelper.LocationName); PushNotificationFCM.FCMAndroid(message, getRuleData.DeviceId, objEmailHelper); } isBillSaved = true; } else { isBillSaved = false; } } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public BillDataServiceModel SaveBillDetails(BillDataServiceModel objBillDataServiceModel)", "Exception While Saving Bill Details.", null); throw; } return(isBillSaved); }