-
Notifications
You must be signed in to change notification settings - Fork 0
fix: cross-screen coherence found in live walkthrough #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,6 +154,11 @@ export class ContractorsRepository { | |
| const contractor = await this.findById(orgId, id); | ||
| if (!contractor) return null; | ||
|
|
||
| // Foreign contractors are required to file a W-8BEN, not a W-9. The | ||
| // documentStatus.hasCurrentW9 field carries "has the current required | ||
| // tax form" regardless of which form that is for this contractor type. | ||
| const requiredTaxForm = contractor.type === 'foreign' ? 'w8ben' : 'w9'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While keeping the |
||
|
|
||
| // Run the 5 child queries concurrently. Previous implementation | ||
| // awaited them sequentially, which added one round-trip per | ||
| // sub-resource (~6× the wall-clock of the slowest fetch). They are | ||
|
|
@@ -192,11 +197,11 @@ export class ContractorsRepository { | |
| expiring: string; | ||
| }>( | ||
| `SELECT | ||
| EXISTS(SELECT 1 FROM tax_documents WHERE contractor_id = $1 AND document_type = 'w9' AND is_current = true AND (expires_at IS NULL OR expires_at > now())) as has_w9, | ||
| EXISTS(SELECT 1 FROM tax_documents WHERE contractor_id = $1 AND document_type = $2::tax_document_type AND is_current = true AND (expires_at IS NULL OR expires_at > now())) as has_w9, | ||
| EXISTS(SELECT 1 FROM tax_documents WHERE contractor_id = $1 AND document_type = 'contract' AND is_current = true AND (expires_at IS NULL OR expires_at > now())) as has_contract, | ||
| COUNT(*) FILTER (WHERE expires_at IS NOT NULL AND expires_at < now() + INTERVAL '30 days') as expiring | ||
| FROM tax_documents WHERE contractor_id = $1 AND is_current = true`, | ||
| [id], | ||
| [id, requiredTaxForm], | ||
| ).catch(() => ({ rows: [{ has_w9: false, has_contract: false, expiring: '0' }] })), | ||
| this.pool.query<{ total: string }>( | ||
| `SELECT COALESCE(SUM(total_amount), 0) as total | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
now()to close the previous status history entry in a seed script that uses relative dates (viaeffectiveDate) can lead to overlapping periods in thecontractor_status_historytable. IfeffectiveDateis in the past, the old status will be marked as effective until the moment the seed script runs, while the new 'offboarded' status will be marked as effective from the earliereffectiveDate. It is better to use the same timestamp for both closing the old record and starting the new one.