Skip to content

Commit

Permalink
Merge pull request #67 from AplinkosMinisterija/update-fish-batches
Browse files Browse the repository at this point in the history
Update fish batches when updating fish stocking
  • Loading branch information
ambrazasp authored Jun 11, 2024
2 parents b0ad8b3 + 50d6a41 commit ffc6cc8
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions services/fishStockings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,14 @@ export default class FishStockingsService extends moleculer.Service {
// Validate fishOrigin
await validateFishOrigin(ctx, existingFishStocking);

// Admin can add, remove or update batches
if (ctx.params.batches) {
await ctx.call('fishBatches.updateBatches', {
batches: ctx.params.batches,
fishStocking: Number(ctx.params.id),
});
}

const fishStockingBeforeUpdate = await this.resolveEntities(ctx);
if (ctx.params.inspector) {
const inspector: any = await ctx.call('auth.users.get', {
Expand All @@ -572,13 +580,7 @@ export default class FishStockingsService extends moleculer.Service {
organization: 'AAD',
},
});
// Inspector can add, remove or update batches
if (ctx.params.batches) {
await ctx.call('fishBatches.updateBatches', {
batches: ctx.params.batches,
fishStocking: Number(ctx.params.id),
});
}

if (fishStockingBeforeUpdate.inspector?.id !== ctx.params.inspector) {
if (inspector) {
await ctx.call('mail.sendFishStockingAssignedEmail', {
Expand Down

0 comments on commit ffc6cc8

Please sign in to comment.