Exemple #1
0
 public static AgencyInfo ToAgencyInfo(this Agency agency, ContractKind?contractKind,
                                       AgencyVerificationStates verificationState, DateTime?verificationDate, JsonDocument countryNames, string languageCode, string markupFormula)
 => new AgencyInfo(name: agency.Name,
                   id: agency.Id,
                   address: agency.Address,
                   billingEmail: agency.BillingEmail,
                   city: agency.City,
                   countryCode: agency.CountryCode,
                   countryName: countryNames.RootElement.GetProperty(languageCode).GetString(),
                   fax: agency.Fax,
                   phone: agency.Phone,
                   postalCode: agency.PostalCode,
                   website: agency.Website,
                   vatNumber: agency.VatNumber,
                   defaultPaymentType: BookingPaymentTypesHelper.GetDefaultPaymentType(contractKind),
                   countryHtId: agency.CountryHtId,
                   localityHtId: agency.LocalityHtId,
                   ancestors: agency.Ancestors ?? new List <int>(),
                   verificationState: verificationState,
                   verificationDate: verificationDate,
                   isActive: agency.IsActive,
                   legalAddress: agency.LegalAddress,
                   preferredPaymentMethod: agency.PreferredPaymentMethod,
                   isContractUploaded: agency.IsContractUploaded,
                   markupDisplayFormula: markupFormula,
                   preferredCurrency: agency.PreferredCurrency);
        public void Card_and_account_apr_should_return_no_payment_methods_when_deadline_is_reached()
        {
            var availability = CreateAvailability(
                isApr: true,
                deadlineDate: new DateTime(2020, 11, 22),
                checkInDate: new DateTime(2020, 11, 25));
            var settingsWithHiddenApr = CreateSettings(aprMode: AprMode.CardAndAccountPurchases);

            var availablePaymentTypes = BookingPaymentTypesHelper.GetAvailablePaymentTypes(availability, settingsWithHiddenApr,
                                                                                           ContractKind.CreditPayments, new DateTime(2020, 11, 23));

            Assert.Equal(new List <PaymentTypes>(), availablePaymentTypes);
        }
        public void Display_only_apr_should_return_no_payment_methods()
        {
            var availability = CreateAvailability(
                isApr: true,
                deadlineDate: new DateTime(2020, 11, 22),
                checkInDate: new DateTime(2020, 11, 25));
            var settingsWithHiddenApr = CreateSettings(aprMode: AprMode.DisplayOnly);

            var availablePaymentTypes = BookingPaymentTypesHelper.GetAvailablePaymentTypes(availability, settingsWithHiddenApr,
                                                                                           ContractKind.CreditPayments, new DateTime(2020, 11, 11));

            Assert.Equal(new List <PaymentTypes>(), availablePaymentTypes);
        }
        public void Not_apr_should_return_no_payment_methods_when_deadline_is_not_reached_and_hidden()
        {
            var availability = CreateAvailability(
                isApr: false,
                deadlineDate: new DateTime(2020, 11, 22),
                checkInDate: new DateTime(2020, 11, 25));
            var settingsWithHiddenApr = CreateSettings(aprMode: AprMode.Hide, deadlineOffersMode: PassedDeadlineOffersMode.Hide);

            var availablePaymentTypes = BookingPaymentTypesHelper.GetAvailablePaymentTypes(availability, settingsWithHiddenApr,
                                                                                           ContractKind.CreditPayments, new DateTime(2020, 11, 22));

            Assert.Equal(new List <PaymentTypes>(), availablePaymentTypes);
        }
        public void Contract_kind_credit_payments_should_match()
        {
            var availability = CreateAvailability(
                isApr: false,
                deadlineDate: new DateTime(2020, 11, 22),
                checkInDate: new DateTime(2020, 11, 25));
            var settingsWithHiddenApr = CreateSettings(aprMode: AprMode.CardAndAccountPurchases, deadlineOffersMode: PassedDeadlineOffersMode.CardAndAccountPurchases);

            var paymentTypes = BookingPaymentTypesHelper.GetAvailablePaymentTypes(availability, settingsWithHiddenApr,
                                                                                  ContractKind.CreditPayments, new DateTime(2020, 11, 20));

            Assert.Equal(new List <PaymentTypes> {
                PaymentTypes.VirtualAccount, PaymentTypes.CreditCard
            }, paymentTypes);
        }
        public void Not_apr_should_return_credit_card_when_deadline_is_reached_and_allowed_credit_card()
        {
            var availability = CreateAvailability(
                isApr: false,
                deadlineDate: new DateTime(2020, 11, 22),
                checkInDate: new DateTime(2020, 11, 25));
            var settingsWithHiddenApr = CreateSettings(aprMode: AprMode.Hide, deadlineOffersMode: PassedDeadlineOffersMode.CardPurchasesOnly);

            var availablePaymentTypes = BookingPaymentTypesHelper.GetAvailablePaymentTypes(availability, settingsWithHiddenApr,
                                                                                           ContractKind.CreditPayments, new DateTime(2020, 11, 22));

            Assert.Equal(new List <PaymentTypes> {
                PaymentTypes.CreditCard
            }, availablePaymentTypes);
        }
Exemple #7
0
        public async Task <List <AgentAgencyRelationInfo> > GetAgentRelations(AgentContext agent)
        {
            var roles = await _context.AgentRoles.ToListAsync();

            return(await(from cr in _context.AgentAgencyRelations
                         join ag in _context.Agencies
                         on cr.AgencyId equals ag.Id
                         join ra in _context.Agencies
                         on ag.Ancestors.Any() ? ag.Ancestors[0] : ag.Id equals ra.Id
                         where ag.IsActive && cr.AgentId == agent.AgentId
                         select new AgentAgencyRelationInfo(
                             ag.Id,
                             ag.Name,
                             cr.Type == AgentAgencyRelationTypes.Master,
                             GetActualPermissions(ra.VerificationState, cr.AgentRoleIds, roles),
                             ra.VerificationState,
                             BookingPaymentTypesHelper.GetDefaultPaymentType(ra.ContractKind)))
                   .ToListAsync());
        }