fix setting and add rental policies
Test / Type Check (all packages) (push) Has been cancelled
Test / API Unit Tests (push) Has been cancelled
Test / Homepage Unit Tests (push) Has been cancelled
Test / Carplace Unit Tests (push) Has been cancelled
Test / Admin Unit Tests (push) Has been cancelled
Test / Dashboard Unit Tests (push) Has been cancelled
Test / API Integration Tests (push) Has been cancelled
Build & Push / Pipeline Tests (push) Waiting to run
Build & Push / Build & Push Docker Image (push) Blocked by required conditions
Test / Type Check (all packages) (push) Has been cancelled
Test / API Unit Tests (push) Has been cancelled
Test / Homepage Unit Tests (push) Has been cancelled
Test / Carplace Unit Tests (push) Has been cancelled
Test / Admin Unit Tests (push) Has been cancelled
Test / Dashboard Unit Tests (push) Has been cancelled
Test / API Integration Tests (push) Has been cancelled
Build & Push / Pipeline Tests (push) Waiting to run
Build & Push / Build & Push Docker Image (push) Blocked by required conditions
This commit is contained in:
@@ -19,7 +19,17 @@ describe('company schemas edge cases', () => {
|
||||
})
|
||||
|
||||
it('keeps contract, accounting, insurance, and pricing settings inside known enums', () => {
|
||||
expect(contractSettingsSchema.parse({ fuelPolicyType: 'FULL_TO_FULL', additionalDriverCharge: 'PER_DAY', taxRate: 20 })).toMatchObject({ fuelPolicyType: 'FULL_TO_FULL' })
|
||||
expect(contractSettingsSchema.parse({
|
||||
fuelPolicy: 'Return with the same fuel level.',
|
||||
fuelPolicyType: 'FULL_TO_FULL',
|
||||
additionalDriverPolicy: 'Additional drivers must be approved before pickup.',
|
||||
additionalDriverCharge: 'PER_DAY',
|
||||
taxRate: 20,
|
||||
})).toMatchObject({
|
||||
fuelPolicy: 'Return with the same fuel level.',
|
||||
fuelPolicyType: 'FULL_TO_FULL',
|
||||
additionalDriverPolicy: 'Additional drivers must be approved before pickup.',
|
||||
})
|
||||
expect(contractSettingsSchema.safeParse({ fuelPolicyType: 'CHAOS' }).success).toBe(false)
|
||||
expect(accountingSettingsSchema.parse({ reportingPeriod: 'MONTHLY', fiscalYearStart: 1, currency: 'MAD' })).toMatchObject({ fiscalYearStart: 1 })
|
||||
expect(accountingSettingsSchema.safeParse({ fiscalYearStart: 13 }).success).toBe(false)
|
||||
|
||||
@@ -106,6 +106,7 @@ export const contractSettingsSchema = z.object({
|
||||
depositPolicy: z.string().optional(),
|
||||
lateFeePolicy: z.string().optional(),
|
||||
damagePolicy: z.string().optional(),
|
||||
additionalDriverPolicy: z.string().optional(),
|
||||
contractFooterNote: z.string().optional(),
|
||||
invoiceFooterNote: z.string().optional(),
|
||||
signatureRequired: z.boolean().optional(),
|
||||
|
||||
@@ -105,13 +105,6 @@ export async function getContractSettings(companyId: string) {
|
||||
|
||||
export async function updateContractSettings(companyId: string, data: any) {
|
||||
await assertSettingsFeature(companyId, 'settings.rental_policies_basic')
|
||||
if (
|
||||
data.additionalDriverCharge ||
|
||||
data.additionalDriverDailyRate !== undefined ||
|
||||
data.additionalDriverFlatRate !== undefined
|
||||
) {
|
||||
await assertSettingsFeature(companyId, 'settings.additional_driver_fees')
|
||||
}
|
||||
return repo.upsertContractSettings(companyId, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ const FEATURE_PLANS: Record<SettingsFeatureKey, { plans: Plan[]; requiredPlan: P
|
||||
'settings.branding_hero': { plans: GROWTH_PLUS, requiredPlan: 'GROWTH' },
|
||||
'settings.renter_payments': { plans: GROWTH_PLUS, requiredPlan: 'GROWTH' },
|
||||
'settings.rental_policies_basic': { plans: ALL_PLANS, requiredPlan: null },
|
||||
'settings.additional_driver_fees': { plans: GROWTH_PLUS, requiredPlan: 'GROWTH' },
|
||||
'settings.additional_driver_fees': { plans: ALL_PLANS, requiredPlan: null },
|
||||
'settings.insurance_policies': { plans: GROWTH_PLUS, requiredPlan: 'GROWTH' },
|
||||
'settings.pricing_rules': { plans: GROWTH_PLUS, requiredPlan: 'GROWTH' },
|
||||
'settings.accounting_defaults': { plans: GROWTH_PLUS, requiredPlan: 'GROWTH' },
|
||||
|
||||
@@ -209,6 +209,7 @@ export async function getContract(id: string, companyId: string) {
|
||||
depositPolicy: contractSettings.depositPolicy,
|
||||
lateFeePolicy: contractSettings.lateFeePolicy,
|
||||
damagePolicy: contractSettings.damagePolicy,
|
||||
additionalDriverPolicy: contractSettings.additionalDriverPolicy,
|
||||
footerNote: contractSettings.contractFooterNote,
|
||||
signatureRequired: contractSettings.signatureRequired,
|
||||
},
|
||||
|
||||
@@ -70,6 +70,7 @@ describe('company configuration API contracts', () => {
|
||||
vi.mocked(companyService.setCustomDomain).mockResolvedValue({ id: 'brand_1', customDomain: 'cars.example.com' } as never)
|
||||
vi.mocked(companyService.createInsurancePolicy).mockResolvedValue({ id: 'policy_1' } as never)
|
||||
vi.mocked(companyService.createPricingRule).mockResolvedValue({ id: 'rule_1' } as never)
|
||||
vi.mocked(companyService.updateContractSettings).mockResolvedValue({ id: 'contract_settings_1' } as never)
|
||||
vi.mocked(companyService.updateAccountingSettings).mockResolvedValue({ id: 'accounting_1' } as never)
|
||||
})
|
||||
|
||||
@@ -126,6 +127,25 @@ describe('company configuration API contracts', () => {
|
||||
}))
|
||||
})
|
||||
|
||||
it('passes rental policy text settings through to the service', async () => {
|
||||
const res = await request(app).patch('/api/v1/companies/me/contract-settings').send({
|
||||
fuelPolicy: 'Return with the same fuel level shown at pickup.',
|
||||
fuelPolicyType: 'SAME_TO_SAME',
|
||||
fuelPolicyNote: 'Charge refueling when fuel is lower at return.',
|
||||
additionalDriverPolicy: 'Only approved additional drivers may operate the vehicle.',
|
||||
damagePolicy: 'Damage is assessed at return inspection.',
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(companyService.updateContractSettings).toHaveBeenCalledWith('company_1', {
|
||||
fuelPolicy: 'Return with the same fuel level shown at pickup.',
|
||||
fuelPolicyType: 'SAME_TO_SAME',
|
||||
fuelPolicyNote: 'Charge refueling when fuel is lower at return.',
|
||||
additionalDriverPolicy: 'Only approved additional drivers may operate the vehicle.',
|
||||
damagePolicy: 'Damage is assessed at return inspection.',
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects malformed pricing rules before service execution', async () => {
|
||||
const res = await request(app).post('/api/v1/companies/me/pricing-rules').send({
|
||||
name: 'Young driver fee',
|
||||
|
||||
Reference in New Issue
Block a user