feat: buyer-specific request lists

Add is_buyer_specific and visible_to_buyer_group to diligence_requests.
Filter request list for buyers to show general requests plus their
buyer-group-specific ones.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
James 2026-02-23 02:53:40 -05:00
parent 70939a602e
commit 9295b18560
3 changed files with 16 additions and 5 deletions

View File

@ -233,6 +233,9 @@ var additiveMigrationStmts = []string{
`ALTER TABLE folders ADD COLUMN sort_order INTEGER DEFAULT 0`,
// Section 7: file storage path
`ALTER TABLE files ADD COLUMN storage_path TEXT DEFAULT ''`,
// Section 9: buyer-specific requests
`ALTER TABLE diligence_requests ADD COLUMN is_buyer_specific INTEGER DEFAULT 0`,
`ALTER TABLE diligence_requests ADD COLUMN visible_to_buyer_group TEXT DEFAULT ''`,
}
func seed(db *sql.DB) error {

View File

@ -363,7 +363,7 @@ func (h *Handler) getFiles(dealID string) []*model.File {
}
func (h *Handler) getRequests(dealID string, profile *model.Profile) []*model.DiligenceRequest {
query := "SELECT id, deal_id, item_number, section, description, priority, atlas_status, atlas_note, confidence, buyer_comment, seller_comment, buyer_group FROM diligence_requests WHERE deal_id = ?"
query := "SELECT id, deal_id, item_number, section, description, priority, atlas_status, atlas_note, confidence, buyer_comment, seller_comment, buyer_group, linked_file_ids, COALESCE(is_buyer_specific, 0), COALESCE(visible_to_buyer_group, '') FROM diligence_requests WHERE deal_id = ?"
args := []interface{}{dealID}
if rbac.EffectiveIsBuyer(profile) {
@ -374,7 +374,13 @@ func (h *Handler) getRequests(dealID string, profile *model.Profile) []*model.Di
placeholders[i] = "?"
args = append(args, g)
}
query += " AND buyer_group IN (" + strings.Join(placeholders, ",") + ")"
// Show general requests (not buyer-specific) AND buyer-specific ones for this group
query += " AND (COALESCE(is_buyer_specific, 0) = 0 OR COALESCE(visible_to_buyer_group, '') IN (" + strings.Join(placeholders, ",") + "))"
// Also filter by buyer_group for general requests
query += " AND (buyer_group IN (" + strings.Join(placeholders, ",") + ") OR buyer_group = '')"
for _, g := range groups {
args = append(args, g)
}
}
}
query += " ORDER BY item_number"
@ -388,7 +394,7 @@ func (h *Handler) getRequests(dealID string, profile *model.Profile) []*model.Di
var reqs []*model.DiligenceRequest
for rows.Next() {
r := &model.DiligenceRequest{}
rows.Scan(&r.ID, &r.DealID, &r.ItemNumber, &r.Section, &r.Description, &r.Priority, &r.AtlasStatus, &r.AtlasNote, &r.Confidence, &r.BuyerComment, &r.SellerComment, &r.BuyerGroup)
rows.Scan(&r.ID, &r.DealID, &r.ItemNumber, &r.Section, &r.Description, &r.Priority, &r.AtlasStatus, &r.AtlasNote, &r.Confidence, &r.BuyerComment, &r.SellerComment, &r.BuyerGroup, &r.LinkedFileIDs, &r.IsBuyerSpecific, &r.VisibleToBuyerGroup)
reqs = append(reqs, r)
}
return reqs

View File

@ -99,6 +99,8 @@ type DiligenceRequest struct {
SellerComment string
BuyerGroup string
LinkedFileIDs string
IsBuyerSpecific bool
VisibleToBuyerGroup string
CreatedBy string
CreatedAt time.Time
UpdatedAt time.Time