public UserControl_FinancialEntity(FinancialEntity financialEntity)
        {
            MyFinancialEntity = financialEntity;

            InitializeComponent();

            FinancialEntity_Name.Text    = financialEntity.Name;
            FinancialEntity_Balance.Text = financialEntity.Balance.ToString("£0.00");
        }
Пример #2
0
        public void CalculatorServiceTest_DynamicFieldLengthDisallowedTest()
        {
            var networthReq = new NetworthRequest();

            networthReq.Assets      = new List <FinancialEntity>();
            networthReq.Liabilities = new List <FinancialEntity>();

            var asset = new FinancialEntity();

            asset.StaticFields  = new List <LabelValue>();
            asset.DynamicFields = new List <LabelValue>();

            asset.StaticFields.Add(new LabelValue {
                Label = "Chequing", Value = -1000
            });
            asset.StaticFields.Add(new LabelValue {
                Label = "Primary Home", Value = 500000
            });

            asset.DynamicFields.Add(new LabelValue {
                Label = "Investment 1", Value = 2000
            });
            asset.DynamicFields.Add(new LabelValue {
                Label = "Investment 2", Value = 5000
            });

            var liability = new FinancialEntity();

            liability.StaticFields  = new List <LabelValue>();
            liability.DynamicFields = new List <LabelValue>();

            liability.StaticFields.Add(new LabelValue {
                Label = "Loan", Value = 10000
            });
            liability.DynamicFields.Add(new LabelValue {
                Label = "Credit Card 1", Value = 2000
            });

            networthReq.Assets.Add(asset);
            networthReq.Liabilities.Add(liability);

            Action testAction = () => _calculatorService.CalculateNetworth(networthReq, 1);

            Assert.Throws <ValidationErrorException>(testAction);
        }
Пример #3
0
        public void CalculatorServiceTest_HappyPathTest()
        {
            var networthReq = new NetworthRequest();

            networthReq.Assets      = new List <FinancialEntity>();
            networthReq.Liabilities = new List <FinancialEntity>();

            var asset = new FinancialEntity();

            asset.StaticFields  = new List <LabelValue>();
            asset.DynamicFields = new List <LabelValue>();

            asset.StaticFields.Add(new LabelValue {
                Label = "Chequing", Value = 1000
            });
            asset.StaticFields.Add(new LabelValue {
                Label = "Primary Home", Value = 500000
            });

            asset.DynamicFields.Add(new LabelValue {
                Label = "Investment 1", Value = 2000
            });

            var liability = new FinancialEntity();

            liability.StaticFields  = new List <LabelValue>();
            liability.DynamicFields = new List <LabelValue>();

            liability.StaticFields.Add(new LabelValue {
                Label = "Loan", Value = 10000
            });
            liability.DynamicFields.Add(new LabelValue {
                Label = "Credit Card 1", Value = 2000
            });

            networthReq.Assets.Add(asset);
            networthReq.Liabilities.Add(liability);

            var result = _calculatorService.CalculateNetworth(networthReq, 1);

            Assert.Equal(503000, result.TotalAssets);
            Assert.Equal(12000, result.TotalLiabilities);
            Assert.Equal(491000, result.NetWorth);
        }
Пример #4
0
        public async Task <ServiceReturn <FinancialEntity> > GetDefaultFinancialEntityByUniquePatientIdAsync(AuthenticationType tipoAuth, string facilityID, string uniqueUserId, string successMessage = "", string errorMessage = "")
        {
            var uiMessages = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(errorMessage))
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, errorMessage);
            }
            else
            {
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, AppResources.GetFinancialEntitiesError);
            }

            if (!string.IsNullOrEmpty(successMessage))
            {
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);
            }

            FinancialEntity efrId = null;

            try
            {
                string baseMuleUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_MULE_URL");

                Generated.Mulesoft.GETClient sc = new Generated.Mulesoft.GETClient(baseMuleUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient()));

                var retTemp = await sc.FinancialEntitiesDefaultAsync(facilityID, uniqueUserId);

                if (retTemp != null)
                {
                    efrId = TranslateDefaultFinancialEntityGPToLocal(retTemp);
                }

                return(ServiceReturnHandling.BuildSuccessCallReturn <FinancialEntity>(efrId, uiMessages));
            }
            catch (Exception ex)
            {
                return(ServiceReturnHandling.HandleException <FinancialEntity>(ex, uiMessages));
            }
        }
        public bool SaveFinancial(FinancialEntity er)
        {
            try
            {
                String query = "Insert into Financial values ('" + er.Id + "','" + er.OrderId + "','" + er.Table + "','" + er.Bill + "');";


                int count = DataAccess.ExecuteQuery(query);

                if (count >= 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #6
0
        public BusinessLayer.Entities.FinancialEntity TranslateDefaultFinancialEntityGPToLocal(Generated.Mulesoft.FinancialEntity efrGP)
        {
            FinancialEntity efrLocal = new FinancialEntity();

            try
            {
                if (efrGP != null)
                {
                    efrLocal.FinancialEntityCode = efrGP.Code;
                    if (efrGP.Id != null)
                    {
                        efrLocal.FinancialEntityId = efrGP.Id;
                    }
                    efrLocal.Name = efrGP.Description;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Erro a realizar o convert de FinancialEntity (GP) para FinancialEntityLight (local)");
                return(efrLocal);
            }
            return(efrLocal);
        }