Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit b4576926 authored by 65160206's avatar 65160206
Browse files

production target get by date machine delete and update

parent ed4444b8
No related branches found
No related tags found
No related merge requests found
Showing
with 175 additions and 62 deletions
......@@ -6,7 +6,9 @@ export declare class MachinesController {
constructor(machinesService: MachinesService);
create(createMachineDto: CreateMachineDto): string;
findAll(): Promise<import("./entities/machine.entity").Machine[]>;
findOne(id: string): string;
update(id: string, updateMachineDto: UpdateMachineDto): string;
remove(id: string): string;
findOne(id: string): Promise<import("./entities/machine.entity").Machine>;
update(id: string, updateMachineDto: UpdateMachineDto): Promise<import("./entities/machine.entity").Machine>;
remove(id: string): Promise<{
message: string;
}>;
}
......@@ -7,7 +7,9 @@ export declare class MachinesService {
constructor(machineRepository: Repository<Machine>);
create(createMachineDto: CreateMachineDto): string;
findAll(): Promise<Machine[]>;
findOne(id: number): string;
update(id: number, updateMachineDto: UpdateMachineDto): string;
remove(id: number): string;
findOne(id: number): Promise<Machine>;
update(id: number, updateMachineDto: UpdateMachineDto): Promise<Machine>;
remove(id: number): Promise<{
message: string;
}>;
}
......@@ -34,14 +34,24 @@ let MachinesService = class MachinesService {
],
});
}
findOne(id) {
return `This action returns a #${id} machine`;
async findOne(id) {
const machine = await this.machineRepository.findOne({
where: { MachineID: id },
});
if (!machine) {
throw new common_1.NotFoundException(`Machine with ID ${id} not found`);
}
return machine;
}
update(id, updateMachineDto) {
return `This action updates a #${id} machine`;
async update(id, updateMachineDto) {
const machine = await this.findOne(id);
Object.assign(machine, updateMachineDto);
return this.machineRepository.save(machine);
}
remove(id) {
return `This action removes a #${id} machine`;
async remove(id) {
const machine = await this.findOne(id);
await this.machineRepository.remove(machine);
return { message: `Machine with ID ${id} has been removed` };
}
};
exports.MachinesService = MachinesService;
......
{"version":3,"file":"machines.service.js","sourceRoot":"","sources":["../../src/machines/machines.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAG5C,6CAAmD;AACnD,qCAAqC;AACrC,8DAAoD;AAG7C,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAEmB,iBAAsC;QAAtC,sBAAiB,GAAjB,iBAAiB,CAAqB;IACtD,CAAC;IAEJ,MAAM,CAAC,gBAAkC;QACvC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,OAAO;QACX,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;YACvC,SAAS,EAAE;gBACT,gBAAgB;gBAChB,wBAAwB;gBACxB,oCAAoC;gBACpC,6CAA6C;aAC9C;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,EAAU;QAChB,OAAO,0BAA0B,EAAE,UAAU,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,EAAU,EAAE,gBAAkC;QACnD,OAAO,0BAA0B,EAAE,UAAU,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,EAAU;QACf,OAAO,0BAA0B,EAAE,UAAU,CAAC;IAChD,CAAC;CACF,CAAA;AAhCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,wBAAO,CAAC,CAAA;qCACU,oBAAU;GAHrC,eAAe,CAgC3B"}
\ No newline at end of file
{"version":3,"file":"machines.service.js","sourceRoot":"","sources":["../../src/machines/machines.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+D;AAG/D,6CAAmD;AACnD,qCAAqC;AACrC,8DAAoD;AAG7C,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAEmB,iBAAsC;QAAtC,sBAAiB,GAAjB,iBAAiB,CAAqB;IACtD,CAAC;IAEJ,MAAM,CAAC,gBAAkC;QACvC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,OAAO;QACX,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;YACvC,SAAS,EAAE;gBACT,gBAAgB;gBAChB,wBAAwB;gBACxB,oCAAoC;gBACpC,6CAA6C;aAC9C;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;YACnD,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;SACzB,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,0BAAiB,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAGD,KAAK,CAAC,MAAM,CACV,EAAU,EACV,gBAAkC;QAElC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAGD,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACvC,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,CAAC;IAC/D,CAAC;CACF,CAAA;AA/CY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,wBAAO,CAAC,CAAA;qCACU,oBAAU;GAHrC,eAAe,CA+C3B"}
\ No newline at end of file
export declare class CreateProductionTargetDto {
itemID: number;
OrderID?: number | null;
itemID: string;
itemType: 'PRODUCT' | 'MATERIAL';
OrderID?: number;
TargetProduced: number;
ActualProduced?: number;
Status?: string;
Date?: Date;
ActualProduced: number;
Status: string;
Date: string;
}
export declare class CreateManyProductionTargetsDto {
productionTargets: CreateProductionTargetDto[];
}
......@@ -9,21 +9,19 @@ var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateProductionTargetDto = void 0;
exports.CreateManyProductionTargetsDto = exports.CreateProductionTargetDto = void 0;
const class_validator_1 = require("class-validator");
class CreateProductionTargetDto {
constructor() {
this.OrderID = -1;
this.ActualProduced = 0;
this.Status = 'Pending';
this.Date = new Date();
}
}
exports.CreateProductionTargetDto = CreateProductionTargetDto;
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsInt)(),
(0, class_validator_1.Min)(1),
__metadata("design:type", Number)
], CreateProductionTargetDto.prototype, "OrderID", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateProductionTargetDto.prototype, "itemID", void 0);
__decorate([
(0, class_validator_1.IsEnum)(['PRODUCT', 'MATERIAL']),
......@@ -31,27 +29,23 @@ __decorate([
], CreateProductionTargetDto.prototype, "itemType", void 0);
__decorate([
(0, class_validator_1.IsInt)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], CreateProductionTargetDto.prototype, "OrderID", void 0);
__decorate([
(0, class_validator_1.IsInt)(),
(0, class_validator_1.Min)(1),
(0, class_validator_1.Min)(0),
__metadata("design:type", Number)
], CreateProductionTargetDto.prototype, "TargetProduced", void 0);
__decorate([
(0, class_validator_1.IsInt)(),
(0, class_validator_1.Min)(0),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], CreateProductionTargetDto.prototype, "ActualProduced", void 0);
__decorate([
(0, class_validator_1.IsString)(),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], CreateProductionTargetDto.prototype, "Status", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Date)
(0, class_validator_1.IsDateString)(),
__metadata("design:type", String)
], CreateProductionTargetDto.prototype, "Date", void 0);
class CreateManyProductionTargetsDto {
}
exports.CreateManyProductionTargetsDto = CreateManyProductionTargetsDto;
//# sourceMappingURL=create-production_target.dto.js.map
\ No newline at end of file
{"version":3,"file":"create-production_target.dto.js","sourceRoot":"","sources":["../../../src/production_targets/dto/create-production_target.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA2E;AAE3E,MAAa,yBAAyB;IAAtC;QAUE,YAAO,GAAY,CAAC,CAAC,CAAC;QAStB,mBAAc,GAAY,CAAC,CAAC;QAI5B,WAAM,GAAY,SAAS,CAAC;QAG5B,SAAI,GAAU,IAAI,IAAI,EAAE,CAAC;IAC3B,CAAC;CAAA;AA3BD,8DA2BC;AAxBC;IAFC,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;;yDACQ;AAGf;IADC,IAAA,wBAAM,EAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;;2DACC;AAIjC;IAFC,IAAA,uBAAK,GAAE;IACP,IAAA,4BAAU,GAAE;;0DACS;AAItB;IAFC,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;;iEACgB;AAKvB;IAHC,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,4BAAU,GAAE;;iEACe;AAI5B;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;yDACe;AAG5B;IADC,IAAA,4BAAU,GAAE;8BACN,IAAI;uDAAc"}
\ No newline at end of file
{"version":3,"file":"create-production_target.dto.js","sourceRoot":"","sources":["../../../src/production_targets/dto/create-production_target.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAOyB;AAEzB,MAAa,yBAAyB;CAwBrC;AAxBD,8DAwBC;AArBC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;;0DACgB;AAGxB;IADC,IAAA,0BAAQ,GAAE;;yDACI;AAGf;IADC,IAAA,wBAAM,EAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;;2DACC;AAIjC;IAFC,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;;iEACgB;AAIvB;IAFC,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;;iEACgB;AAGvB;IADC,IAAA,0BAAQ,GAAE;;yDACI;AAGf;IADC,IAAA,8BAAY,GAAE;;uDACF;AAGf,MAAa,8BAA8B;CAE1C;AAFD,wEAEC"}
\ No newline at end of file
import { ProductionTargetsService } from './production_targets.service';
import { CreateProductionTargetDto } from './dto/create-production_target.dto';
import { CreateManyProductionTargetsDto } from './dto/create-production_target.dto';
import { UpdateProductionTargetDto } from './dto/update-production_target.dto';
import { ProductionTarget } from './entities/production_target.entity';
export declare class ProductionTargetsController {
private readonly productionTargetsService;
constructor(productionTargetsService: ProductionTargetsService);
create(createProductionTargetDto: CreateProductionTargetDto): Promise<import("./entities/production_target.entity").ProductionTarget>;
findAll(): Promise<import("./entities/production_target.entity").ProductionTarget[]>;
findOne(id: string): Promise<import("./entities/production_target.entity").ProductionTarget>;
update(id: string, updateProductionTargetDto: UpdateProductionTargetDto): Promise<import("./entities/production_target.entity").ProductionTarget>;
remove(id: string): Promise<void>;
create(createProductionTargetDto: CreateProductionTargetDto): Promise<ProductionTarget>;
createMany(createManyDto: CreateManyProductionTargetsDto): Promise<ProductionTarget[]>;
getByDate(date: string): Promise<ProductionTarget[]>;
findAll(): Promise<ProductionTarget[]>;
findOne(id: string): Promise<ProductionTarget>;
update(id: string, updateProductionTargetDto: UpdateProductionTargetDto): Promise<ProductionTarget>;
remove(id: string): Promise<ProductionTarget>;
}
......@@ -16,6 +16,7 @@ exports.ProductionTargetsController = void 0;
const common_1 = require("@nestjs/common");
const production_targets_service_1 = require("./production_targets.service");
const create_production_target_dto_1 = require("./dto/create-production_target.dto");
const create_production_target_dto_2 = require("./dto/create-production_target.dto");
const update_production_target_dto_1 = require("./dto/update-production_target.dto");
let ProductionTargetsController = class ProductionTargetsController {
constructor(productionTargetsService) {
......@@ -24,6 +25,15 @@ let ProductionTargetsController = class ProductionTargetsController {
create(createProductionTargetDto) {
return this.productionTargetsService.create(createProductionTargetDto);
}
async createMany(createManyDto) {
return this.productionTargetsService.createMany(createManyDto);
}
async getByDate(date) {
if (!date) {
throw new common_1.BadRequestException('Date parameter is required');
}
return this.productionTargetsService.findByDate(date);
}
findAll() {
return this.productionTargetsService.findAll();
}
......@@ -45,6 +55,20 @@ __decorate([
__metadata("design:paramtypes", [create_production_target_dto_1.CreateProductionTargetDto]),
__metadata("design:returntype", void 0)
], ProductionTargetsController.prototype, "create", null);
__decorate([
(0, common_1.Post)('bulk'),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [create_production_target_dto_2.CreateManyProductionTargetsDto]),
__metadata("design:returntype", Promise)
], ProductionTargetsController.prototype, "createMany", null);
__decorate([
(0, common_1.Get)('by-date'),
__param(0, (0, common_1.Query)('date')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], ProductionTargetsController.prototype, "getByDate", null);
__decorate([
(0, common_1.Get)(),
__metadata("design:type", Function),
......
{"version":3,"file":"production_targets.controller.js","sourceRoot":"","sources":["../../src/production_targets/production_targets.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,6EAAwE;AACxE,qFAA+E;AAC/E,qFAA+E;AAGxE,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IACtC,YACmB,wBAAkD;QAAlD,6BAAwB,GAAxB,wBAAwB,CAA0B;IAClE,CAAC;IAGJ,MAAM,CAAS,yBAAoD;QACjE,OAAO,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;IACzE,CAAC;IAGD,OAAO;QACL,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,CAAC;IACjD,CAAC;IAGD,OAAO,CAAc,EAAU;QAC7B,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;IAGD,MAAM,CACS,EAAU,EACf,yBAAoD;QAE5D,OAAO,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,yBAAyB,CAAC,CAAC;IAC9E,CAAC;IAGD,MAAM,CAAc,EAAU;QAC5B,OAAO,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AAhCY,kEAA2B;AAMtC;IADC,IAAA,aAAI,GAAE;IACC,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAA4B,wDAAyB;;yDAElE;AAGD;IADC,IAAA,YAAG,GAAE;;;;0DAGL;AAGD;IADC,IAAA,YAAG,EAAC,KAAK,CAAC;IACF,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;0DAEnB;AAGD;IADC,IAAA,cAAK,EAAC,KAAK,CAAC;IAEV,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAA4B,wDAAyB;;yDAG7D;AAGD;IADC,IAAA,eAAM,EAAC,KAAK,CAAC;IACN,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;yDAElB;sCA/BU,2BAA2B;IADvC,IAAA,mBAAU,EAAC,oBAAoB,CAAC;qCAGc,qDAAwB;GAF1D,2BAA2B,CAgCvC"}
\ No newline at end of file
{"version":3,"file":"production_targets.controller.js","sourceRoot":"","sources":["../../src/production_targets/production_targets.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAUwB;AACxB,6EAAwE;AACxE,qFAA+E;AAC/E,qFAAoF;AACpF,qFAA+E;AAIxE,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IACtC,YACmB,wBAAkD;QAAlD,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AC,MAAM,CAAC,CAAA;;;;4DAO7B;AAGD;IADC,IAAA,YAAG,GAAE;;;;0DAGL;AAGD;IADC,IAAA,YAAG,EAAC,KAAK,CAAC;IACF,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;0DAEnB;AAGD;IADC,IAAA,cAAK,EAAC,KAAK,CAAC;IAEV,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAA4B,wDAAyB;;yDAG7D;AAGD;IADC,IAAA,eAAM,EAAC,KAAK,CAAC;IACN,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;yDAElB;sCA9CU,2BAA2B;IADvC,IAAA,mBAAU,EAAC,oBAAoB,CAAC;qCAGc,qDAAwB;GAF1D,2BAA2B,CA+CvC"}
\ No newline at end of file
......@@ -3,7 +3,7 @@ import { ProductionTarget } from './entities/production_target.entity';
import { Order } from '../orders/entities/order.entity';
import { Product } from '../products/entities/product.entity';
import { Material } from '../materials/entities/material.entity';
import { CreateProductionTargetDto } from './dto/create-production_target.dto';
import { CreateProductionTargetDto, CreateManyProductionTargetsDto } from './dto/create-production_target.dto';
import { UpdateProductionTargetDto } from './dto/update-production_target.dto';
export declare class ProductionTargetsService {
private readonly productionTargetRepository;
......@@ -12,8 +12,10 @@ export declare class ProductionTargetsService {
private readonly materialRepository;
constructor(productionTargetRepository: Repository<ProductionTarget>, orderRepository: Repository<Order>, productRepository: Repository<Product>, materialRepository: Repository<Material>);
create(createProductionTargetDto: CreateProductionTargetDto): Promise<ProductionTarget>;
createMany(createManyDto: CreateManyProductionTargetsDto): Promise<ProductionTarget[]>;
findAll(): Promise<ProductionTarget[]>;
findOne(id: number): Promise<ProductionTarget>;
findByDate(dateStr: string): Promise<ProductionTarget[]>;
update(id: number, updateProductionTargetDto: UpdateProductionTargetDto): Promise<ProductionTarget>;
remove(id: number): Promise<void>;
remove(id: number): Promise<ProductionTarget>;
}
......@@ -29,8 +29,12 @@ let ProductionTargetsService = class ProductionTargetsService {
}
async create(createProductionTargetDto) {
const { OrderID, itemID, itemType, ...targetData } = createProductionTargetDto;
const itemIDNumber = parseInt(itemID, 10);
if (isNaN(itemIDNumber)) {
throw new common_1.NotFoundException(`Invalid itemID: ${itemID}`);
}
let order = null;
if (OrderID && OrderID !== -1) {
if (OrderID !== undefined && OrderID !== null && OrderID !== -1) {
order = await this.orderRepository.findOne({
where: { OrderID },
});
......@@ -41,12 +45,12 @@ let ProductionTargetsService = class ProductionTargetsService {
let itemExists = false;
if (itemType === 'PRODUCT') {
itemExists = await this.productRepository.exist({
where: { ProductID: itemID },
where: { ProductID: itemIDNumber },
});
}
else if (itemType === 'MATERIAL') {
itemExists = await this.materialRepository.exist({
where: { MaterialID: itemID },
where: { MaterialID: itemIDNumber },
});
}
else {
......@@ -58,15 +62,21 @@ let ProductionTargetsService = class ProductionTargetsService {
const newTarget = this.productionTargetRepository.create({
...targetData,
order,
itemID,
itemID: itemIDNumber,
itemType,
});
return this.productionTargetRepository.save(newTarget);
}
async createMany(createManyDto) {
const validTargets = [];
for (const targetDto of createManyDto.productionTargets) {
const newTarget = await this.create(targetDto);
validTargets.push(newTarget);
}
return validTargets;
}
async findAll() {
return this.productionTargetRepository.find({
relations: ['order'],
});
return this.productionTargetRepository.find({ relations: ['order'] });
}
async findOne(id) {
const target = await this.productionTargetRepository.findOne({
......@@ -78,6 +88,21 @@ let ProductionTargetsService = class ProductionTargetsService {
}
return target;
}
async findByDate(dateStr) {
if (!dateStr)
throw new common_1.BadRequestException('Date is required');
const dateParts = dateStr.trim().split('/');
if (dateParts.length !== 3 ||
dateParts.some((part) => isNaN(Number(part)))) {
throw new common_1.BadRequestException('Invalid date format. Expected "dd/mm/yyyy"');
}
const [day, month, year] = dateParts.map(Number);
const startOfDay = new Date(year, month - 1, day, 0, 0, 0);
const endOfDay = new Date(year, month - 1, day, 23, 59, 59);
return this.productionTargetRepository.find({
where: { Date: (0, typeorm_2.Between)(startOfDay, endOfDay) },
});
}
async update(id, updateProductionTargetDto) {
const { OrderID, itemID, itemType, ...updateData } = updateProductionTargetDto;
const target = await this.productionTargetRepository.findOne({
......@@ -87,7 +112,7 @@ let ProductionTargetsService = class ProductionTargetsService {
if (!target) {
throw new common_1.NotFoundException(`ProductionTarget with ID ${id} not found`);
}
if (OrderID) {
if (OrderID !== undefined && OrderID !== null) {
const order = await this.orderRepository.findOne({
where: { OrderID },
});
......@@ -97,15 +122,19 @@ let ProductionTargetsService = class ProductionTargetsService {
target.order = order;
}
if (itemID && itemType) {
const itemIDNumber = parseInt(itemID, 10);
if (isNaN(itemIDNumber)) {
throw new common_1.NotFoundException(`Invalid itemID: ${itemID}`);
}
let itemExists = false;
if (itemType === 'PRODUCT') {
itemExists = await this.productRepository.exist({
where: { ProductID: itemID },
where: { ProductID: itemIDNumber },
});
}
else if (itemType === 'MATERIAL') {
itemExists = await this.materialRepository.exist({
where: { MaterialID: itemID },
where: { MaterialID: itemIDNumber },
});
}
else {
......@@ -114,7 +143,7 @@ let ProductionTargetsService = class ProductionTargetsService {
if (!itemExists) {
throw new common_1.NotFoundException(`Item with ID ${itemID} and Type ${itemType} not found`);
}
target.itemID = itemID;
target.itemID = itemIDNumber;
target.itemType = itemType;
}
Object.assign(target, updateData);
......@@ -123,6 +152,7 @@ let ProductionTargetsService = class ProductionTargetsService {
async remove(id) {
const target = await this.findOne(id);
await this.productionTargetRepository.remove(target);
return target;
}
};
exports.ProductionTargetsService = ProductionTargetsService;
......
{"version":3,"file":"production_targets.service.js","sourceRoot":"","sources":["../../src/production_targets/production_targets.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+D;AAC/D,6CAAmD;AACnD,qCAAuD;AACvD,kFAAuE;AACvE,kEAAwD;AACxD,wEAA8D;AAC9D,2EAAiE;AAK1D,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACnC,YAEmB,0BAAwD,EAGxD,eAAkC,EAGlC,iBAAsC,EAGt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B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACtC,MAAM,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;CACF,CAAA;AAlJY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,2CAAgB,CAAC,CAAA;IAGlC,WAAA,IAAA,0BAAgB,EAAC,oBAAK,CAAC,CAAA;IAGvB,WAAA,IAAA,0BAAgB,EAAC,wBAAO,CAAC,CAAA;IAGzB,WAAA,IAAA,0BAAgB,EAAC,0BAAQ,CAAC,CAAA;qCARkB,oBAAU;QAGrB,oBAAU;QAGR,oBAAU;QAGT,oBAAU;GAZtC,wBAAwB,CAkJpC"}
\ No newline at end of file
{"version":3,"file":"production_targets.service.js","sourceRoot":"","sources":["../../src/production_targets/production_targets.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAIwB;AACxB,6CAAmD;AACnD,qCAAgE;AAChE,kFAAuE;AACvE,kEAAwD;AACxD,wEAA8D;AAC9D,2EAAiE;AAQ1D,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACnC,YAEmB,0BAAwD,EAGxD,eAAkC,EAGlC,iBAAsC,EAGtC,kBAAwC;QATxC,+BAA0B,GAA1B,0BAA0B,CAA8B;QAGxD,oBAAe,GAAf,eAAe,CAAmB;QAGlC,sBAAiB,GAAjB,iBAAiB,CAAqB;QAGtC,uBAAkB,GAAlB,kBAAkB,CAAsB;IACxD,CAAC;IAGJ,KAAK,CAAC,MAAM,CACV,yBAAoD;QAEpD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAChD,yBAAyB,CAAC;QAG5B,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,KAAK,CAAC,YAAY,CAAC,E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CAAC,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAGD,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACtC,MAAM,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AAjMY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,2CAAgB,CAAC,CAAA;IAGlC,WAAA,IAAA,0BAAgB,EAAC,oBAAK,CAAC,CAAA;IAGvB,WAAA,IAAA,0BAAgB,EAAC,wBAAO,CAAC,CAAA;IAGzB,WAAA,IAAA,0BAAgB,EAAC,0BAAQ,CAAC,CAAA;qCARkB,oBAAU;QAGrB,oBAAU;QAGR,oBAAU;QAGT,oBAAU;GAZtC,wBAAwB,CAiMpC"}
\ No newline at end of file
export declare class CreateProductDto {
brand: string;
size: string;
unit: string;
quantityInStock: number;
pricePerUnit: number;
}
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateProductDto = void 0;
const class_validator_1 = require("class-validator");
class CreateProductDto {
}
exports.CreateProductDto = CreateProductDto;
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateProductDto.prototype, "brand", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateProductDto.prototype, "size", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateProductDto.prototype, "unit", void 0);
__decorate([
(0, class_validator_1.IsNumber)(),
__metadata("design:type", Number)
], CreateProductDto.prototype, "quantityInStock", void 0);
__decorate([
(0, class_validator_1.IsNumber)({ maxDecimalPlaces: 8 }),
__metadata("design:type", Number)
], CreateProductDto.prototype, "pricePerUnit", void 0);
//# sourceMappingURL=create-product.dto.js.map
\ No newline at end of file
{"version":3,"file":"create-product.dto.js","sourceRoot":"","sources":["../../../src/products/dto/create-product.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;CAAG;AAAhC,4CAAgC"}
\ No newline at end of file
{"version":3,"file":"create-product.dto.js","sourceRoot":"","sources":["../../../src/products/dto/create-product.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAiE;AAEjE,MAAa,gBAAgB;CAe5B;AAfD,4CAeC;AAbC;IADC,IAAA,0BAAQ,GAAE;;+CACG;AAGd;IADC,IAAA,0BAAQ,GAAE;;8CACE;AAGb;IADC,IAAA,0BAAQ,GAAE;;8CACE;AAGb;IADC,IAAA,0BAAQ,GAAE;;yDACa;AAGxB;IADC,IAAA,0BAAQ,EAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,CAAC;;sDACb"}
\ No newline at end of file
......@@ -8,5 +8,5 @@ export declare class QueueTypesController {
findAll(): Promise<import("./entities/queue-type.entity").QueueType[]>;
findOne(id: string): Promise<import("./entities/queue-type.entity").QueueType>;
update(id: string, updateQueueTypeDto: UpdateQueueTypeDto): Promise<import("./entities/queue-type.entity").QueueType>;
remove(id: string): Promise<void>;
remove(id: string): Promise<import("./entities/queue-type.entity").QueueType>;
}
......@@ -9,5 +9,5 @@ export declare class QueueTypesService {
findAll(): Promise<QueueType[]>;
findOne(id: number): Promise<QueueType>;
update(id: number, updateQueueTypeDto: UpdateQueueTypeDto): Promise<QueueType>;
remove(id: number): Promise<void>;
remove(id: number): Promise<QueueType>;
}
......@@ -38,7 +38,14 @@ let QueueTypesService = class QueueTypesService {
return this.findOne(id);
}
async remove(id) {
await this.queueTypeRepository.delete(id);
const queueType = await this.queueTypeRepository.findOne({
where: { QueueTypeID: id },
});
if (!queueType) {
throw new common_1.NotFoundException(`QueueType with ID ${id} not found`);
}
await this.queueTypeRepository.remove(queueType);
return queueType;
}
};
exports.QueueTypesService = QueueTypesService;
......
{"version":3,"file":"queue-types.service.js","sourceRoot":"","sources":["../../src/queue-types/queue-types.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AACrC,oEAAyD;AAKlD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YAEmB,mBAA0C;QAA1C,wBAAmB,GAAnB,mBAAmB,CAAuB;IAC1D,CAAC;IAGJ,KAAK,CAAC,MAAM,CAAC,kBAAsC;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACzE,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3D,CAAC;IAGD,KAAK,CAAC,OAAO;QACX,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;IAC/C,CAAC;IAGD,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YAC5C,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;SAC3B,CAAC,CAAC;IACL,CAAC;IAGD,KAAK,CAAC,MAAM,CACV,EAAU,EACV,kBAAsC;QAEtC,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAGD,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF,CAAA;AArCY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,6BAAS,CAAC,CAAA;qCACU,oBAAU;GAHvC,iBAAiB,CAqC7B"}
\ No newline at end of file
{"version":3,"file":"queue-types.service.js","sourceRoot":"","sources":["../../src/queue-types/queue-types.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+D;AAC/D,6CAAmD;AACnD,qCAAqC;AACrC,oEAAyD;AAKlD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YAEmB,mBAA0C;QAA1C,wBAAmB,GAAnB,mBAAmB,CAAuB;IAC1D,CAAC;IAGJ,KAAK,CAAC,MAAM,CAAC,kBAAsC;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACzE,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3D,CAAC;IAGD,KAAK,CAAC,OAAO;QACX,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;IAC/C,CAAC;IAGD,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YAC5C,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;SAC3B,CAAC,CAAC;IACL,CAAC;IAGD,KAAK,CAAC,MAAM,CACV,EAAU,EACV,kBAAsC;QAEtC,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAGD,KAAK,CAAC,MAAM,CAAC,EAAU;QAErB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YACvD,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;SAC3B,CAAC,CAAC;QAGH,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,0BAAiB,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAC;QACnE,CAAC;QAGD,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAGjD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AAnDY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,6BAAS,CAAC,CAAA;qCACU,oBAAU;GAHvC,iBAAiB,CAmD7B"}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment