Ejemplo n.º 1
0
        public void TransformCheque()
        {
            //Arrange
            ChequeRequest request = new ChequeRequest
            {
                PersonName   = "Berry ",
                ChequeAmount = 1234.5m
            };

            string requestAmountInLetter = " one thousand and two hundred and thirty-four dollars and fifty cents ";

            //Act

            var newChequeMessage                       = client.PostAsJsonAsync(addChequeRoute, request).GetAwaiter().GetResult();
            var chequeId                               = newChequeMessage.Content.ReadAsAsync <int>().GetAwaiter().GetResult();
            HttpResponseMessage response               = client.GetAsync(string.Format(findChequeRoute, chequeId)).GetAwaiter().GetResult();
            ChequeResponse      retrivedCheque         = response.Content.ReadAsAsync <ChequeResponse>().GetAwaiter().GetResult();
            HttpResponseMessage updatedChequesResponse = client.PutAsJsonAsync(transformChequeRoute, retrivedCheque).GetAwaiter().GetResult();
            ChequeResponse      updatedCheque          = updatedChequesResponse.Content.ReadAsAsync <ChequeResponse>().GetAwaiter().GetResult();

            //Assert
            Assert.AreEqual(HttpStatusCode.Created, newChequeMessage.StatusCode);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);

            Assert.IsNotNull(retrivedCheque);
            Assert.AreEqual(retrivedCheque.PersonName, request.PersonName.ToUpper());

            Assert.AreEqual(HttpStatusCode.OK, updatedChequesResponse.StatusCode);
            Assert.IsNotNull(updatedCheque.ChequeAmountInLetter);
            Assert.AreEqual(requestAmountInLetter.Trim(), updatedCheque.ChequeAmountInLetter.Trim());
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> PutChequeRequest(int id, ChequeRequest chequeRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != chequeRequest.ChequeNumber)
            {
                return(BadRequest());
            }

            db.Entry(chequeRequest).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChequeRequestExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> PostChequeRequest(ChequeRequest chequeRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ChequeRequests.Add(chequeRequest);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ChequeRequestExists(chequeRequest.ChequeNumber))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = chequeRequest.ChequeNumber }, chequeRequest));
        }
Ejemplo n.º 4
0
        public void IsValidCheque_ExpectedResult(ChequeRequest input, string expectResult)
        {
            var chequeService = new ChequeService();
            var message       = "";
            var result        = chequeService.IsValidCheque(input, out message);

            Assert.IsTrue(message.Contains(expectResult), $"incorrect validation result, expect {expectResult} but {message}");
        }
Ejemplo n.º 5
0
        public async Task <IHttpActionResult> GetChequeRequest(int id)
        {
            ChequeRequest chequeRequest = await db.ChequeRequests.FindAsync(id);

            if (chequeRequest == null)
            {
                return(NotFound());
            }

            return(Ok(chequeRequest));
        }
Ejemplo n.º 6
0
        public ChequeResponse Create(ChequeRequest request)
        {
            ValidatEntity(request);
            ChequeResponse response = new ChequeResponse
            {
                DateTime   = DateTime.Now,
                PersonName = request.PersonName.ToUpper(),
                Amount     = request.ChequeAmount.Value,
            };

            return(response);
        }
Ejemplo n.º 7
0
        public async Task <IHttpActionResult> DeleteChequeRequest(int id)
        {
            ChequeRequest chequeRequest = await db.ChequeRequests.FindAsync(id);

            if (chequeRequest == null)
            {
                return(NotFound());
            }

            db.ChequeRequests.Remove(chequeRequest);
            await db.SaveChangesAsync();

            return(Ok(chequeRequest));
        }
Ejemplo n.º 8
0
        public void AddChequeWithInvalidName()
        {
            //Arrange
            ChequeRequest request = new ChequeRequest
            {
                PersonName   = "Jame123",
                ChequeAmount = 12.0m
            };

            //Act &Assert
            HttpResponseMessage response = client.PostAsJsonAsync(addChequeRoute, request).GetAwaiter().GetResult();

            Assert.AreEqual(response.StatusCode, HttpStatusCode.BadRequest);
        }
Ejemplo n.º 9
0
        public ActionResult AddCheque(ChequeRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(View("Add"));
            }

            HttpResponseMessage message = HttpClient.PostAsJsonAsync(AddChequeRoute, request).GetAwaiter().GetResult();

            if (message.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                HttpError error = message.Content.ReadAsAsync <HttpError>().GetAwaiter().GetResult();
                return(new HttpStatusCodeResult(message.StatusCode, error.Message));
            }
        }
Ejemplo n.º 10
0
        public HttpResponseMessage Put(int id, [FromBody] ChequeRequest cheque)
        {
            if (string.IsNullOrEmpty(cheque.LastName) || string.IsNullOrEmpty(cheque.FirstName))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new BaseApiResponse
                {
                    Code = InternalApiStatusCode.FailedRequestValidation,
                    Message = "Invalid cheque object"
                }));
            }

            var chequeResposne = new ChequeResponse();

            try
            {
                var chequeResult = _chequeRepository.Update(new ChequeDto
                {
                    ChequeId  = id,
                    LastName  = cheque.LastName,
                    FirstName = cheque.FirstName,
                    Amount    = cheque.Amount,
                });

                if (chequeResult == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound, new BaseApiResponse
                    {
                        Code = InternalApiStatusCode.Error,
                        Message = "cheque is not found"
                    }));
                }

                chequeResposne.Cheque  = chequeResult;
                chequeResposne.Code    = InternalApiStatusCode.Success;
                chequeResposne.Message = "cheque is updated";

                return(Request.CreateResponse(HttpStatusCode.OK, chequeResposne));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Ejemplo n.º 11
0
 public HttpResponseMessage Post([FromBody] ChequeRequest request)
 {
     try
     {
         ChequeResponse newCheque = chequeComponent.Create(request);
         int            recordId  = chequeData.AddCheque(newCheque);
         return(Request.CreateResponse(HttpStatusCode.Created, recordId));
     }
     catch (ValidationException ex)
     {
         var errorResponse = Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message, ex);
         return(errorResponse);
     }
     catch (Exception ex)
     {
         var errorResponse = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message, ex);
         return(errorResponse);
     }
 }
Ejemplo n.º 12
0
        public void Seed()
        {
            ChequeController chequeController = new ChequeController(new HttpClientProvider());
            ChequeRequest    cheque1          = new ChequeRequest
            {
                ChequeAmount = 125.50m,
                PersonName   = "John Smith"
            };

            chequeController.AddSampleCheque(cheque1);

            ChequeRequest cheque2 = new ChequeRequest
            {
                ChequeAmount = 400.20m,
                PersonName   = "Mary Brown"
            };

            chequeController.AddSampleCheque(cheque2);
        }
        // Post: api/Cheque/create
        public HttpResponseMessage Post([FromBody] ChequeRequest request)
        {
            var chequeService = new ChequeService();
            var message       = string.Empty;
            var isValid       = chequeService.IsValidCheque(request, out message);

            if (isValid)
            {
                var amountWord = chequeService.GetAmountWord(request.Amount);
                return(ToJson(new Cheque()
                {
                    ChequeDate = request.ChequeDate, Amount = request.Amount, Payee = request.Payee, AmountWord = amountWord
                }));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, message));
            }
        }
        public bool IsValidCheque(ChequeRequest request, out string message)
        {
            message = string.Empty;
            //by Cheques Act 1986 Australian cheques are stale after 15 months by law
            if (request.ChequeDate > DateTime.Today.AddMonths(15) || request.ChequeDate < DateTime.Today.AddMonths(-15))
            {
                message =
                    "Please enter a valid cheque date. Australian Cheques are stale after 15 months by law (Cheques Act)";
            }
            else if (string.IsNullOrEmpty(request.Payee) || request.Payee.Length <= 1)
            {
                message = "Please enter a valid payee.";
            }
            else if (request.Amount <= 0 || request.Amount >= 10000000000000.00)
            {
                message = "Please enter a valid cheque amount.";
            }

            return(string.IsNullOrEmpty(message));
        }
Ejemplo n.º 15
0
        public void AddCheque()
        {
            //Arrange
            ChequeRequest request = new ChequeRequest
            {
                PersonName   = "Jame Brown",
                ChequeAmount = 1234.5m
            };

            //Act

            var resultBefore     = client.GetAsync(allChequesRoute).GetAwaiter().GetResult().Content.ReadAsAsync <IEnumerable <ChequeResponse> >().GetAwaiter().GetResult();
            var newChequeMessage = client.PostAsJsonAsync(addChequeRoute, request).GetAwaiter().GetResult();
            var id          = newChequeMessage.Content.ReadAsAsync <int>().GetAwaiter().GetResult();
            var resultAfter = client.GetAsync(allChequesRoute).GetAwaiter().GetResult().Content.ReadAsAsync <IEnumerable <ChequeResponse> >().GetAwaiter().GetResult();

            //Assert
            Assert.AreEqual(HttpStatusCode.Created, newChequeMessage.StatusCode);
            Assert.Greater(resultAfter.Count(), resultBefore.Count());
            Assert.Greater(id, resultBefore.Count());
        }
Ejemplo n.º 16
0
        public void FindCheque()
        {
            //Arrange
            ChequeRequest request = new ChequeRequest
            {
                PersonName   = "New Person",
                ChequeAmount = 1234.5m
            };

            //Act

            var newChequeMessage = client.PostAsJsonAsync(addChequeRoute, request).GetAwaiter().GetResult();
            var id = newChequeMessage.Content.ReadAsAsync <int>().GetAwaiter().GetResult();
            HttpResponseMessage response = client.GetAsync(string.Format(findChequeRoute, id)).GetAwaiter().GetResult();
            ChequeResponse      cheque   = response.Content.ReadAsAsync <ChequeResponse>().GetAwaiter().GetResult();

            //Assert
            Assert.AreEqual(HttpStatusCode.Created, newChequeMessage.StatusCode);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(cheque);
            Assert.AreEqual(cheque.PersonName, request.PersonName.ToUpper());
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Adds or edits office cheque requests depending on the 'IsClientChequeRequest' property
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="chequeRequest">ChequeRequest properties to add/edit cheque request.</param>
        /// <returns>Returns cheque request id after adding or editting cheque request.</returns>
        public ChequeRequestReturnValue SaveOfficeChequeRequest(HostSecurityToken oHostSecurityToken, ChequeRequest chequeRequest)
        {
            ChequeRequestReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oAccountService = new AccountsService();
                returnValue     = oAccountService.SaveOfficeChequeRequest(Functions.GetLogonIdFromToken(oHostSecurityToken), chequeRequest);
            }
            else
            {
                returnValue         = new ChequeRequestReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
        /// <summary>
        /// Gets the client bank id by project id
        /// Get OfficeVattable
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="projectId">Project id to get client bank id</param>  
        public ChequeRequestReturnValue GetDefaultChequeRequestDetails(Guid logonId, Guid projectId)
        {
            ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue();

            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");
                    }

                    ChequeRequest chequeReq = new ChequeRequest();
                    chequeReq.BankId = SrvMatterCommon.GetClientBankIdByProjectId(projectId);
                    chequeReq.BankOfficeId = SrvMatterCommon.GetOfficeBankIdByProjectId(projectId);
                    Guid matterBranchId = SrvMatterCommon.GetMatterBranchGuid(projectId);
                    if (matterBranchId != PmsCommonData.DataConstants.DummyGuid)
                    {
                        bool branchNoVat = SrvBranchCommon.GetBranchNoVAT(matterBranchId);
                        if (branchNoVat)
                        {
                            chequeReq.OfficeVATTable = IlbCommon.YesNo.No;
                        }
                    }

                    returnValue.ChequeRequest = chequeReq;
                }
                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>
        /// Adds or edits office cheque requests depending on the 'IsClientChequeRequest' property
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="chequeRequest">ChequeRequest properties to add/edit cheque request.</param>
        /// <returns>Returns cheque request id after adding or editting cheque request.</returns>
        public ChequeRequestReturnValue SaveOfficeChequeRequest(Guid logonId, ChequeRequest chequeRequest)
        {
            ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue();

            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");
                    }

                    //163 - Create Office Cheque Requests

                    //if (!UserSecuritySettings.GetUserSecuitySettings(163))
                    if (!UserSecuritySettings.GetUserSecuitySettings((int)AccountsSettings.CreateOfficeChequeRequest))
                        throw new Exception("You do not have sufficient permissions to carry out this request");

                    SrvOfficeChequeRequest srvOfficeChequeRequest = new SrvOfficeChequeRequest();
                    srvOfficeChequeRequest.Id = chequeRequest.ChequeRequestId;
                    srvOfficeChequeRequest.ProjectId = chequeRequest.ProjectId;
                    srvOfficeChequeRequest.Date = chequeRequest.ChequeRequestDate;
                    srvOfficeChequeRequest.DisbursementTypeId = chequeRequest.DisbursementTypeId;
                    srvOfficeChequeRequest.Description = chequeRequest.ChequeRequestDescription;
                    srvOfficeChequeRequest.Payee = chequeRequest.ChequeRequestPayee;
                    srvOfficeChequeRequest.OfficeBankId = chequeRequest.BankId;
                    srvOfficeChequeRequest.Amount = chequeRequest.ChequeRequestAmount;
                    srvOfficeChequeRequest.OfficeVATTable = chequeRequest.OfficeVATTable;
                    srvOfficeChequeRequest.VATRateId = chequeRequest.VATRateId;
                    srvOfficeChequeRequest.VATAmount = chequeRequest.VATAmount;
                    srvOfficeChequeRequest.IsAnticipated = chequeRequest.IsChequeRequestAnticipated;
                    srvOfficeChequeRequest.MemberId = chequeRequest.MemberId;

                    string errorMessage = string.Empty;
                    string caption = string.Empty;
                    bool isSaveSuccessful = srvOfficeChequeRequest.Save(out errorMessage, out caption);

                    if (chequeRequest.ChequeRequestId == 0)
                    {
                        chequeRequest.ChequeRequestId = srvOfficeChequeRequest.Id;
                    }

                    returnValue.ChequeRequest = chequeRequest;
                    returnValue.Success = isSaveSuccessful;

                    if (returnValue.Success)
                    {
                        // if client cheque request is saved then authorises it.
                        if (chequeRequest.IsChequeRequestAuthorised && UserSecuritySettings.GetUserSecuitySettings((int)AccountsSettings.AuthoriseClientChequeRequest))
                        {
                            if (UserSecuritySettings.GetUserSecuitySettings((int)AccountsSettings.AuthoriseChequeRequestHigherAmount))
                            {

                                SrvOfficeChequeRequestCommon.AddAuthoriseOfficeChequeRequests(srvOfficeChequeRequest.Id, UserInformation.Instance.UserMemberId, DateTime.Now);
                            }
                            else
                            {
                                Decimal officeChequeRequestHigherAmount = Convert.ToDecimal(UserSecuritySettings.GetUserSecuitySettingsFeatureValue((int)AccountsSettings.OfficeChequeRequestHigherAmount));

                                if (Convert.ToDecimal(srvOfficeChequeRequest.Amount) > officeChequeRequestHigherAmount)
                                {
                                    errorMessage = "You are not allowed to Authorise Off Cheque Requests over the value of £" +
                                                     officeChequeRequestHigherAmount.ToString("0.00") + ".";
                                }
                                else
                                {

                                    SrvOfficeChequeRequestCommon.AddAuthoriseOfficeChequeRequests(srvOfficeChequeRequest.Id, UserInformation.Instance.UserMemberId, DateTime.Now);
                                }
                            }
                        }

                        chequeRequest.ChequeRequestId = srvOfficeChequeRequest.Id;
                        returnValue.ChequeRequest = chequeRequest;
                    }

                    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>
        /// Adds or edits client cheque requests depending on the 'IsClientChequeRequest' property
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="chequeRequest">ChequeRequest properties to add/edit cheque request.</param>
        /// <returns>Returns cheque request id after adding or editting cheque request.</returns>
        public ChequeRequestReturnValue SaveClientChequeRequest(Guid logonId, ChequeRequest clientChequeRequest)
        {
            ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue();

            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");
                    }

                    //243 = RequestClientCredits
                    //242 = RequestClientDebits

                    if (clientChequeRequest.ClientChequeRequestsIsCredit)
                        if (!UserSecuritySettings.GetUserSecuitySettings((int)AccountsSettings.RequestClientCredits))
                            //if (!UserSecuritySettings.GetUserSecuitySettings(243))
                            throw new Exception("You do not have sufficient permissions to carry out this request");

                    if (!clientChequeRequest.ClientChequeRequestsIsCredit)
                        if (!UserSecuritySettings.GetUserSecuitySettings((int)AccountsSettings.RequestClientDebits))
                            //if (!UserSecuritySettings.GetUserSecuitySettings(242))
                            throw new Exception("You do not have sufficient permissions to carry out this request");

                    string errorMessage = string.Empty;
                    string warningMessage = string.Empty;
                    string errorCaption = string.Empty;

                    // Creates object for client cheque request service class
                    SrvClientChequeRequest srvClientChequeRequest = new SrvClientChequeRequest();

                    // Sets properties
                    srvClientChequeRequest.Id = clientChequeRequest.ChequeRequestId;
                    srvClientChequeRequest.ProjectId = clientChequeRequest.ProjectId;
                    srvClientChequeRequest.Date = clientChequeRequest.ChequeRequestDate;
                    srvClientChequeRequest.ClientBankId = clientChequeRequest.BankId;
                    srvClientChequeRequest.Description = clientChequeRequest.ChequeRequestDescription;
                    srvClientChequeRequest.Payee = clientChequeRequest.ChequeRequestPayee;
                    srvClientChequeRequest.Amount = clientChequeRequest.ChequeRequestAmount;
                    srvClientChequeRequest.Reference = clientChequeRequest.ChequeRequestReference;
                    srvClientChequeRequest.MemberId = clientChequeRequest.MemberId;
                    srvClientChequeRequest.ClearanceDaysChq = clientChequeRequest.ClientChequeRequestsClearanceDaysChq;
                    srvClientChequeRequest.ClearanceDaysElec = clientChequeRequest.ClientChequeRequestsClearanceDaysElec;
                    srvClientChequeRequest.ClearanceTypeId = clientChequeRequest.ClearanceTypeId;
                    srvClientChequeRequest.IsCredit = clientChequeRequest.ClientChequeRequestsIsCredit;

                    if (clientChequeRequest.ProceedIfOverDrawn)
                    {
                        // If the 'ProceedIfOverDrawn' flag is false then it should be true for next
                        // save click event. As its false for warning messages.
                        srvClientChequeRequest.ProceedIfOverDrawn = true;
                    }

                    returnValue.Success = srvClientChequeRequest.Save(out errorMessage, out warningMessage, out errorCaption);

                    if (returnValue.Success)
                    {
                        // if client cheque request is saved then authorises it.
                        if (clientChequeRequest.IsChequeRequestAuthorised && UserSecuritySettings.GetUserSecuitySettings((int)AccountsSettings.AuthoriseClientChequeRequest))
                        {
                            if (UserSecuritySettings.GetUserSecuitySettings((int)AccountsSettings.AuthoriseChequeRequestHigherAmount))
                            {
                                // As Suggested by client to use the overloaded method and requestId property
                                if (srvClientChequeRequest.RequesterId == UserInformation.Instance.DbUid)
                                {
                                    SrvClientChequeRequestCommon.AddAuthoriseClientChequeRequests(srvClientChequeRequest.Id, UserInformation.Instance.UserMemberId, DateTime.Now);
                                }
                                else
                                {
                                    SrvClientChequeRequestCommon.AddAuthoriseClientChequeRequests(srvClientChequeRequest.Id, UserInformation.Instance.UserMemberId, DateTime.Now, srvClientChequeRequest.RequesterId, srvClientChequeRequest.Description);
                                }
                            }
                            else
                            {
                                Decimal clientChequeRequestHigherAmount = Convert.ToDecimal(UserSecuritySettings.GetUserSecuitySettingsFeatureValue((int)AccountsSettings.ClientChequeRequestHigherAmount));

                                if (Convert.ToDecimal(srvClientChequeRequest.Amount) > clientChequeRequestHigherAmount)
                                {
                                    errorMessage = "You are not allowed to Authorise Client Cheque Requests over the value of £" +
                                                     clientChequeRequestHigherAmount.ToString("0.00") + ".";
                                }
                                else
                                {
                                    SrvClientChequeRequestCommon.AddAuthoriseClientChequeRequests(srvClientChequeRequest.Id, UserInformation.Instance.UserMemberId, DateTime.Now);
                                }
                            }
                        }

                        clientChequeRequest.ChequeRequestId = srvClientChequeRequest.Id;
                        returnValue.ChequeRequest = clientChequeRequest;
                    }

                    returnValue.Message = errorMessage;
                    returnValue.WarningMessage = warningMessage;
                }
                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>
        /// Loads office cheque request details
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="officeChequeRequestId">Office Cheque Request id to get details</param>
        /// <returns>Loads office cheque request details</returns>
        public ChequeRequestReturnValue LoadOfficeChequeRequestDetails(Guid logonId, int officeChequeRequestId)
        {
            ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    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");
                    }

                    SrvOfficeChequeRequest srvOfficeChequeRequest = new SrvOfficeChequeRequest();
                    srvOfficeChequeRequest.Id = officeChequeRequestId;
                    srvOfficeChequeRequest.Load();

                    ChequeRequest chequeReq = new ChequeRequest();
                    chequeReq.ProjectId = srvOfficeChequeRequest.ProjectId;
                    chequeReq.ChequeRequestDate = srvOfficeChequeRequest.Date;
                    chequeReq.DisbursementTypeId = srvOfficeChequeRequest.DisbursementTypeId;
                    chequeReq.ChequeRequestDescription = srvOfficeChequeRequest.Description;
                    chequeReq.ChequeRequestPayee = srvOfficeChequeRequest.Payee;
                    chequeReq.BankId = srvOfficeChequeRequest.OfficeBankId;
                    chequeReq.ChequeRequestAmount = srvOfficeChequeRequest.Amount;
                    chequeReq.OfficeVATTable = srvOfficeChequeRequest.OfficeVATTable;
                    chequeReq.VATRateId = srvOfficeChequeRequest.VATRateId;
                    chequeReq.VATAmount = srvOfficeChequeRequest.VATAmount;
                    chequeReq.IsChequeRequestAuthorised = srvOfficeChequeRequest.IsAuthorised;
                    chequeReq.MemberId = srvOfficeChequeRequest.MemberId;
                    chequeReq.IsChequeRequestAnticipated = srvOfficeChequeRequest.IsAnticipated;
                    returnValue.ChequeRequest = chequeReq;
                }
                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;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Saves office cheque request details
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void _btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    // Sets error message if posting date is blank
                    if (string.IsNullOrEmpty(_ccPostDate.DateText))
                    {
                        _lblPostingPeriod.Text = "Invalid";
                        _lblMessage.CssClass   = "errorMessage";
                        _lblMessage.Text       = "Posting Date is not within the current financial year";
                        return;
                    }

                    ChequeRequest chequeRequest = GetControlData();
                    if (chequeRequest != null)
                    {
                        AccountsServiceClient accountsService = null;
                        try
                        {
                            bool isPostingPeriodValid = SetPostingPeriod();

                            if (isPostingPeriodValid)
                            {
                                accountsService = new AccountsServiceClient();
                                ChequeRequestReturnValue returnValue = accountsService.SaveOfficeChequeRequest(_logonSettings.LogonId, chequeRequest);

                                if (returnValue.Success)
                                {
                                    // If print checkbox is checked then prints cheque request details
                                    // else shows success message on the same page.
                                    if (_chkBxPrintChequeRequest.Checked)
                                    {
                                        // Newly added cheque request id to populate details for printable format.
                                        Session[SessionName.ChequeRequestId] = returnValue.ChequeRequest.ChequeRequestId;

                                        // To redirect to printable format of cheque request details.
                                        Response.Redirect("~/Pages/Accounts/PrintableOfficeChequeRequest.aspx", true);
                                    }
                                    else
                                    {
                                        ResetControls(true);
                                        _lblMessage.CssClass = "successMessage";
                                        _lblMessage.Text     = "Office Cheque Request Saved Successfully.";
                                    }
                                }
                                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();
                                }
                            }
                        }
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException)
                {
                    _lblMessage.Text     = DataConstants.WSEndPointErrorMessage;
                    _lblMessage.CssClass = "errorMessage";
                }
                catch (Exception ex)
                {
                    _lblMessage.CssClass = "errorMessage";
                    _lblMessage.Text     = ex.Message;
                }
            }
        }
 /// <summary>
 /// Adds or edits office cheque requests depending on the 'IsClientChequeRequest' property
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="chequeRequest">ChequeRequest properties to add/edit cheque request.</param>
 /// <returns>Returns cheque request id after adding or editting cheque request.</returns>
 public ChequeRequestReturnValue SaveOfficeChequeRequest(HostSecurityToken oHostSecurityToken, ChequeRequest chequeRequest)
 {
     ChequeRequestReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oAccountService = new AccountsService();
         returnValue = oAccountService.SaveOfficeChequeRequest(Functions.GetLogonIdFromToken(oHostSecurityToken), chequeRequest);
     }
     else
     {
         returnValue = new ChequeRequestReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }
Ejemplo n.º 24
0
        public bool AddSampleCheque(ChequeRequest request)
        {
            HttpResponseMessage message = HttpClient.PostAsJsonAsync(AddChequeRoute, request).GetAwaiter().GetResult();

            return(message.IsSuccessStatusCode);
        }
        /// <summary>
        /// Loads office cheque request details for printing
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="clientChequeRequestId">Office cheque request id toget cheque request details.</param>
        /// <returns>Returns office cheque request details by office cheque request id.</returns>
        public ChequeRequestReturnValue LoadOfficeChequeRequestDetailsForPrinting(Guid logonId, int officeChequeRequestId)
        {
            ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue();

            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");
                    }

                    ChequeRequest officeChequeRequest = new ChequeRequest();

                    DsOfficeChequeRequests dsOfficeChequeRequestsDetails = SrvOfficeChequeRequestLookup.GetOfficeChequeRequestsByOfficeChequeRequestId(officeChequeRequestId);

                    // Gets printable properties from the dataset
                    foreach (DataRow drOfficeChequeRequest in dsOfficeChequeRequestsDetails.OfficeChequeRequests.Rows)
                    {
                        Guid projectId = (Guid)drOfficeChequeRequest["projectId"];

                        // Gets the matter description by project id
                        SrvMatter srvMatter = new SrvMatter();
                        srvMatter.Load(projectId);

                        Guid clientId = srvMatter.ClientId;
                        string matterDescription = srvMatter.MatterDescription;
                        string matterReference = srvMatter.MatterReference;
                        bool isMember = srvMatter.IsMember;

                        // Inserts "-" in between matter reference
                        matterReference = matterReference.Insert(6, "-");

                        string personName = srvMatter.ClientName;

                        // Gets the partner name by partner member id for project id
                        Guid partnerId = srvMatter.MatterPartnerMemberId;
                        string partnerName = SrvEarnerCommon.GetFeeEarnerNameByFeeEarnerId(partnerId);

                        // Gets the fee earner name by fee earner id
                        Guid feeEarnerId = srvMatter.FeeEarnerMemberId;
                        string feeEarnerName = SrvEarnerCommon.GetFeeEarnerNameByFeeEarnerId(feeEarnerId);

                        // This member id is from application settings for accounts.
                        Guid userMemberId = (Guid)drOfficeChequeRequest["memberId"];
                        DateTime officeChequeRequestDate = (DateTime)drOfficeChequeRequest["OfficeChequeRequestsDate"];

                        // Gets user name by member id
                        DsSystemUsers dsSystemUsers = SrvUserLookup.GetUser(userMemberId.ToString());
                        string userName = string.Empty;
                        if (dsSystemUsers.uvw_SystemUsers.Count > 0)
                        {
                            userName = dsSystemUsers.uvw_SystemUsers[0].name;
                        }
                        else
                        {
                            DsPersonDealing dsPersonDealing = SrvMatterLookup.GetPersonDealingLookup();
                            for (int index = 0; index < dsPersonDealing.uvw_PersonDealingLookup.Count; index++)
                            {
                                if (dsPersonDealing.uvw_PersonDealingLookup[index].MemberID == userMemberId)
                                {
                                    userName = dsPersonDealing.uvw_PersonDealingLookup[index].name;
                                }
                            }
                        }

                        int bankId = (int)drOfficeChequeRequest["bankId"];
                        string officeChequeRequestDescription = (string)drOfficeChequeRequest["OfficeChequeRequestsDesc"];
                        string officeChequeRequestPayee = (string)drOfficeChequeRequest["OfficeChequeRequestsPayee"];
                        int officeChequeRequestVATRateId = (int)drOfficeChequeRequest["VatRateId"];

                        // Gets VAT rate by VAT rate id
                        DsVatRates dsVATRates = SrvVATRateLookup.GetVatRates(officeChequeRequestVATRateId);
                        string officeChequeRequestVATRateReference = (string)dsVATRates.VatRates[0].VatRateRef;

                        // Gets the bank name by bank id
                        string officeChequeRequestBankName = this.GetBankByBankId(bankId);
                        decimal officeChequeRequestAmount = (decimal)drOfficeChequeRequest["OfficeChequeRequestsAmount"];
                        decimal officeChequeRequestVATAmount = (decimal)drOfficeChequeRequest["OfficeChequeRequestsVATAmount"];
                        bool isOfficeChequeAuthorised = (bool)drOfficeChequeRequest["OfficeChequeRequestsIsAuthorised"];
                        bool isOfficeChequeAnticipated = (bool)drOfficeChequeRequest["OfficeChequeRequestIsAnticipated"];

                        officeChequeRequest.UserName = userName;
                        officeChequeRequest.PersonName = personName;
                        officeChequeRequest.PartnerName = partnerName;
                        officeChequeRequest.FeeEarnerReference = feeEarnerName;
                        officeChequeRequest.BankName = officeChequeRequestBankName;
                        officeChequeRequest.ChequeRequestDate = officeChequeRequestDate;
                        officeChequeRequest.ChequeRequestPayee = officeChequeRequestPayee;
                        officeChequeRequest.VATAmount = officeChequeRequestVATAmount;
                        officeChequeRequest.VATRate = officeChequeRequestVATRateReference;
                        officeChequeRequest.ChequeRequestAmount = officeChequeRequestAmount;
                        officeChequeRequest.MatterDescription = matterDescription;
                        officeChequeRequest.MatterReference = matterReference;
                        officeChequeRequest.IsChequeRequestAuthorised = isOfficeChequeAuthorised;
                        officeChequeRequest.IsChequeRequestAnticipated = isOfficeChequeAnticipated;
                        officeChequeRequest.ChequeRequestDescription = officeChequeRequestDescription;

                        // Gets addressline1,addressline2,addressline3 for client.
                        if (isMember)
                        {
                            DsMemAddress dsMemAddress = SrvAddressLookup.GetMemberAddresses(clientId);
                            if (dsMemAddress.Address.Rows.Count > 0)
                            {
                                officeChequeRequest.AddressLine1 = dsMemAddress.Address[0].AddressLine1.ToString().Trim();
                                officeChequeRequest.AddressLine2 = dsMemAddress.Address[0].AddressLine2.ToString().Trim();
                                officeChequeRequest.AddressLine3 = dsMemAddress.Address[0].AddressLine3.ToString().Trim();
                                officeChequeRequest.AddressTown = dsMemAddress.Address[0].AddressTown.ToString().Trim();
                                officeChequeRequest.AddressCounty = dsMemAddress.Address[0].AddressCounty.ToString().Trim();
                                officeChequeRequest.AddressPostcode = dsMemAddress.Address[0].AddressPostCode.ToString().Trim();
                            }
                        }
                        else // Look for organisation address if the client is not member.
                        {
                            DsOrgAddress dsOrgAddress = SrvAddressLookup.GetOrganisationAddresses(clientId);
                            if (dsOrgAddress.Address.Rows.Count > 0)
                            {
                                officeChequeRequest.AddressLine1 = dsOrgAddress.Address[0].AddressLine1.ToString().Trim();
                                officeChequeRequest.AddressLine2 = dsOrgAddress.Address[0].AddressLine2.ToString().Trim();
                                officeChequeRequest.AddressLine3 = dsOrgAddress.Address[0].AddressLine3.ToString().Trim();
                                officeChequeRequest.AddressTown = dsOrgAddress.Address[0].AddressTown.ToString().Trim();
                                officeChequeRequest.AddressCounty = dsOrgAddress.Address[0].AddressCounty.ToString().Trim();
                                officeChequeRequest.AddressPostcode = dsOrgAddress.Address[0].AddressPostCode.ToString().Trim();
                            }

                        }
                    }

                    returnValue.ChequeRequest = officeChequeRequest;
                }
                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>
        /// Gets data from the controls and sets properties for client cheque request class.
        /// </summary>
        /// <returns>Returns object to client cheque request class</returns>
        private IRIS.Law.WebServiceInterfaces.Accounts.ChequeRequest GetControlData()
        {
            ChequeRequest clientChequeRequest = null;

            try
            {
                clientChequeRequest = new ChequeRequest();

                if (Session[SessionName.ProjectId] != null)
                {
                    clientChequeRequest.ProjectId = new Guid(Convert.ToString(Session[SessionName.ProjectId]));
                }

                if (!string.IsNullOrEmpty(_ddlClientBank.SelectedValue))
                {
                    clientChequeRequest.BankId = Convert.ToInt32(_ddlClientBank.SelectedValue);
                }

                clientChequeRequest.ChequeRequestId          = Convert.ToInt32(_hdnClientChequeRequestId.Value);
                clientChequeRequest.ChequeRequestDate        = Convert.ToDateTime(_ccPostDate.DateText);
                clientChequeRequest.ChequeRequestAmount      = Convert.ToDecimal(_txtAmount.Text.Trim());
                clientChequeRequest.ChequeRequestDescription = _txtDescription.Text.Trim();

                if (_txtPayee.Text != string.Empty)
                {
                    clientChequeRequest.ChequeRequestPayee = _txtPayee.Text.Trim();
                }
                else
                {
                    clientChequeRequest.ChequeRequestPayee = _txtDescription.Text.Trim();
                }

                clientChequeRequest.IsChequeRequestAuthorised = _chkBxAuthorise.Checked;
                clientChequeRequest.MemberId = new Guid(ViewState["MemberId"].ToString());
                // As suggested by client: Set reference to "CHQ"
                clientChequeRequest.ChequeRequestReference = _txtReference.Text;

                if (_ddlClientDebitCredit.SelectedValue == "Credit")
                {
                    clientChequeRequest.ClientChequeRequestsIsCredit = true;
                }
                else
                {
                    clientChequeRequest.ClientChequeRequestsIsCredit = false;
                }

                clientChequeRequest.ClearanceTypeId = Convert.ToInt32(_dllClearanceType.SelectedValue);
                clientChequeRequest.ClientChequeRequestsClearanceDaysChq  = Convert.ToInt32(_txtClearanceDaysChq.Text);
                clientChequeRequest.ClientChequeRequestsClearanceDaysElec = Convert.ToInt32(_txtClearanceDaysElec.Text);
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text     = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text     = ex.Message;
            }

            return(clientChequeRequest);
        }
        /// <summary>
        /// Gets data from the controls and sets properties for client cheque request class.
        /// </summary>
        /// <returns>Returns object to client cheque request class</returns>
        private IRIS.Law.WebServiceInterfaces.Accounts.ChequeRequest GetControlData()
        {
            ChequeRequest clientChequeRequest = null;

            try
            {
                clientChequeRequest = new ChequeRequest();

                if (Session[SessionName.ProjectId] != null)
                {
                    clientChequeRequest.ProjectId = new Guid(Convert.ToString(Session[SessionName.ProjectId]));
                }

                if (!string.IsNullOrEmpty(_ddlClientBank.SelectedValue))
                {
                    clientChequeRequest.BankId = Convert.ToInt32(_ddlClientBank.SelectedValue);
                }

                clientChequeRequest.ChequeRequestId = Convert.ToInt32(_hdnClientChequeRequestId.Value);
                clientChequeRequest.ChequeRequestDate = Convert.ToDateTime(_ccPostDate.DateText);
                clientChequeRequest.ChequeRequestAmount = Convert.ToDecimal(_txtAmount.Text.Trim());
                clientChequeRequest.ChequeRequestDescription = _txtDescription.Text.Trim();

                if (_txtPayee.Text != string.Empty)
                {
                    clientChequeRequest.ChequeRequestPayee = _txtPayee.Text.Trim();
                }
                else
                {
                    clientChequeRequest.ChequeRequestPayee = _txtDescription.Text.Trim();
                }

                clientChequeRequest.IsChequeRequestAuthorised = _chkBxAuthorise.Checked;
                clientChequeRequest.MemberId = new Guid(ViewState["MemberId"].ToString());
                // As suggested by client: Set reference to "CHQ"
                clientChequeRequest.ChequeRequestReference = _txtReference.Text;

                if (_ddlClientDebitCredit.SelectedValue == "Credit")
                {
                    clientChequeRequest.ClientChequeRequestsIsCredit = true;
                }
                else
                {
                    clientChequeRequest.ClientChequeRequestsIsCredit = false;
                }

                clientChequeRequest.ClearanceTypeId = Convert.ToInt32(_dllClearanceType.SelectedValue);
                clientChequeRequest.ClientChequeRequestsClearanceDaysChq = Convert.ToInt32(_txtClearanceDaysChq.Text);
                clientChequeRequest.ClientChequeRequestsClearanceDaysElec = Convert.ToInt32(_txtClearanceDaysElec.Text);

            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text = ex.Message;
            }

            return clientChequeRequest;
        }
        /// <summary>
        /// Loads client cheque request details
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="officeChequeRequestId">Client Cheque Request id to get details</param>
        /// <returns>Loads client cheque request details</returns>
        public ChequeRequestReturnValue LoadClientChequeRequestDetails(Guid logonId, int clientChequeRequestId)
        {
            ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue();

            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");
                    }

                    SrvClientChequeRequest srvClientChequeRequest = new SrvClientChequeRequest();
                    srvClientChequeRequest.Id = clientChequeRequestId;
                    srvClientChequeRequest.Load();

                    ChequeRequest chequeRequest = new ChequeRequest();
                    chequeRequest.ProjectId = srvClientChequeRequest.ProjectId;
                    chequeRequest.ChequeRequestReference = srvClientChequeRequest.Reference;
                    chequeRequest.ChequeRequestDate = srvClientChequeRequest.Date;
                    chequeRequest.ChequeRequestDescription = srvClientChequeRequest.Description;
                    chequeRequest.ChequeRequestPayee = srvClientChequeRequest.Payee;
                    chequeRequest.BankId = srvClientChequeRequest.ClientBankId;
                    chequeRequest.ChequeRequestAmount = srvClientChequeRequest.Amount;
                    chequeRequest.IsChequeRequestAuthorised = srvClientChequeRequest.IsAuthorised;
                    chequeRequest.MemberId = srvClientChequeRequest.MemberId;
                    chequeRequest.ClientChequeRequestsIsCredit = srvClientChequeRequest.IsCredit;
                    chequeRequest.ClientChequeRequestsClearanceDaysElec = srvClientChequeRequest.ClearanceDaysElec;
                    chequeRequest.ClientChequeRequestsClearanceDaysChq = srvClientChequeRequest.ClearanceDaysChq;
                    chequeRequest.ClearanceTypeId = srvClientChequeRequest.ClearanceTypeId;

                    returnValue.ChequeRequest = chequeRequest;
                }
                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>
        /// Loads cheque request details
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="clientChequeRequestId">Client cheque request id toget cheque request details.</param>
        /// <returns>Returns client cheque request details by client cheque request id.</returns>
        public ChequeRequestReturnValue LoadClientChequeRequestDetailsForPrinting(Guid logonId, int clientChequeRequestId)
        {
            ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue();

            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");
                    }

                    ChequeRequest clientChequeRequest = new ChequeRequest();

                    DsClientChequeRequestsDetails dsClientChequeRequestsDetails = SrvClientChequeRequestLookup.GetClientChequeRequestDetails(clientChequeRequestId);

                    // Gets printable properties from the dataset
                    foreach (DataRow drClientChequeRequest in dsClientChequeRequestsDetails.uvw_ClientChequeRequestsDetails.Rows)
                    {
                        Guid projectId = (Guid)drClientChequeRequest["projectId"];

                        // Gets the matter details by project id
                        SrvMatter srvMatter = new SrvMatter();
                        srvMatter.Load(projectId);

                        Guid clientId = srvMatter.ClientId;
                        bool isMember = srvMatter.IsMember;
                        string matterDescription = srvMatter.MatterDescription;
                        string matterReference = srvMatter.MatterReference;

                        // Inserts "-" in between matter reference
                        matterReference = matterReference.Insert(6, "-");

                        string personName = srvMatter.ClientName;

                        // Gets the partner name by partner member id for project id
                        Guid partnerId = srvMatter.MatterPartnerMemberId;
                        string partnerName = SrvEarnerCommon.GetFeeEarnerNameByFeeEarnerId(partnerId);

                        // Client name should be related to project id
                        DateTime clientChequeRequestDate = (DateTime)drClientChequeRequest["ClientChequeRequestsDate"];
                        string feeEarnerReference = (string)drClientChequeRequest["feeRef"];
                        string userName = (string)drClientChequeRequest["userName"];
                        string clientChequeRequestDescription = (string)drClientChequeRequest["ClientChequeRequestsDesc"];
                        string clientChequeRequestPayee = (string)drClientChequeRequest["ClientChequeRequestsPayee"];
                        int bankId = (int)drClientChequeRequest["bankId"];
                        string clientChequeRequestBankName = this.GetBankByBankId(bankId);
                        decimal clientChequeRequestAmount = (decimal)drClientChequeRequest["ClientChequeRequestsAmount"];
                        bool isClientChequeAuthorised = (bool)drClientChequeRequest["ClientChequeRequestsIsAuthorised"];
                        string matBranchRef = (string)drClientChequeRequest["matBranchRef"];
                        string ClearanceTypeDesc = (string)drClientChequeRequest["ClearanceTypeDesc"];

                        clientChequeRequest.PersonName = personName;
                        clientChequeRequest.IsChequeRequestAuthorised = isClientChequeAuthorised;
                        clientChequeRequest.ChequeRequestDate = clientChequeRequestDate;
                        clientChequeRequest.ChequeRequestDescription = clientChequeRequestDescription;
                        clientChequeRequest.ChequeRequestPayee = clientChequeRequestPayee;
                        clientChequeRequest.BankName = clientChequeRequestBankName;
                        clientChequeRequest.ChequeRequestAmount = clientChequeRequestAmount;
                        clientChequeRequest.UserName = userName;
                        clientChequeRequest.FeeEarnerReference = feeEarnerReference;
                        clientChequeRequest.MatterReference = matterReference;
                        clientChequeRequest.MatterDescription = matterDescription;
                        clientChequeRequest.PartnerName = partnerName;
                        clientChequeRequest.ClearanceTypeDesc = ClearanceTypeDesc;
                        clientChequeRequest.MatBranchRef = matBranchRef;

                        // Gets address details for client
                        if (isMember)
                        {
                            DsMemAddress dsMemAddress = SrvAddressLookup.GetMemberAddresses(clientId);
                            if (dsMemAddress.Address.Rows.Count > 0)
                            {
                                clientChequeRequest.AddressLine1 = dsMemAddress.Address[0].AddressLine1.ToString().Trim();
                                clientChequeRequest.AddressLine2 = dsMemAddress.Address[0].AddressLine2.ToString().Trim();
                                clientChequeRequest.AddressLine3 = dsMemAddress.Address[0].AddressLine3.ToString().Trim();
                                clientChequeRequest.AddressTown = dsMemAddress.Address[0].AddressTown.ToString().Trim();
                                clientChequeRequest.AddressCounty = dsMemAddress.Address[0].AddressCounty.ToString().Trim();
                                clientChequeRequest.AddressPostcode = dsMemAddress.Address[0].AddressPostCode.ToString().Trim();
                            }
                        }
                        else // if a client is not member client look address detail fo organisation client.
                        {
                            DsOrgAddress dsOrgAddress = SrvAddressLookup.GetOrganisationAddresses(clientId);
                            if (dsOrgAddress.Address.Rows.Count > 0)
                            {
                                clientChequeRequest.AddressLine1 = dsOrgAddress.Address[0].AddressLine1.ToString().Trim();
                                clientChequeRequest.AddressLine2 = dsOrgAddress.Address[0].AddressLine2.ToString().Trim();
                                clientChequeRequest.AddressLine3 = dsOrgAddress.Address[0].AddressLine3.ToString().Trim();
                                clientChequeRequest.AddressTown = dsOrgAddress.Address[0].AddressTown.ToString().Trim();
                                clientChequeRequest.AddressCounty = dsOrgAddress.Address[0].AddressCounty.ToString().Trim();
                                clientChequeRequest.AddressPostcode = dsOrgAddress.Address[0].AddressPostCode.ToString().Trim();
                            }
                        }
                    }

                    returnValue.ChequeRequest = clientChequeRequest;
                }
                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;
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Gets data from controls for save
        /// </summary>
        /// <returns></returns>
        private ChequeRequest GetControlData()
        {
            ChequeRequest chequeReq = new ChequeRequest();

            try
            {
                if (string.IsNullOrEmpty(_txtAmount.Text))
                {
                    throw new Exception("Amount is mandatory.");
                }

                if (Convert.ToDecimal(_txtAmount.Text.Trim()) == 0)
                {
                    throw new Exception("Amount is mandatory.");
                }

                if (ViewState["ChequeRequestProjectId"] != null)
                {
                    if (new Guid(Convert.ToString(ViewState["ChequeRequestProjectId"])) != DataConstants.DummyGuid)
                    {
                        chequeReq.ProjectId = new Guid(Convert.ToString(ViewState["ChequeRequestProjectId"]));
                    }
                    else
                    {
                        if (Session[SessionName.ProjectId] != null)
                        {
                            chequeReq.ProjectId = new Guid(Convert.ToString(Session[SessionName.ProjectId]));
                        }
                    }
                }

                chequeReq.ChequeRequestId          = Convert.ToInt32(_hdnOfficeChequeRequestId.Value);
                chequeReq.ChequeRequestDate        = Convert.ToDateTime(_ccPostDate.DateText);
                chequeReq.DisbursementTypeId       = Convert.ToInt32(_ddlDisbursementType.SelectedValue);
                chequeReq.ChequeRequestDescription = _txtDescription.Text;
                chequeReq.ChequeRequestPayee       = _txtPayee.Text;
                chequeReq.BankId = Convert.ToInt32(_ddlBank.SelectedValue);
                chequeReq.ChequeRequestAmount = Convert.ToDecimal(_txtAmount.Text);

                if (_ddlVAT.SelectedValue == "Yes")
                {
                    chequeReq.OfficeVATTable = IRIS.Law.PmsCommonData.Accounts.AccountsDataConstantsYesNo.Yes;
                }
                else
                {
                    chequeReq.OfficeVATTable = IRIS.Law.PmsCommonData.Accounts.AccountsDataConstantsYesNo.No;
                }

                chequeReq.VATRateId = Convert.ToInt32(GetValueOnIndexFromArray(_ddlVATRate.SelectedValue, 0));
                chequeReq.VATAmount = Convert.ToDecimal(_txtVATAmount.Text);
                chequeReq.IsChequeRequestAnticipated = _chkBxAnticipated.Checked;
                chequeReq.IsChequeRequestAuthorised  = _chkBxAuthorise.Checked;
                chequeReq.MemberId = new Guid(ViewState["MemberId"].ToString());

                return(chequeReq);
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text     = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
                return(chequeReq);
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text     = ex.Message;
                return(chequeReq);
            }
        }