Bug/gh issues fiz (#1103)
* refactor: optimize page loading and data fetching * fix: resolve recurring production runtime errors * feat: add MCP company and customer updates * fix: handle year-end tax adjustments * feat: harden annual report compliance * fix: expand invoice logo and font support * fix: sanitize API route error responses * fix: sanitize user-facing error messages * feat: persist onboarding and tax assessment notices * fix: reduce cloud backup audit churn * feat: refine invoice editor layout * fix: show saved tax adjustments in INK2 * fix: complete annual report API mappings * docs: record operational safeguards and decisions * fix: harden annual report review findings * fix: adjust column span for description based on VAT registration * New css class name
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { buildSandboxCustomers } from '../customers'
|
||||
|
||||
describe('sandbox customer seed data', () => {
|
||||
it('sets the required VAT-validation state for every customer', () => {
|
||||
const customers = buildSandboxCustomers('user-1', 'company-1')
|
||||
|
||||
expect(customers).toHaveLength(3)
|
||||
expect(customers.every((customer) => typeof customer.vat_number_validated === 'boolean')).toBe(
|
||||
true,
|
||||
)
|
||||
expect(customers.find((customer) => customer.customer_type === 'individual')).toMatchObject({
|
||||
name: 'Anna Lindström',
|
||||
vat_number_validated: false,
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,47 @@
|
||||
export function buildSandboxCustomers(userId: string, companyId: string) {
|
||||
return [
|
||||
{
|
||||
user_id: userId,
|
||||
company_id: companyId,
|
||||
name: 'Björk & Partner AB',
|
||||
customer_type: 'swedish_business',
|
||||
email: 'faktura@bjorkpartner.se',
|
||||
org_number: '5566778899',
|
||||
vat_number: 'SE556677889901',
|
||||
vat_number_validated: true,
|
||||
address_line1: 'Storgatan 10',
|
||||
postal_code: '111 44',
|
||||
city: 'Stockholm',
|
||||
country: 'SE',
|
||||
default_payment_terms: 30,
|
||||
},
|
||||
{
|
||||
user_id: userId,
|
||||
company_id: companyId,
|
||||
name: 'Schmidt GmbH',
|
||||
customer_type: 'eu_business',
|
||||
email: 'billing@schmidt.de',
|
||||
org_number: 'HRB 12345',
|
||||
vat_number: 'DE123456789',
|
||||
vat_number_validated: true,
|
||||
address_line1: 'Hauptstraße 5',
|
||||
postal_code: '10115',
|
||||
city: 'Berlin',
|
||||
country: 'DE',
|
||||
default_payment_terms: 30,
|
||||
},
|
||||
{
|
||||
user_id: userId,
|
||||
company_id: companyId,
|
||||
name: 'Anna Lindström',
|
||||
customer_type: 'individual',
|
||||
email: 'anna.lindstrom@example.com',
|
||||
vat_number_validated: false,
|
||||
address_line1: 'Lillgatan 3',
|
||||
postal_code: '222 33',
|
||||
city: 'Malmö',
|
||||
country: 'SE',
|
||||
default_payment_terms: 30,
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { createLogger } from '@/lib/logger'
|
||||
import { checkRateLimit } from '@/lib/auth/rate-limit-http'
|
||||
import { truncateIp } from '@/lib/api/v1/with-api-v1'
|
||||
import { ensureSandboxAgentProfile } from '@/lib/sandbox/ensure-agent'
|
||||
import { buildSandboxCustomers } from './customers'
|
||||
|
||||
// Anonymous sign-in is enabled in all environments so visitors can try the
|
||||
// product; a per-/24 cap on the seed endpoint keeps a single network from
|
||||
@@ -145,6 +146,9 @@ export async function POST(request: Request) {
|
||||
invoice_default_days: 30,
|
||||
onboarding_step: 6,
|
||||
onboarding_complete: true,
|
||||
initial_setup_path: 'fresh',
|
||||
initial_setup_completed_at: new Date().toISOString(),
|
||||
initial_setup_dismissed_at: new Date().toISOString(),
|
||||
is_sandbox: true,
|
||||
// Dimensions demo: the register/pickers render out of the box.
|
||||
dimensions_enabled: true,
|
||||
@@ -211,50 +215,7 @@ export async function POST(request: Request) {
|
||||
// 5. Create customers
|
||||
const { data: customers, error: custError } = await supabase
|
||||
.from('customers')
|
||||
.insert([
|
||||
{
|
||||
user_id: userId,
|
||||
company_id: companyId,
|
||||
name: 'Björk & Partner AB',
|
||||
customer_type: 'swedish_business',
|
||||
email: 'faktura@bjorkpartner.se',
|
||||
org_number: '5566778899',
|
||||
vat_number: 'SE556677889901',
|
||||
vat_number_validated: true,
|
||||
address_line1: 'Storgatan 10',
|
||||
postal_code: '111 44',
|
||||
city: 'Stockholm',
|
||||
country: 'SE',
|
||||
default_payment_terms: 30,
|
||||
},
|
||||
{
|
||||
user_id: userId,
|
||||
company_id: companyId,
|
||||
name: 'Schmidt GmbH',
|
||||
customer_type: 'eu_business',
|
||||
email: 'billing@schmidt.de',
|
||||
org_number: 'HRB 12345',
|
||||
vat_number: 'DE123456789',
|
||||
vat_number_validated: true,
|
||||
address_line1: 'Hauptstraße 5',
|
||||
postal_code: '10115',
|
||||
city: 'Berlin',
|
||||
country: 'DE',
|
||||
default_payment_terms: 30,
|
||||
},
|
||||
{
|
||||
user_id: userId,
|
||||
company_id: companyId,
|
||||
name: 'Anna Lindström',
|
||||
customer_type: 'individual',
|
||||
email: 'anna.lindstrom@example.com',
|
||||
address_line1: 'Lillgatan 3',
|
||||
postal_code: '222 33',
|
||||
city: 'Malmö',
|
||||
country: 'SE',
|
||||
default_payment_terms: 30,
|
||||
},
|
||||
])
|
||||
.insert(buildSandboxCustomers(userId, companyId))
|
||||
.select('id, name')
|
||||
|
||||
if (custError) throw custError
|
||||
|
||||
Reference in New Issue
Block a user