/// <summary> /// Adds the draft bill. /// </summary> /// <param name="oHostSecurityToken">The HostSecurityToken with Logon Id.</param> /// <param name="bill">The bill.</param> /// <returns></returns> public DraftBillReturnValue AddDraftBill(HostSecurityToken oHostSecurityToken, DraftBill bill) { DraftBillReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.AddDraftBill(Functions.GetLogonIdFromToken(oHostSecurityToken), bill); } else { returnValue = new DraftBillReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Gets the control data. /// </summary> /// <returns></returns> private DraftBill GetControlData() { DraftBill bill = new DraftBill(); try { if (_txtTotal.Text == "0.00") { throw new Exception("Unable to create a zero draft bill with no disbs or time selected."); } bill.DraftBillDate = Convert.ToDateTime(_ccDraftBillDate.DateText); bill.ProfitCosts = Convert.ToDecimal(_txtCosts.Text.Trim()); bill.VATAmount = Convert.ToDecimal(_txtTotalVAT.Text.Trim()); bill.VATRateId = Convert.ToInt32(GetValueOnIndex(_ddlVATRate.SelectedValue, 0)); if (string.IsNullOrEmpty(_ccUnbilledTimeUpto.DateText)) { bill.BilledTimeUpto = DataConstants.BlankDate; } else { bill.BilledTimeUpto = Convert.ToDateTime(_ccUnbilledTimeUpto.DateText); } bill.ProjectId = (Guid)Session[SessionName.ProjectId]; bill.PostingDescription = _txtDraftBillDescription.Text.Trim(); bill.UnbilledPaidNonVATableNotes = _txtNonVatableNotes.Text.Trim(); bill.UnbilledPaidVATableNotes = _txtVatableNotes.Text.Trim(); bill.AntiNonVATableNotes = _txtAnticipatedNonVatableNotes.Text.Trim(); bill.AntiVATableNotes = _txtAnticipatedVatableNotes.Text.Trim(); bill.TimeTransactions = GetTimeTransactions().ToArray(); List<DisbursementLedgerTransaction> transactions = new List<DisbursementLedgerTransaction>(); GetPaidDisbursementsFromGrid(transactions, _grdUnBilledPaidNonVatable, false); bill.UnBilledPaidNonVatableList = transactions.ToArray(); transactions.Clear(); GetPaidDisbursementsFromGrid(transactions, _grdUnbilledPaidVatable, true); bill.UnBilledPaidVatableList = transactions.ToArray(); transactions.Clear(); List<AnticipatedDisbursementLedgerTransaction> antiTransactions = new List<AnticipatedDisbursementLedgerTransaction>(); GetUnpaidDisbursementsFromGrid(antiTransactions, _grdAnticipatedNonVatable, false); bill.AnticipatedDisbursementNonVatableList = antiTransactions.ToArray(); antiTransactions.Clear(); GetUnpaidDisbursementsFromGrid(antiTransactions, _grdAnticipatedVatable, true); bill.AnticipatedDisbursementVatableList = antiTransactions.ToArray(); } catch (Exception ex) { throw ex; } return bill; }
/// <summary> /// Adds the draft bill. /// </summary> /// <param name="oHostSecurityToken">The HostSecurityToken with Logon Id.</param> /// <param name="bill">The bill.</param> /// <returns></returns> public DraftBillReturnValue AddDraftBill(HostSecurityToken oHostSecurityToken, DraftBill bill) { DraftBillReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.AddDraftBill(Functions.GetLogonIdFromToken(oHostSecurityToken), bill); } else { returnValue = new DraftBillReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }
/// <summary> /// Adds the draft bill. /// </summary> /// <param name="logonId">The logon id.</param> /// <param name="bill">The bill.</param> /// <returns></returns> public DraftBillReturnValue AddDraftBill(Guid logonId, DraftBill bill) { DraftBillReturnValue returnValue = new DraftBillReturnValue(); try { // Get the logged on user from the current logons and add their // ApplicationSettings the list of concurrent sessions. Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: // Can do everything break; case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: throw new Exception("Access denied"); default: throw new Exception("Access denied"); } // Ensure we have permission if (!UserSecuritySettings.GetUserSecuitySettings(145)) throw new Exception("You do not have sufficient permissions to carry out this request"); string errorMessage = string.Empty; string warningMessage = string.Empty; SrvDraftBill srvDraftBill = new SrvDraftBill(); srvDraftBill.ProjectId = bill.ProjectId; bool success = srvDraftBill.ValidateProjectId(out errorMessage, out warningMessage); if (success) { srvDraftBill.SetDefaultDisbursementLedger(); } else { throw new Exception(errorMessage); } srvDraftBill.Date = bill.DraftBillDate.Date; srvDraftBill.ProfitCosts = bill.ProfitCosts; srvDraftBill.VATAmount = bill.VATAmount; srvDraftBill.VATRateId = bill.VATRateId; srvDraftBill.BilledTimeUpto = bill.BilledTimeUpto; srvDraftBill.PostingDescriptionDetails = bill.PostingDescription; srvDraftBill.UnbPaidNonVatNotes = bill.UnbilledPaidNonVATableNotes; srvDraftBill.UnbPaidVatNotes = bill.UnbilledPaidVATableNotes; srvDraftBill.AntiNonVatNotes = bill.AntiNonVATableNotes; srvDraftBill.AntiVatNotes = bill.AntiVATableNotes; this.SetDraftBillTransValues(bill.UnBilledPaidNonVatableList, srvDraftBill.UnBilledPaidNonVatableDisbsList); this.SetDraftBillTransValues(bill.UnBilledPaidVatableList, srvDraftBill.UnBilledPaidVatableDisbsList); this.SetDraftBillAnticipatedTransValues(bill.AnticipatedDisbursementNonVatableList, srvDraftBill.AntiDisbsNonVatableList); this.SetDraftBillAnticipatedTransValues(bill.AnticipatedDisbursementVatableList, srvDraftBill.AntiDisbsVatableList); this.SetTimeValues(bill.TimeTransactions, srvDraftBill.TimeTransaction); var primaryClientAssociation = new BrAssociations().GetAssociationForMatterByProjectIdAndRoleId(srvDraftBill.ProjectId, 1); if (primaryClientAssociation.ProjectAssociations.Count > 0) { var billPayer = new DraftBillPayer() { MemberId = primaryClientAssociation.ProjectAssociations[0].MemberID, OrgId = primaryClientAssociation.ProjectAssociations[0].OrgID, Amount = srvDraftBill.GetBillTotal(), BillPayerStatusId = 1, CashCollActDue = DataConstants.BlankDate, Narrative = string.Empty, AddressId = primaryClientAssociation.ProjectAssociations[0].MemberID == DataConstants.DummyGuid ? SrvAddressLookup.GetOrganisationAddressForBilling(primaryClientAssociation.ProjectAssociations[0].OrgID) : SrvAddressLookup.GetMemberAddressForBilling(primaryClientAssociation.ProjectAssociations[0].MemberID) }; srvDraftBill.BillPayers.Add(billPayer); } returnValue.Success = srvDraftBill.Save(out errorMessage); bill.DraftBillId = srvDraftBill.Id; returnValue.DraftBill = bill; returnValue.Message = errorMessage; } finally { // Remove the logged on user's ApplicationSettings from the // list of concurrent sessions Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception ex) { returnValue.Success = false; returnValue.Message = ex.Message; } return returnValue; }
/// <summary> /// Returns draft bill details by draft bill id /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service</param> /// <param name="draftBillId">Draft bill id to populate</param> /// <returns></returns> public DraftBillReturnValue GetDraftBill(Guid logonId, int draftBillId) { DraftBillReturnValue returnValue = new DraftBillReturnValue(); try { // Get the logged on user from the current logons and add their // ApplicationSettings the list of concurrent sessions. Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: // Can do everything break; case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: throw new Exception("Access denied"); default: throw new Exception("Access denied"); } SrvDraftBill srvDraftBill = new SrvDraftBill(); srvDraftBill.Id = draftBillId; srvDraftBill.Load(draftBillId); DraftBill draftBill = new DraftBill(); draftBill.DraftBillId = srvDraftBill.Id; draftBill.DraftBillDate = srvDraftBill.Date; draftBill.ProfitCosts = srvDraftBill.ProfitCosts; draftBill.VATAmount = srvDraftBill.VATAmount; draftBill.VATRateId = srvDraftBill.VATRateId; draftBill.BilledTimeUpto = srvDraftBill.BilledTimeUpto; draftBill.IsProcessed = srvDraftBill.IsProcessed; draftBill.IsSubmitted = srvDraftBill.IsSubmitted; draftBill.ProjectId = srvDraftBill.ProjectId; draftBill.PostingDescription = srvDraftBill.PostingDescriptionDetails; draftBill.UnbilledPaidNonVATableNotes = srvDraftBill.UnbPaidNonVatNotes; draftBill.UnbilledPaidVATableNotes = srvDraftBill.UnbPaidVatNotes; draftBill.AntiNonVATableNotes = srvDraftBill.AntiNonVatNotes; draftBill.AntiVATableNotes = srvDraftBill.AntiVatNotes; returnValue.DraftBill = draftBill; } finally { // Remove the logged on user's ApplicationSettings from the // list of concurrent sessions Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception ex) { returnValue.Success = false; returnValue.Message = ex.Message; } return returnValue; }