Merge branch 'main' of https://gits.altru.id/ESLOGAD/eslogad-backend
This commit is contained in:
commit
8aadb06d40
@ -404,7 +404,7 @@ func (p *LetterOutgoingProcessorImpl) ProcessApprovalSubmission(ctx context.Cont
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the minimum step order (first step)
|
// Find the minimum step order (first step)
|
||||||
minStepOrder := flow.Steps[0].StepOrder
|
minStepOrder := flow.Steps[0].StepOrder
|
||||||
for _, step := range flow.Steps {
|
for _, step := range flow.Steps {
|
||||||
@ -733,9 +733,9 @@ func (p *LetterOutgoingProcessorImpl) ProcessRejection(ctx context.Context, lett
|
|||||||
|
|
||||||
for i := range allApprovals {
|
for i := range allApprovals {
|
||||||
// Only update other pending approvals from the same revision
|
// Only update other pending approvals from the same revision
|
||||||
if allApprovals[i].RevisionNumber == approval.RevisionNumber &&
|
if allApprovals[i].RevisionNumber == approval.RevisionNumber &&
|
||||||
allApprovals[i].ID != approval.ID &&
|
allApprovals[i].ID != approval.ID &&
|
||||||
allApprovals[i].Status == entities.ApprovalStatusPending {
|
allApprovals[i].Status == entities.ApprovalStatusPending {
|
||||||
allApprovals[i].Status = entities.ApprovalStatusRejected
|
allApprovals[i].Status = entities.ApprovalStatusRejected
|
||||||
if err := p.approvalRepo.Update(txCtx, &allApprovals[i]); err != nil {
|
if err := p.approvalRepo.Update(txCtx, &allApprovals[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -785,10 +785,10 @@ func (p *LetterOutgoingProcessorImpl) ProcessRevision(ctx context.Context, lette
|
|||||||
|
|
||||||
// Increment revision number
|
// Increment revision number
|
||||||
letter.RevisionNumber++
|
letter.RevisionNumber++
|
||||||
|
|
||||||
// Set revision number on the new attachment
|
// Set revision number on the new attachment
|
||||||
attachment.RevisionNumber = letter.RevisionNumber
|
attachment.RevisionNumber = letter.RevisionNumber
|
||||||
|
|
||||||
// Add the new attachment
|
// Add the new attachment
|
||||||
if err := p.attachmentRepo.Create(txCtx, &attachment); err != nil {
|
if err := p.attachmentRepo.Create(txCtx, &attachment); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -821,6 +821,7 @@ func (p *LetterOutgoingProcessorImpl) ProcessRevision(ctx context.Context, lette
|
|||||||
ParallelGroup: approval.ParallelGroup,
|
ParallelGroup: approval.ParallelGroup,
|
||||||
IsRequired: approval.IsRequired,
|
IsRequired: approval.IsRequired,
|
||||||
Status: entities.ApprovalStatusPending,
|
Status: entities.ApprovalStatusPending,
|
||||||
|
ApproverID: approval.ApproverID,
|
||||||
}
|
}
|
||||||
if err := p.approvalRepo.Create(txCtx, &newApproval); err != nil {
|
if err := p.approvalRepo.Create(txCtx, &newApproval); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -897,12 +898,12 @@ func (p *LetterOutgoingProcessorImpl) AddAttachments(ctx context.Context, letter
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set revision number on all attachments
|
// Set revision number on all attachments
|
||||||
for i := range attachments {
|
for i := range attachments {
|
||||||
attachments[i].RevisionNumber = letter.RevisionNumber
|
attachments[i].RevisionNumber = letter.RevisionNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.attachmentRepo.CreateBulk(txCtx, attachments); err != nil {
|
if err := p.attachmentRepo.CreateBulk(txCtx, attachments); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -984,7 +985,7 @@ func (p *LetterOutgoingProcessorImpl) GetApprovalsByLetter(ctx context.Context,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.GetApprovalsByLetterAndRevision(ctx, letterID, letter.RevisionNumber)
|
return p.GetApprovalsByLetterAndRevision(ctx, letterID, letter.RevisionNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -994,7 +995,7 @@ func (p *LetterOutgoingProcessorImpl) GetApprovalsByLetterAndRevision(ctx contex
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter to only return approvals for the specified revision
|
// Filter to only return approvals for the specified revision
|
||||||
var currentRevisionApprovals []entities.LetterOutgoingApproval
|
var currentRevisionApprovals []entities.LetterOutgoingApproval
|
||||||
for _, approval := range approvals {
|
for _, approval := range approvals {
|
||||||
@ -1002,7 +1003,7 @@ func (p *LetterOutgoingProcessorImpl) GetApprovalsByLetterAndRevision(ctx contex
|
|||||||
currentRevisionApprovals = append(currentRevisionApprovals, approval)
|
currentRevisionApprovals = append(currentRevisionApprovals, approval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentRevisionApprovals, nil
|
return currentRevisionApprovals, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user