From 95b8d32041f636b46a3f4d15a5865e287aa9a178 Mon Sep 17 00:00:00 2001 From: Aditya Siregar Date: Mon, 13 Oct 2025 13:44:36 +0700 Subject: [PATCH] add approver --- .../processor/letter_outgoing_processor.go | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/internal/processor/letter_outgoing_processor.go b/internal/processor/letter_outgoing_processor.go index 7ef818a..89fa551 100644 --- a/internal/processor/letter_outgoing_processor.go +++ b/internal/processor/letter_outgoing_processor.go @@ -404,7 +404,7 @@ func (p *LetterOutgoingProcessorImpl) ProcessApprovalSubmission(ctx context.Cont if err != nil { return err } - + // Find the minimum step order (first step) minStepOrder := flow.Steps[0].StepOrder for _, step := range flow.Steps { @@ -733,9 +733,9 @@ func (p *LetterOutgoingProcessorImpl) ProcessRejection(ctx context.Context, lett for i := range allApprovals { // Only update other pending approvals from the same revision - if allApprovals[i].RevisionNumber == approval.RevisionNumber && - allApprovals[i].ID != approval.ID && - allApprovals[i].Status == entities.ApprovalStatusPending { + if allApprovals[i].RevisionNumber == approval.RevisionNumber && + allApprovals[i].ID != approval.ID && + allApprovals[i].Status == entities.ApprovalStatusPending { allApprovals[i].Status = entities.ApprovalStatusRejected if err := p.approvalRepo.Update(txCtx, &allApprovals[i]); err != nil { return err @@ -785,10 +785,10 @@ func (p *LetterOutgoingProcessorImpl) ProcessRevision(ctx context.Context, lette // Increment revision number letter.RevisionNumber++ - + // Set revision number on the new attachment attachment.RevisionNumber = letter.RevisionNumber - + // Add the new attachment if err := p.attachmentRepo.Create(txCtx, &attachment); err != nil { return err @@ -821,6 +821,7 @@ func (p *LetterOutgoingProcessorImpl) ProcessRevision(ctx context.Context, lette ParallelGroup: approval.ParallelGroup, IsRequired: approval.IsRequired, Status: entities.ApprovalStatusPending, + ApproverID: approval.ApproverID, } if err := p.approvalRepo.Create(txCtx, &newApproval); err != nil { return err @@ -897,12 +898,12 @@ func (p *LetterOutgoingProcessorImpl) AddAttachments(ctx context.Context, letter if err != nil { return err } - + // Set revision number on all attachments for i := range attachments { attachments[i].RevisionNumber = letter.RevisionNumber } - + if err := p.attachmentRepo.CreateBulk(txCtx, attachments); err != nil { return err } @@ -984,7 +985,7 @@ func (p *LetterOutgoingProcessorImpl) GetApprovalsByLetter(ctx context.Context, if err != nil { return nil, err } - + return p.GetApprovalsByLetterAndRevision(ctx, letterID, letter.RevisionNumber) } @@ -994,7 +995,7 @@ func (p *LetterOutgoingProcessorImpl) GetApprovalsByLetterAndRevision(ctx contex if err != nil { return nil, err } - + // Filter to only return approvals for the specified revision var currentRevisionApprovals []entities.LetterOutgoingApproval for _, approval := range approvals { @@ -1002,7 +1003,7 @@ func (p *LetterOutgoingProcessorImpl) GetApprovalsByLetterAndRevision(ctx contex currentRevisionApprovals = append(currentRevisionApprovals, approval) } } - + return currentRevisionApprovals, nil }