mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 05:18:11 +00:00
Warehouses confilct fix
This commit is contained in:
@@ -60,7 +60,6 @@ import { RoutesModule } from './modules/routes/routes.module';
|
|||||||
import { WarehousesModule } from './modules/warehouses/warehouses.module';
|
import { WarehousesModule } from './modules/warehouses/warehouses.module';
|
||||||
import { OverviewModule } from './modules/overview/overview.module';
|
import { OverviewModule } from './modules/overview/overview.module';
|
||||||
import { FacilitiesModule } from './modules/facilities/facilities.module';
|
import { FacilitiesModule } from './modules/facilities/facilities.module';
|
||||||
import { OverviewModule } from './modules/overview/overview.module';
|
|
||||||
import { VehiclesModule } from './modules/vehicles/vehicles.module';
|
import { VehiclesModule } from './modules/vehicles/vehicles.module';
|
||||||
import { DriversModule } from './modules/drivers/drivers.module';
|
import { DriversModule } from './modules/drivers/drivers.module';
|
||||||
|
|
||||||
@@ -122,8 +121,6 @@ import { DriversModule } from './modules/drivers/drivers.module';
|
|||||||
WarehousesModule,
|
WarehousesModule,
|
||||||
OverviewModule,
|
OverviewModule,
|
||||||
FacilitiesModule,
|
FacilitiesModule,
|
||||||
WarehousesModule,
|
|
||||||
OverviewModule,
|
|
||||||
VehiclesModule,
|
VehiclesModule,
|
||||||
DriversModule,
|
DriversModule,
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Module, forwardRef } from "@nestjs/common";
|
import { DynamicModule, Module, forwardRef } from "@nestjs/common";
|
||||||
import { TypeOrmModule } from "@nestjs/typeorm";
|
import { TypeOrmModule } from "@nestjs/typeorm";
|
||||||
import { HttpModule } from "@nestjs/axios";
|
import { HttpModule } from "@nestjs/axios";
|
||||||
import { ConfigModule, ConfigService } from "@nestjs/config";
|
import { ConfigModule, ConfigService } from "@nestjs/config";
|
||||||
@@ -23,12 +23,10 @@ import { PaymentRefundEntity } from "./entities/payment-refund.entity";
|
|||||||
|
|
||||||
const FREIGHT_QUEUE = PAYMENT_QUEUES[PaymentServiceEnum.FREIGHT];
|
const FREIGHT_QUEUE = PAYMENT_QUEUES[PaymentServiceEnum.FREIGHT];
|
||||||
|
|
||||||
@Module({
|
function rabbitMQImport(): DynamicModule[] {
|
||||||
imports: [
|
if (!process.env.PAYMENT_RABBITMQ_URL) return [];
|
||||||
HttpModule.register({ timeout: 10_000 }),
|
|
||||||
ConfigModule,
|
return [
|
||||||
forwardRef(() => TrainSchedulingModule),
|
|
||||||
TypeOrmModule.forFeature([PaymentWebhookEventEntity, PaymentRefundEntity]),
|
|
||||||
RabbitMQModule.forRootAsync({
|
RabbitMQModule.forRootAsync({
|
||||||
inject: [ConfigService],
|
inject: [ConfigService],
|
||||||
useFactory: (config: ConfigService) => ({
|
useFactory: (config: ConfigService) => ({
|
||||||
@@ -49,6 +47,16 @@ const FREIGHT_QUEUE = PAYMENT_QUEUES[PaymentServiceEnum.FREIGHT];
|
|||||||
connectionInitOptions: { wait: false },
|
connectionInitOptions: { wait: false },
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
HttpModule.register({ timeout: 10_000 }),
|
||||||
|
ConfigModule,
|
||||||
|
forwardRef(() => TrainSchedulingModule),
|
||||||
|
TypeOrmModule.forFeature([PaymentWebhookEventEntity, PaymentRefundEntity]),
|
||||||
|
...rabbitMQImport(),
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
PaymentRepository,
|
PaymentRepository,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import { PaymentClientService } from "./payment-client.service";
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as Handlebars from "handlebars";
|
import * as Handlebars from "handlebars";
|
||||||
import { ConfigService } from "@nestjs/config";
|
|
||||||
import { Booking } from "../bookings/entities/booking.entity";
|
import { Booking } from "../bookings/entities/booking.entity";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Entity, Column, Index } from 'typeorm';
|
import { Entity, Column } from 'typeorm';
|
||||||
import { BaseEntity } from '@edr/api-common';
|
import { BaseEntity } from '@edr/api-common';
|
||||||
|
|
||||||
export enum VehicleType {
|
export enum VehicleType {
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ export class Warehouse extends BaseEntity {
|
|||||||
@Column({ name: 'station_id', type: 'uuid', nullable: true })
|
@Column({ name: 'station_id', type: 'uuid', nullable: true })
|
||||||
stationId?: string | null;
|
stationId?: string | null;
|
||||||
|
|
||||||
@ManyToOne(() => Yard, { nullable: true })
|
|
||||||
@JoinColumn({ name: 'station_id' })
|
|
||||||
facility?: Yard | null;
|
|
||||||
|
|
||||||
@Column({ name: 'location_name', type: 'varchar', length: 200, nullable: true })
|
@Column({ name: 'location_name', type: 'varchar', length: 200, nullable: true })
|
||||||
locationName?: string | null;
|
locationName?: string | null;
|
||||||
|
|
||||||
|
|||||||
@@ -142,16 +142,4 @@ export class WarehouseInventoryController {
|
|||||||
dispatch(@Param('id', ParseUUIDPipe) id: string, @Body('performedBy') performedBy?: string) {
|
dispatch(@Param('id', ParseUUIDPipe) id: string, @Body('performedBy') performedBy?: string) {
|
||||||
return this.inventoryService.dispatch(id, performedBy);
|
return this.inventoryService.dispatch(id, performedBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post(':id/load')
|
|
||||||
@ApiOperation({ summary: 'Mark ready inventory as loaded' })
|
|
||||||
load(@Param('id', ParseUUIDPipe) id: string) {
|
|
||||||
return this.inventoryService.load(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post(':id/dispatch')
|
|
||||||
@ApiOperation({ summary: 'Dispatch loaded inventory' })
|
|
||||||
dispatch(@Param('id', ParseUUIDPipe) id: string) {
|
|
||||||
return this.inventoryService.dispatch(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { Between, DataSource, EntityManager, FindManyOptions, ILike, LessThanOrE
|
|||||||
|
|
||||||
import { FilterWarehouseInventoryDto } from './dto/filter-inventory.dto';
|
import { FilterWarehouseInventoryDto } from './dto/filter-inventory.dto';
|
||||||
import { InquiryWarehouseInventoryDto } from './dto/inquiry-inventory.dto';
|
import { InquiryWarehouseInventoryDto } from './dto/inquiry-inventory.dto';
|
||||||
|
import { LoadInventoryDto } from './dto/load-inventory.dto';
|
||||||
|
import { MoveInventoryDto } from './dto/move-inventory.dto';
|
||||||
import { ReceiveWarehouseInventoryDto } from './dto/receive-inventory.dto';
|
import { ReceiveWarehouseInventoryDto } from './dto/receive-inventory.dto';
|
||||||
import { ReserveInventoryDto } from './dto/reserve-inventory.dto';
|
import { ReserveInventoryDto } from './dto/reserve-inventory.dto';
|
||||||
import { UnloadBookingDto } from './dto/unload-booking.dto';
|
import { UnloadBookingDto } from './dto/unload-booking.dto';
|
||||||
@@ -46,6 +48,103 @@ export interface InventoryInquiryResult {
|
|||||||
readyForLoadingAt: Date | null;
|
readyForLoadingAt: Date | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BookingSummaryRow {
|
||||||
|
id: string;
|
||||||
|
reference: string | null;
|
||||||
|
status: string | null;
|
||||||
|
customer: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ArrivalQueueRow {
|
||||||
|
bookingId: string;
|
||||||
|
bookingReference: string | null;
|
||||||
|
customer: string | null;
|
||||||
|
cargo: string | null;
|
||||||
|
container: string | null;
|
||||||
|
arrivalDate: Date | null;
|
||||||
|
bookingStatus: string | null;
|
||||||
|
inventoryId: string | null;
|
||||||
|
currentStatus: string | null;
|
||||||
|
inspectionStatus: string | null;
|
||||||
|
facility: string | null;
|
||||||
|
warehouse: string | null;
|
||||||
|
yard: string | null;
|
||||||
|
zone: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ArrivalQueueItem {
|
||||||
|
bookingId: string;
|
||||||
|
bookingReference: string | null;
|
||||||
|
customer: string | null;
|
||||||
|
cargo: string | null;
|
||||||
|
container: string | null;
|
||||||
|
facility: string | null;
|
||||||
|
warehouse: string | null;
|
||||||
|
yard: string | null;
|
||||||
|
zone: string | null;
|
||||||
|
inventoryId: string | null;
|
||||||
|
currentStatus: string | null;
|
||||||
|
arrivalDate: Date | null;
|
||||||
|
inspectionStatus: string | null;
|
||||||
|
unloaded: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DefaultLocation {
|
||||||
|
warehouseId: string;
|
||||||
|
facilityId?: string | null;
|
||||||
|
yardId: string;
|
||||||
|
zoneId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AutoUnloadResult {
|
||||||
|
processedCount: number;
|
||||||
|
skippedCount: number;
|
||||||
|
failedCount: number;
|
||||||
|
results: Array<{
|
||||||
|
bookingId: string;
|
||||||
|
inventoryId?: string;
|
||||||
|
status: 'PROCESSED' | 'FAILED';
|
||||||
|
reason?: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AutoLoadResult {
|
||||||
|
loadedCount: number;
|
||||||
|
skippedCount: number;
|
||||||
|
results: Array<{
|
||||||
|
inventoryId: string;
|
||||||
|
status: 'LOADED' | 'SKIPPED';
|
||||||
|
reason?: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface WarehouseDashboardSummary {
|
||||||
|
totalWarehouses: number;
|
||||||
|
totalInventory: number;
|
||||||
|
receivedToday: number;
|
||||||
|
stored: number;
|
||||||
|
reserved: number;
|
||||||
|
readyForLoading: number;
|
||||||
|
loaded: number;
|
||||||
|
dispatched: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LocationRef {
|
||||||
|
warehouseId: string;
|
||||||
|
yardId: string;
|
||||||
|
zoneId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LocationNode {
|
||||||
|
capacityWeight?: number | null;
|
||||||
|
capacityContainers?: number | null;
|
||||||
|
currentWeight: number;
|
||||||
|
maxWeight?: number | null;
|
||||||
|
maxVolume?: number | null;
|
||||||
|
currentVolume?: number | null;
|
||||||
|
currentContainers: number;
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class WarehouseInventoryService {
|
export class WarehouseInventoryService {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -386,7 +485,7 @@ export class WarehouseInventoryService {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.applyCapacityDelta(manager, dto.warehouseId, dto.yardId, dto.zoneId, weight, volume, containerCount, +1);
|
await this.applyCapacityDelta(manager, dto, weight, volume, containerCount);
|
||||||
|
|
||||||
await this.activityLog.record(
|
await this.activityLog.record(
|
||||||
{
|
{
|
||||||
@@ -405,7 +504,7 @@ export class WarehouseInventoryService {
|
|||||||
return this.findById(id);
|
return this.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async move(id: string, dto: MoveWarehouseInventoryDto): Promise<WarehouseInventory> {
|
async move(id: string, dto: MoveInventoryDto): Promise<WarehouseInventory> {
|
||||||
const movedId = await this.dataSource.transaction(async (manager) => {
|
const movedId = await this.dataSource.transaction(async (manager) => {
|
||||||
const item = await manager.getRepository(WarehouseInventory).findOne({
|
const item = await manager.getRepository(WarehouseInventory).findOne({
|
||||||
where: { id },
|
where: { id },
|
||||||
@@ -428,12 +527,12 @@ export class WarehouseInventoryService {
|
|||||||
const containerCount = item.containerId ? Math.round(Number(item.quantity) || 0) : 0;
|
const containerCount = item.containerId ? Math.round(Number(item.quantity) || 0) : 0;
|
||||||
|
|
||||||
if (item.warehouseId !== dto.warehouseId) {
|
if (item.warehouseId !== dto.warehouseId) {
|
||||||
this.assertCapacity('Warehouse', warehouse, weight, containerCount);
|
this.assertCapacity('Warehouse', warehouse, weight, Number(item.volume) || 0, containerCount);
|
||||||
}
|
}
|
||||||
if (item.yardId !== dto.yardId) {
|
if (item.yardId !== dto.yardId) {
|
||||||
this.assertCapacity('Yard', yard, weight, containerCount);
|
this.assertCapacity('Yard', yard, weight, Number(item.volume) || 0, containerCount);
|
||||||
}
|
}
|
||||||
this.assertCapacity('Zone', zone, weight, containerCount);
|
this.assertCapacity('Zone', zone, weight, Number(item.volume) || 0, containerCount);
|
||||||
|
|
||||||
await this.applyCapacityDelta(
|
await this.applyCapacityDelta(
|
||||||
manager,
|
manager,
|
||||||
@@ -443,10 +542,11 @@ export class WarehouseInventoryService {
|
|||||||
zoneId: item.zoneId,
|
zoneId: item.zoneId,
|
||||||
},
|
},
|
||||||
-weight,
|
-weight,
|
||||||
|
-(Number(item.volume) || 0),
|
||||||
-containerCount,
|
-containerCount,
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.applyCapacityDelta(manager, dto, weight, containerCount);
|
await this.applyCapacityDelta(manager, dto, weight, Number(item.volume) || 0, containerCount);
|
||||||
|
|
||||||
item.warehouseId = dto.warehouseId;
|
item.warehouseId = dto.warehouseId;
|
||||||
item.yardId = dto.yardId;
|
item.yardId = dto.yardId;
|
||||||
@@ -597,34 +697,6 @@ export class WarehouseInventoryService {
|
|||||||
return this.findById(id);
|
return this.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async store(id: string): Promise<WarehouseInventory> {
|
|
||||||
const item = await this.findById(id);
|
|
||||||
|
|
||||||
if (item.status !== 'RECEIVED' && item.status !== 'ARRIVED_AT_WAREHOUSE') {
|
|
||||||
throw new BadRequestException(`Only RECEIVED inventory can be stored (current: ${item.status})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.inventoryRepository.update(id, { status: 'STORED' });
|
|
||||||
return this.findById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
async reserve(id: string, dto: { bookingId?: string }): Promise<WarehouseInventory> {
|
|
||||||
const item = await this.findById(id);
|
|
||||||
|
|
||||||
if (item.status !== 'STORED') {
|
|
||||||
throw new BadRequestException('Only STORED inventory can be reserved.');
|
|
||||||
}
|
|
||||||
|
|
||||||
const bookingId = dto.bookingId ?? item.bookingId;
|
|
||||||
await this.assertPaidBooking(this.dataSource.manager, bookingId);
|
|
||||||
|
|
||||||
await this.inventoryRepository.update(id, {
|
|
||||||
bookingId,
|
|
||||||
status: 'RESERVED',
|
|
||||||
});
|
|
||||||
return this.findById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Loading records (Batch 3) ─────────────────────────────────────────────
|
// ── Loading records (Batch 3) ─────────────────────────────────────────────
|
||||||
|
|
||||||
async findLoadings(
|
async findLoadings(
|
||||||
@@ -663,44 +735,13 @@ export class WarehouseInventoryService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async dispatch(id: string, performedBy?: string): Promise<WarehouseInventory> {
|
dispatch(id: string, performedBy?: string): Promise<WarehouseInventory> {
|
||||||
const item = await this.findById(id);
|
return this.transition(id, 'DISPATCHED', {
|
||||||
|
timestampField: 'dispatchedAt',
|
||||||
if (item.status !== 'UNDER_INSPECTION') {
|
activityType: 'INVENTORY_DISPATCHED',
|
||||||
throw new BadRequestException(
|
description: 'Inventory dispatched',
|
||||||
`Only items in UNDER_INSPECTION can be marked READY_FOR_LOADING (current: ${item.status})`,
|
performedBy,
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.inventoryRepository.update(id, {
|
|
||||||
status: 'READY_FOR_LOADING',
|
|
||||||
readyForLoadingAt: new Date(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.findById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
async load(id: string): Promise<WarehouseInventory> {
|
|
||||||
const item = await this.findById(id);
|
|
||||||
|
|
||||||
if (item.status !== 'READY_FOR_LOADING') {
|
|
||||||
throw new BadRequestException(`Only READY_FOR_LOADING inventory can be loaded (current: ${item.status})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.assertPaidBooking(this.dataSource.manager, item.bookingId);
|
|
||||||
await this.inventoryRepository.update(id, { status: 'LOADED' });
|
|
||||||
return this.findById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
async dispatch(id: string): Promise<WarehouseInventory> {
|
|
||||||
const item = await this.findById(id);
|
|
||||||
|
|
||||||
if (item.status !== 'LOADED') {
|
|
||||||
throw new BadRequestException(`Only LOADED inventory can be dispatched (current: ${item.status})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.inventoryRepository.update(id, { status: 'DISPATCHED' });
|
|
||||||
return this.findById(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async dashboardSummary(filter: FilterWarehouseInventoryDto): Promise<WarehouseDashboardSummary> {
|
async dashboardSummary(filter: FilterWarehouseInventoryDto): Promise<WarehouseDashboardSummary> {
|
||||||
@@ -858,7 +899,7 @@ export class WarehouseInventoryService {
|
|||||||
|
|
||||||
private async validateLocation(
|
private async validateLocation(
|
||||||
manager: EntityManager,
|
manager: EntityManager,
|
||||||
dto: ReceiveWarehouseInventoryDto,
|
dto: LocationRef,
|
||||||
): Promise<{ warehouse: Warehouse; yard: WarehouseYard; zone: WarehouseZone }> {
|
): Promise<{ warehouse: Warehouse; yard: WarehouseYard; zone: WarehouseZone }> {
|
||||||
const warehouse = await manager.getRepository(Warehouse).findOne({ where: { id: dto.warehouseId } });
|
const warehouse = await manager.getRepository(Warehouse).findOne({ where: { id: dto.warehouseId } });
|
||||||
if (!warehouse) throw new NotFoundException(`Warehouse ${dto.warehouseId} not found`);
|
if (!warehouse) throw new NotFoundException(`Warehouse ${dto.warehouseId} not found`);
|
||||||
@@ -879,6 +920,38 @@ export class WarehouseInventoryService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async getBookingStatus(bookingId: string): Promise<string | null> {
|
||||||
|
const [row]: Array<{ status: string | null }> = await this.dataSource.query(
|
||||||
|
'SELECT status FROM freight.bookings WHERE id = $1 AND deleted_at IS NULL LIMIT 1',
|
||||||
|
[bookingId],
|
||||||
|
);
|
||||||
|
return row?.status ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async attachBookingSummaries(items: WarehouseInventory[]): Promise<void> {
|
||||||
|
const bookingIds = [...new Set(items.map((item) => item.bookingId).filter(Boolean))] as string[];
|
||||||
|
if (bookingIds.length === 0) return;
|
||||||
|
|
||||||
|
const rows: BookingSummaryRow[] = await this.dataSource.query(
|
||||||
|
`SELECT b.id, b.reference, b.status, company.name AS customer
|
||||||
|
FROM freight.bookings b
|
||||||
|
LEFT JOIN freight.companies company ON company.id = b.company_id
|
||||||
|
WHERE b.id = ANY($1) AND b.deleted_at IS NULL`,
|
||||||
|
[bookingIds],
|
||||||
|
);
|
||||||
|
const summaries = new Map(rows.map((row) => [row.id, row]));
|
||||||
|
|
||||||
|
items.forEach((item) => {
|
||||||
|
const summary = item.bookingId ? summaries.get(item.bookingId) : undefined;
|
||||||
|
if (!summary) return;
|
||||||
|
Object.assign(item, {
|
||||||
|
bookingReference: summary.reference,
|
||||||
|
bookingStatus: summary.status,
|
||||||
|
customerName: summary.customer,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private assertCapacity(
|
private assertCapacity(
|
||||||
label: string,
|
label: string,
|
||||||
node: LocationNode,
|
node: LocationNode,
|
||||||
@@ -909,21 +982,24 @@ export class WarehouseInventoryService {
|
|||||||
|
|
||||||
private async applyCapacityDelta(
|
private async applyCapacityDelta(
|
||||||
manager: EntityManager,
|
manager: EntityManager,
|
||||||
dto: ReceiveWarehouseInventoryDto,
|
location: LocationRef,
|
||||||
weightAdd: number,
|
weightAdd: number,
|
||||||
|
volumeAdd: number,
|
||||||
containerAdd: number,
|
containerAdd: number,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const apply = sign === 1 ? manager.increment.bind(manager) : manager.decrement.bind(manager);
|
|
||||||
const targets: Array<[typeof Warehouse | typeof WarehouseYard | typeof WarehouseZone, string]> = [
|
const targets: Array<[typeof Warehouse | typeof WarehouseYard | typeof WarehouseZone, string]> = [
|
||||||
[Warehouse, warehouseId],
|
[Warehouse, location.warehouseId],
|
||||||
[WarehouseYard, yardId],
|
[WarehouseYard, location.yardId],
|
||||||
[WarehouseZone, zoneId],
|
[WarehouseZone, location.zoneId],
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const [entity, id] of targets) {
|
for (const [entity, id] of targets) {
|
||||||
if (weight) await apply(entity, { id }, 'currentWeight', weight);
|
if (weightAdd > 0) await manager.increment(entity, { id }, 'currentWeight', weightAdd);
|
||||||
if (volume) await apply(entity, { id }, 'currentVolume', volume);
|
if (weightAdd < 0) await manager.decrement(entity, { id }, 'currentWeight', Math.abs(weightAdd));
|
||||||
if (containers) await apply(entity, { id }, 'currentContainers', containers);
|
if (volumeAdd > 0) await manager.increment(entity, { id }, 'currentVolume', volumeAdd);
|
||||||
|
if (volumeAdd < 0) await manager.decrement(entity, { id }, 'currentVolume', Math.abs(volumeAdd));
|
||||||
|
if (containerAdd > 0) await manager.increment(entity, { id }, 'currentContainers', containerAdd);
|
||||||
|
if (containerAdd < 0) await manager.decrement(entity, { id }, 'currentContainers', Math.abs(containerAdd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user