/// <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;
 }
Exemple #2
0
        /// <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);
        }
Exemple #3
0
        /// <summary>
        /// Submits selected draft bills
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="selectedDraftBillIds"></param>
        /// <returns></returns>
        public DraftBillReturnValue SubmitDraftBill(HostSecurityToken oHostSecurityToken, List <int> selectedDraftBillIds)
        {
            DraftBillReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oAccountService = new AccountsService();
                returnValue     = oAccountService.SubmitDraftBill(Functions.GetLogonIdFromToken(oHostSecurityToken), selectedDraftBillIds);
            }
            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>
        /// Submits selected draft bills
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="selectedDraftBillIds"></param>
        /// <returns></returns>
        public DraftBillReturnValue SubmitDraftBill(Guid logonId, List<int> selectedDraftBillIds)
        {
            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");
                    }

                    for (int index = 0; index < selectedDraftBillIds.Count; index++)
                    {
                        int draftBillId = selectedDraftBillIds[index];
                        SrvDraftBillCommon.SubmitDraftBill(draftBillId);
                    }

                    returnValue.Success = true;
                    returnValue.Message = string.Empty;
                }
                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;
        }
Exemple #7
0
        /// <summary>
        /// Submits unposted draft bills to accounts
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void _btnSubmit_Click(object sender, EventArgs e)
        {
            AccountsServiceClient accountsService = null;

            try
            {
                accountsService = new AccountsServiceClient();

                CheckBox   checkboxSelect = null;
                List <int> arrListSelectedDraftBillIds = new List <int>();

                foreach (GridViewRow gridViewRow in _grdDraftBills.Rows)
                {
                    checkboxSelect = (CheckBox)gridViewRow.FindControl("_chkBxSelect");
                    if (checkboxSelect.Checked == true)
                    {
                        Label _lblDraftBillId = ((Label)gridViewRow.FindControl("_lblDraftBillId"));
                        arrListSelectedDraftBillIds.Add(Convert.ToInt32(_lblDraftBillId.Text));
                    }
                }

                int[] arrSelectedIds = arrListSelectedDraftBillIds.ToArray();

                // If there are any selected draft bill ids to be submitted, then call submit method.
                if (arrListSelectedDraftBillIds.Count > 0)
                {
                    Guid logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                    DraftBillReturnValue returnValue = accountsService.SubmitDraftBill(logonId, arrSelectedIds);

                    if (returnValue.Success)
                    {
                        _hdnRefresh.Value = "true";
                        // After submission again binds unposted draft bills.
                        BindDraftBills();
                    }
                    else
                    {
                        _lblMessage.CssClass = "errorMessage";
                        _lblMessage.Text     = returnValue.Message;
                    }
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text     = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text     = ex.Message;
            }
            finally
            {
                if (accountsService != null)
                {
                    if (accountsService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        accountsService.Close();
                    }
                }
            }
        }
 /// <summary>
 /// Submits selected draft bills
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="selectedDraftBillIds"></param>
 /// <returns></returns>
 public DraftBillReturnValue SubmitDraftBill(HostSecurityToken oHostSecurityToken, List<int> selectedDraftBillIds)
 {
     DraftBillReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oAccountService = new AccountsService();
         returnValue = oAccountService.SubmitDraftBill(Functions.GetLogonIdFromToken(oHostSecurityToken), selectedDraftBillIds);
     }
     else
     {
         returnValue = new DraftBillReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }