Ejemplo n.º 1
0
        public void TestGetSEVISEVBatchTypeExchangeVisitorFinancialInfo()
        {
            string binationalCommission = "commission";
            string personal             = "peronsal";
            string evGovt = "ev gov";
            Other  other  = new Other("name", "amount");
            USGovernmentFunding  usGovt        = new USGovernmentFunding(null, null, null, null, null, null);
            InternationalFunding international = new InternationalFunding(null, null, null, null, null, null);

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            var programSponsorFunds = "prog sponsor funds";
            var receivedUsGovtFunds = true;
            var printForm           = true;
            var financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            var instance = financialInfo.GetSEVISEVBatchTypeExchangeVisitorFinancialInfo();

            Assert.IsNotNull(instance.OtherFunds);
            Assert.AreEqual(financialInfo.PrintForm, instance.printForm);
            Assert.AreEqual(financialInfo.ProgramSponsorFunds, instance.ProgramSponsorFunds);
            Assert.AreEqual(financialInfo.ReceivedUSGovtFunds, instance.ReceivedUSGovtFunds);
            Assert.IsTrue(instance.ReceivedUSGovtFundsSpecified);
        }
        public void TestProgramSponsor_ContainsCharacters()
        {
            var otherFunds                    = new OtherFunds("10", null, null, null, null, null);
            var programSponsorFunds           = "100";
            var receivedUsGovtFunds           = true;
            var printForm                     = true;
            Func <FinancialInfo> createEntity = () =>
            {
                var financialInfo = new FinancialInfo(
                    printForm: printForm,
                    receivedUSGovtFunds: receivedUsGovtFunds,
                    programSponsorFunds: programSponsorFunds,
                    otherFunds: otherFunds);
                return(financialInfo);
            };

            var validator = new FinancialInfoValidator();
            var instance  = createEntity();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            programSponsorFunds = "c";
            instance            = createEntity();
            result = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual(FinancialInfoValidator.PROGRAM_SPONSOR_FUNDS_ERROR_MESSAGE, result.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(result.Errors.First().CustomState, typeof(FundingErrorPath));
        }
Ejemplo n.º 3
0
    public void Fill_out_car_details(int year, string make, string type, FinancialInfo financialInfo)
    {
        BrowserWindow browserWindow = _desktop.BrowserWindow("Web");
        browserWindow.DomTextField("//INPUT[@id='autoquote:year']").SetText(year.ToString());

        browserWindow.DomElement("//IMG[@class='x-form-trigger x-for*']").DomClick();
        (browserWindow.Find(string.Format("//div[@textContents='{0}']", make)) as DomElement).Click();

        browserWindow.DomElement("//IMG[@class='x-form-trigger x-for*'][2]").DomClick();
        (browserWindow.Find(string.Format("//div[@textContents='{0}']", type)) as DomElement).Click();

        switch (financialInfo)
        {
            case FinancialInfo.OWN:
                browserWindow.DomRadioButton("//INPUT[@id='autoquote:finInfo:0']").Select();
                break;
            case FinancialInfo.FINANCED:
                browserWindow.DomRadioButton("//INPUT[@id='autoquote:finInfo:1']").Select();
                break;
            case FinancialInfo.LEASE:
                browserWindow.DomRadioButton("//INPUT[@id='autoquote:finInfo:2']").Select();
                break;
        }

        browserWindow.DomButton("AutoQuote.Next").Click();
    }
Ejemplo n.º 4
0
        public void TestConstructor()
        {
            string binationalCommission = "commission";
            string personal             = "peronsal";
            string evGovt        = "ev gov";
            Other  other         = new Other("name", "amount");
            var    usGovt        = new USGovernmentFunding("us gov 1", null, "us gov value 1", null, null, null);
            var    international = new InternationalFunding("international org 1", null, "internation org 1 value", null, null, null);

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            var programSponsorFunds = "prog sponsor funds";
            var receivedUsGovtFunds = true;
            var printForm           = true;
            var instance            = new FinancialInfo(
                printForm,
                receivedUsGovtFunds,
                programSponsorFunds,
                otherFunds);

            Assert.IsTrue(Object.ReferenceEquals(otherFunds, instance.OtherFunds));
            Assert.AreEqual(programSponsorFunds, instance.ProgramSponsorFunds);
            Assert.AreEqual(receivedUsGovtFunds, instance.ReceivedUSGovtFunds);
            Assert.AreEqual(printForm, instance.PrintForm);
        }
Ejemplo n.º 5
0
        public void TestConstructor_PrintFormIsFalse()
        {
            string binationalCommission = "commission";
            string personal             = "peronsal";
            string evGovt = "ev gov";
            Other  other  = new Other("name", "amount");
            USGovernmentFunding  usGovt        = new USGovernmentFunding(null, null, null, null, null, null);
            InternationalFunding international = new InternationalFunding(null, null, null, null, null, null);

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            var programSponsorFunds = "prog sponsor funds";
            var receivedUsGovtFunds = true;
            var printForm           = false;
            var instance            = new FinancialInfo(
                printForm,
                receivedUsGovtFunds,
                programSponsorFunds,
                otherFunds);

            Assert.AreEqual(receivedUsGovtFunds, instance.ReceivedUSGovtFunds);
            Assert.AreEqual(printForm, instance.PrintForm);
        }
        public void TestFinancialInfo_MustHaveMinimumFunding()
        {
            var otherFunds                    = new OtherFunds(null, null, null, null, null, null);
            var programSponsorFunds           = "100";
            var receivedUsGovtFunds           = true;
            var printForm                     = true;
            Func <FinancialInfo> createEntity = () =>
            {
                var financialInfo = new FinancialInfo(
                    printForm: printForm,
                    receivedUSGovtFunds: receivedUsGovtFunds,
                    programSponsorFunds: programSponsorFunds,
                    otherFunds: otherFunds);
                return(financialInfo);
            };

            var validator = new FinancialInfoValidator();
            var instance  = createEntity();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            programSponsorFunds = "0";
            instance            = createEntity();
            result = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual(FinancialInfoValidator.FUNDING_LESS_THAN_MINIMUM_AMOUNT_ERROR_MESSAGE, result.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(result.Errors.First().CustomState, typeof(FundingErrorPath));
        }
        public void TestOtherFunds_ShouldRunValidator()
        {
            OtherFunds           otherFunds          = null;
            var                  programSponsorFunds = "100";
            var                  receivedUsGovtFunds = true;
            var                  printForm           = true;
            Func <FinancialInfo> createEntity        = () =>
            {
                var financialInfo = new FinancialInfo(
                    printForm: printForm,
                    receivedUSGovtFunds: receivedUsGovtFunds,
                    programSponsorFunds: programSponsorFunds,
                    otherFunds: otherFunds);
                return(financialInfo);
            };
            var validator = new FinancialInfoValidator();
            var instance  = createEntity();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            otherFunds = new OtherFunds("a", null, null, null, null, null);
            instance   = createEntity();
            result     = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
        }
        public ViewResult Details(Guid id)
        {
            FinancialInfo info = _financialInfosRepository.GetFinancialInfo(id);
            Car           car  = _carsRepository.GetCar(info.CarId);
            FinancialInfoDetailsViewModel model = new FinancialInfoDetailsViewModel
            {
                Finfo = info,
                Car   = car
            };

            return(View(model));
        }
Ejemplo n.º 9
0
        public void TestGetTotalFunding_HasOtherFunds()
        {
            OtherFunds otherFunds          = new OtherFunds("1.0", null, null, null, null, null);
            string     programSponsorFunds = null;
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            Assert.AreEqual(1.0m, financialInfo.GetTotalFunding());
        }
Ejemplo n.º 10
0
        public void TestGetTotalFunding_HasEmtpyStringProgramSponsorFunds()
        {
            OtherFunds otherFunds          = null;
            string     programSponsorFunds = string.Empty;
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            Assert.AreEqual(0.0m, financialInfo.GetTotalFunding());
        }
Ejemplo n.º 11
0
        public void TestGetEVPersonTypeFinancialInfo_NullOtherFunds()
        {
            OtherFunds otherFunds          = null;
            var        programSponsorFunds = "prog sponsor funds";
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);
            var instance = financialInfo.GetEVPersonTypeFinancialInfo();

            Assert.IsNull(instance.OtherFunds);
        }
        /// <summary>
        /// Returns sevis participant financial information.
        /// </summary>
        /// <param name="participantExchangeVisitor">The exchange visitor.</param>
        /// <param name="orgFunding">The international organization funding.</param>
        /// <param name="usFunding">The US government funding for the participant.</param>
        /// <returns>The financial info object.</returns>
        public FinancialInfo GetFinancialInfo(ParticipantExchangeVisitor participantExchangeVisitor, ExchangeVisitorFundingDTO orgFunding, ExchangeVisitorFundingDTO usFunding)
        {
            Contract.Requires(participantExchangeVisitor != null, "The participant exchange visitor must not be null.");
            Func <decimal?, string> getFundingAsWholeDollarString = (value) =>
            {
                if (value.HasValue && value.Value > 0.0m)
                {
                    return(((int)value.Value).ToString());
                }
                else
                {
                    return(null);
                }
            };

            var receivedUsGovtFunds = false;

            if ((participantExchangeVisitor.FundingGovtAgency1.HasValue && participantExchangeVisitor.FundingGovtAgency1.Value > 0.0m) ||
                (participantExchangeVisitor.FundingGovtAgency2.HasValue && participantExchangeVisitor.FundingGovtAgency2.Value > 0.0m))
            {
                receivedUsGovtFunds = true;
            }
            var   programSponsorFunds = getFundingAsWholeDollarString(participantExchangeVisitor.FundingSponsor);
            Other other = null;

            if (participantExchangeVisitor.FundingOther.HasValue && participantExchangeVisitor.FundingOther.Value > 0.0m)
            {
                other = new Other(
                    name: participantExchangeVisitor.OtherName,
                    amount: getFundingAsWholeDollarString(participantExchangeVisitor.FundingOther));
            }

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: getFundingAsWholeDollarString(participantExchangeVisitor.FundingVisGovt),
                binationalCommission: getFundingAsWholeDollarString(participantExchangeVisitor.FundingVisBNC),
                personal: getFundingAsWholeDollarString(participantExchangeVisitor.FundingPersonal),
                usGovernmentFunding: usFunding != null && !usFunding.IsEmpty() ? usFunding.GetUSGovt() : null,
                internationalFunding: orgFunding != null && !orgFunding.IsEmpty() ? orgFunding.GetInternational() : null,
                other: other);

            var financialInfo = new FinancialInfo(
                printForm: true,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            return(financialInfo);
        }
Ejemplo n.º 13
0
        public void TestGetChangeDetail_SameInstance()
        {
            OtherFunds otherFunds          = new OtherFunds("1.0", null, null, null, null, null);
            string     programSponsorFunds = null;
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            var changeDetail = financialInfo.GetChangeDetail(financialInfo);

            Assert.IsFalse(changeDetail.HasChanges());
        }
Ejemplo n.º 14
0
        public void TestGetSEVISEVBatchTypeExchangeVisitorFinancialInfo_OtherFundsIsNull()
        {
            OtherFunds otherFunds          = null;
            var        programSponsorFunds = "prog sponsor funds";
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            var instance = financialInfo.GetSEVISEVBatchTypeExchangeVisitorFinancialInfo();

            Assert.IsNull(instance.OtherFunds);
        }
 public IActionResult Edit(FinancialInfoEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         FinancialInfo info = _financialInfosRepository.GetFinancialInfo(model.Id);
         info.BankName          = model.BankName;
         info.LeaseType         = model.LeaseType;
         info.LeaseTime         = model.LeaseTime;
         info.LeaseStartDate    = model.LeaseStartDate;
         info.LeaseEndDate      = model.LeaseEndDate;
         info.StartNetPrice     = model.StartNetPrice;
         info.EndBuyoutNetPrice = model.EndBuyoutNetPrice;
         info.MonthlyLeaseFee   = model.MonthlyLeaseFee;
         info.Company           = model.Company;
         _financialInfosRepository.Update(info);
         return(RedirectToAction("Details", new { id = info.Id }));
     }
     return(RedirectToAction("Edit", new { id = model.Id }));
 }
        public ViewResult Edit(Guid id)
        {
            FinancialInfo info = _financialInfosRepository.GetFinancialInfo(id);
            FinancialInfoEditViewModel model = new FinancialInfoEditViewModel
            {
                Id                = info.Id,
                CarId             = info.CarId,
                BankName          = info.BankName,
                LeaseType         = info.LeaseType,
                LeaseTime         = info.LeaseTime,
                LeaseStartDate    = info.LeaseStartDate,
                LeaseEndDate      = info.LeaseEndDate,
                StartNetPrice     = info.StartNetPrice,
                EndBuyoutNetPrice = info.EndBuyoutNetPrice,
                MonthlyLeaseFee   = info.MonthlyLeaseFee,
                Company           = info.Company
            };

            return(View(model));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 财务信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void set_finaicnal_Click(object sender, RoutedEventArgs e)
        {
            if (_FinancialInfo == null)
            {
                _FinancialInfo = new FinancialInfo();
            }
            if (!_checkText.checkNumIsEmpty(this.marketID1.Text))
            {
                return;
            }

            if (!_checkText.checkNumIsEmpty(this.unitmoney.Text))
            {
                return;
            }
            if (!_checkText.checkTextIsEmpty(this.marketName1.Text))
            {
                return;
            }
            if (flag == 0)
            {
                if (!_checkText.checkNumIsEmpty(this.ImportMoney.Text))
                {
                    return;
                }
                if (!_checkText.checkNumIsEmpty(this.SaledMoney.Text))
                {
                    return;
                }
                _FinancialInfo.InerAmount = Convert.ToDouble(this.ImportMoney.Text);
                _FinancialInfo.SaleAmount = Convert.ToDouble(this.SaledMoney.Text);
            }
            _FinancialInfo.MarketID = Convert.ToInt32(this.marketID1.Text);

            _FinancialInfo.totalAmount = Convert.ToDouble(this.unitmoney.Text);
            _FinancialInfo.MarketName  = this.marketName1.Text;
            string addFinancial = XMLSerialization.Serialize(_FinancialInfo);

            addInfo("Financial", addFinancial);
        }
Ejemplo n.º 18
0
        public void TestJsonSerialization()
        {
            string binationalCommission = "commission";
            string personal             = "peronsal";
            string evGovt        = "ev gov";
            Other  other         = new Other("name", "amount");
            var    usGovt        = new USGovernmentFunding("us gov 1", null, "us gov value 1", null, null, null);
            var    international = new InternationalFunding("international org 1", null, "internation org 1 value", null, null, null);

            var otherFunds = new OtherFunds(
                exchangeVisitorGovernment: evGovt,
                binationalCommission: binationalCommission,
                personal: personal,
                usGovernmentFunding: usGovt,
                internationalFunding: international,
                other: other);

            var programSponsorFunds = "prog sponsor funds";
            var receivedUsGovtFunds = true;
            var printForm           = true;
            var instance            = new FinancialInfo(
                printForm,
                receivedUsGovtFunds,
                programSponsorFunds,
                otherFunds);
            var json       = JsonConvert.SerializeObject(instance);
            var jsonObject = JsonConvert.DeserializeObject <FinancialInfo>(json);

            Assert.AreEqual(receivedUsGovtFunds, jsonObject.ReceivedUSGovtFunds);
            Assert.AreEqual(printForm, jsonObject.PrintForm);
            Assert.IsNotNull(jsonObject.OtherFunds);
            Assert.IsNotNull(jsonObject.OtherFunds.InternationalFunding);
            Assert.IsNotNull(jsonObject.OtherFunds.USGovernmentFunding);

            //spot checks
            Assert.AreEqual(usGovt.Org1, jsonObject.OtherFunds.USGovernmentFunding.Org1);
            Assert.AreEqual(international.Org1, jsonObject.OtherFunds.InternationalFunding.Org1);
        }
Ejemplo n.º 19
0
        public void TestGetChangeDetail_HasChangeInChild()
        {
            OtherFunds otherFunds          = new OtherFunds("1.0", null, null, null, null, null);
            string     programSponsorFunds = null;
            var        receivedUsGovtFunds = true;
            var        printForm           = true;
            var        financialInfo       = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: otherFunds);

            OtherFunds someOtherFunds     = new OtherFunds("2.0", null, null, null, null, null);
            var        otherFinancialInfo = new FinancialInfo(
                printForm: printForm,
                receivedUSGovtFunds: receivedUsGovtFunds,
                programSponsorFunds: programSponsorFunds,
                otherFunds: someOtherFunds);

            var changeDetail = financialInfo.GetChangeDetail(otherFinancialInfo);

            Assert.IsTrue(changeDetail.HasChanges());
        }
 public IActionResult Create(FinancialInfoCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         FinancialInfo info = new FinancialInfo
         {
             CarId             = model.CarId,
             BankName          = model.BankName,
             LeaseType         = model.LeaseType,
             LeaseTime         = model.LeaseTime,
             LeaseStartDate    = model.LeaseStartDate,
             LeaseEndDate      = model.LeaseEndDate,
             StartNetPrice     = model.StartNetPrice,
             EndBuyoutNetPrice = model.EndBuyoutNetPrice,
             MonthlyLeaseFee   = model.MonthlyLeaseFee,
             Company           = model.Company,
             Id = new Guid()
         };
         _financialInfosRepository.Add(info);
         return(RedirectToAction("Details", new { id = info.Id }));
     }
     return(RedirectToAction("Create", new { carId = model.CarId }));
 }
        public async Task <int> Handle(CreateFinancialInfoCommand request, CancellationToken cancellationToken)
        {
            var financialInformationCount = await _context.FinancialInformation
                                            .Where(f => f.CreatedBy == _currentUserService.UserId).CountAsync(cancellationToken);

            var financialInfo = new FinancialInfo
            {
                CardNumber    = request.CardNumber,
                BankId        = request.BankId == 0 ? null : request.BankId,
                AccountNumber = request.AccountNumber,
                Sheba         = request.Sheba,
                BankCardImage = await _imageAccessor.Upload(request.BankCardImage, _currentUserService.UserId,
                                                            "کارت بانکی " + ++financialInformationCount),
                Status = Status.Sent
            };

            _context.FinancialInformation.Add(financialInfo);
            _notificationService.SendAsync(NotificationType.BankCard);

            await _context.SaveChangesAsync(cancellationToken);

            return(financialInfo.Id);
        }
        /// <summary>
        /// Returns the exchange visitor model given the required exchange vistor information.
        /// </summary>
        /// <param name="user">The user requesting the exchange visitor.</param>
        /// <param name="isValidated">True, if the exchange visitor has been validated in sevis.</param>
        /// <param name="person">The exchange visitor person model.</param>
        /// <param name="financialInfo">The financial information.</param>
        /// <param name="participantPerson">The participant person record for the participant.</param>
        /// <param name="occupationCategoryCode">The occupation category code.</param>
        /// <param name="dependents">The dependents for the exchange visitor.</param>
        /// <param name="siteOfActivity">The site of activity, i.e. C Street state dept.</param>
        /// <returns>The exchange visitor.</returns>
        public ExchangeVisitor GetExchangeVisitor(
            bool isValidated,
            Validation.Sevis.Bio.Person person,
            FinancialInfo financialInfo,
            ParticipantPerson participantPerson,
            string occupationCategoryCode,
            IEnumerable <DependentBiographicalDTO> dependents,
            AddressDTO siteOfActivity,
            string sevisOrgId)
        {
            Contract.Requires(person != null, "The person must not be null.");
            Contract.Requires(financialInfo != null, "The financial info must not be null.");
            Contract.Requires(participantPerson != null, "The participant person must not be null.");
            Contract.Requires(siteOfActivity != null, "The site of activity must not be null.");

            var exchangeVisitorDependents = new List <Dependent>();

            if (dependents != null)
            {
                foreach (var dependent in dependents)
                {
                    exchangeVisitorDependents.Add(dependent.GetDependent(siteOfActivity, null));
                }
            }

            return(new ExchangeVisitor(
                       sevisId: participantPerson.SevisId,
                       isValidated: isValidated,
                       sevisOrgId: sevisOrgId,
                       person: person,
                       financialInfo: financialInfo,
                       occupationCategoryCode: occupationCategoryCode,
                       programEndDate: participantPerson.EndDate.HasValue ? participantPerson.EndDate.Value.DateTime : default(DateTime),
                       programStartDate: participantPerson.StartDate.HasValue ? participantPerson.StartDate.Value.DateTime : default(DateTime),
                       dependents: exchangeVisitorDependents,
                       siteOfActivity: siteOfActivity));
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="user">The user requesting the exchange visitor.</param>
 /// <param name="sevisId">The sevis id of the exchange visitor, or null, if none has been provided yet.</param>
 /// <param name="sevisOrgId">The sevis org id of the exchange visitor, or null, if none has been provided yet.</param>
 /// <param name="person">The person object representing the biographical information of the exchange visitor.</param>
 /// <param name="financialInfo">The financial info, detailing financial information about the exchange visitor.</param>
 /// <param name="occupationCategoryCode">The occupation category code.</param>
 /// <param name="programEndDate">The end date of the participant.</param>
 /// <param name="programStartDate">The start date of the participant.</param>
 /// <param name="siteOfActivity">The exchange visitor site of activity.</param>
 /// <param name="dependents">The dependents of the exchange visitor.</param>
 public ExchangeVisitor(
     string sevisId,
     string sevisOrgId,
     bool isValidated,
     Bio.Person person,
     FinancialInfo financialInfo,
     string occupationCategoryCode,
     DateTime programEndDate,
     DateTime programStartDate,
     AddressDTO siteOfActivity,
     IEnumerable <Dependent> dependents
     )
 {
     this.Person                 = person;
     this.FinancialInfo          = financialInfo;
     this.OccupationCategoryCode = occupationCategoryCode;
     this.ProgramEndDate         = programEndDate;
     this.ProgramStartDate       = programStartDate;
     this.Dependents             = dependents ?? new List <Dependent>();
     this.SiteOfActivity         = siteOfActivity;
     this.SevisId                = sevisId;
     this.SevisOrgId             = sevisOrgId;
     this.IsValidated            = isValidated;
 }
Ejemplo n.º 24
0
        private FinancialInfo ParseFinInfo(string content, DocLinkInfo.LinkTypeEnum linktype, FinInfoCategoria categoria, FinInfoTipo tipo)
        {
            var parser = new HtmlParser();
            var doc    = parser.Parse(content);

            FinancialInfo finInfo = new FinancialInfo();

            finInfo.Categoria = categoria;
            finInfo.Tipo      = tipo;


            IHtmlTableElement table = null;

            if (linktype == DocLinkInfo.LinkTypeEnum.Bovespa)
            {
                var div = doc.QuerySelector("div.ScrollMaker");

                if (div == null)
                {
                    var scripts = doc.QuerySelectorAll("script");
                    if (scripts.Any(s => s.TextContent.Contains("Não Possui Dados para Carregar a Página")))
                    {
                        // dado não existe
                        return(null);
                    }
                }

                table = div.FirstElementChild as IHtmlTableElement;
                //table anterior a table é a linha que contém o multiplicador
                var multiplierText = div.PreviousElementSibling.TextContent;
                if (multiplierText.Contains("Mil"))
                {
                    finInfo.Multiplicador = 1000;
                }
            }
            else //cvm
            {
                var title = doc.QuerySelector("#TituloTabelaSemBorda");
                if (title.TextContent.Contains("Reais Mil"))
                {
                    finInfo.Multiplicador = 1000;
                }

                table = title.NextElementSibling as IHtmlTableElement;

                if (table.InnerHtml.Contains("Justificativa para a não prestação da informação"))
                {
                    // dado não existe
                    return(null);
                }
            }

            foreach (var row in table.Rows)
            {
                bool isTopLine = false;
                if (linktype == DocLinkInfo.LinkTypeEnum.Bovespa)
                {
                    isTopLine = row.GetAttribute("valign") == "top";
                }
                else
                {
                    isTopLine = row.Cells[0].TextContent.Trim() == "Conta";
                }

                if (isTopLine) // linha de título
                {
                    // pega a data da terceira célula
                    // Valor do Trimestre Atual 01/04/2009 a 30/06/2009
                    var text       = row.Cells[2].TextContent;
                    var iUltimoNum = text.LastIndexOfNum();
                    var start      = iUltimoNum - 9;
                    var datetext   = text.Substring(start, 10).Trim();
                    finInfo.Data = DateTime.ParseExact(datetext, "dd/MM/yyyy", new CultureInfo("pt-BR"));
                }
                else
                {
                    var           codconta  = row.Cells[0].TextContent;
                    var           nomeconta = row.Cells[1].TextContent;
                    var           valortext = row.Cells[2].TextContent;
                    FinancialItem item      = new FinancialItem();
                    item.Conta = codconta.Trim();
                    item.Nome  = nomeconta.Trim();
                    item.Valor = ParseValor(valortext.Trim());
                    finInfo.Items.Add(item);
                }
            }

            return(finInfo);
        }
Ejemplo n.º 25
0
 public Subscription(Guid userId, FinancialInfo financialInfo)
 {
     UserId        = userId;
     FinancialInfo = financialInfo;
 }
Ejemplo n.º 26
0
        public ViewResult Details(Guid id)
        {
            //Task<IActionResult> task = Task.Run(async () => await PDFAsync());

            Car car = _carsrepository.GetCar(id);
            //FileDescription file1 = new FileDescription
            //{
            //    Id = Guid.NewGuid(),
            //    Ext = ".jpg",
            //    Description = "test1",
            //    Enabled = true
            //};
            //FileDescription file2 = new FileDescription
            //{
            //    Id = Guid.NewGuid(),
            //    Ext = ".jpg",
            //    Description = "test2",
            //    Enabled = true
            //};
            //var file1car1 = new CarFile();
            //var file2car1 = new CarFile();
            //file1car1.Car = car;
            //file1car1.CarId = car.Id;
            //file1car1.FileDescription = file1;
            //file1car1.FileDescriptionId = file1.Id;

            //file2car1.Car = car;
            //file2car1.CarId = car.Id;
            //file2car1.FileDescription = file2;
            //file2car1.FileDescriptionId = file2.Id;
            //_fileDescriptionsRepository.Create(file1);
            //_fileDescriptionsRepository.Create(file2);
            //_carFilesRepository.Add(file1car1);
            //_carFilesRepository.Add(file2car1);


            //dane dla skończonych wynajmów - id klienta,nazwa klienta, użytkownik,tel,mail, od, do, przebieg start, przebieg koniec, id wynajmu
            List <Rent> rents         = _rentsRepository.GetAllRentsByCar(id).ToList();
            Rent        currentRent   = null;
            var         finishedRents = new List <Tuple <Guid, string, string, string, string, DateTime, DateTime, Tuple <int, int, Guid> > >();
            string      clientName    = "";

            if (rents != null)
            {
                foreach (var rent in rents)
                {
                    if (rent.IsFinished)
                    {
                        HandoverDocument document = _handoverDocumentsRepository.GetHandoverByRent(rent.Id);
                        var milage       = Tuple.Create(document.StartMilage, document.EndMilage, rent.Id);
                        var finishedrent = new Tuple <Guid, string, string, string, string, DateTime, DateTime, Tuple <int, int, Guid> >
                                               (rent.ClientId, _clientsRepository.GetClient(rent.ClientId).Name, rent.UserName, rent.UserPhone, rent.UserMail, rent.StartDate, rent.EndDate, milage);
                        finishedRents.Add(finishedrent);
                    }
                    else
                    {
                        if (rent.IsActive)
                        {
                            currentRent = rent;
                            clientName  = _clientsRepository.GetClient(rent.ClientId).Name;
                        }
                    }
                }
            }
            Service lastService            = null;
            IEnumerable <Service> services = _sevicesRepository.GetAllbyCar(car.Id);

            if (services.Count() > 0)
            {
                lastService = services.First();
                foreach (var item in services)
                {
                    item.Client = _clientsRepository.GetClient(item.ClientId);
                    if (item.Date > lastService.Date)
                    {
                        lastService = item;
                    }
                }
            }
            DateTime nextServiceDate   = car.RegistrationDate.AddYears(car.YearsServiceInterval);
            int      daysToNextService = (nextServiceDate - DateTime.Now.Date).Days;

            if (lastService != null)
            {
                nextServiceDate   = lastService.Date.AddYears(car.YearsServiceInterval);
                daysToNextService = (DateTime.Now.Date - nextServiceDate).Days;
            }
            int milageToNextService = car.NextServiceMilage - car.Milage;

            IEnumerable <TyreInfo> tyres = _tyreInfosRepository.GetAllByCar(car.Id);

            foreach (var item in tyres)
            {
                if (item.TyreShopId != Guid.Empty)
                {
                    item.TyreShop = _tyreShopsRepository.GetTyreShop(item.TyreShopId);
                }
                else
                {
                    item.TyreShop = null;
                }
            }
            FinancialInfo financial                     = _financialInfosRepository.GetCarFinancialInfo(car.Id);
            IEnumerable <MilageRecord> records          = _milageRecordsRepository.GetMilageRecordsByCar(car.Id);
            InsurancePolicy            policy           = _insurancePoliciesRepository.GetActiveCarPolicy(car.Id);
            List <InsurancePolicy>     previousPolicies = new List <InsurancePolicy>();

            foreach (var item in _insurancePoliciesRepository.GetAllCarPolicies(car.Id))
            {
                if (!item.IsActive)
                {
                    previousPolicies.Add(item);
                }
            }
            CarDetailsViewModel carDetailsViewModel = new CarDetailsViewModel()
            {
                DaysToNextService   = daysToNextService,
                NextServiceDate     = nextServiceDate,
                MilageToNextService = milageToNextService,
                FinancialInfo       = financial,
                Car                       = car,
                Services                  = services,
                TyreInfos                 = tyres,
                MilageHistory             = records,
                PageTitle                 = "Szczegóły " + car.RegistrationNumber,
                IsCurrentlyRented         = !car.IsAvailable,
                PreviousRents             = finishedRents,
                CurrentRent               = currentRent,
                CurrentRentClientName     = clientName,
                InsurancePolicy           = policy,
                PreviousInsurancePolicies = previousPolicies
            };

            return(View(carDetailsViewModel));
        }