feat(backend, frontend): Hinzufügen von Funktionen zur Verwaltung von Lagerbeständen im Falukant-System
- Implementierung von Methoden zur Hinzufügung und Abfrage von Lagerbeständen im AdminController und AdminService. - Erweiterung der Routen im AdminRouter zur Unterstützung der neuen Lagerverwaltungsfunktionen. - Anpassung der Benutzeroberfläche zur Integration eines Dialogs für die Lagerhinzufügung und zur Anzeige von Lagertypen. - Aktualisierung der Übersetzungen in den Sprachdateien für die neuen Funktionen und Fehlermeldungen.
This commit is contained in:
@@ -313,6 +313,62 @@ class AdminService {
|
||||
return stock;
|
||||
}
|
||||
|
||||
async addFalukantStock(userId, branchId, stockTypeId, quantity) {
|
||||
if (!(await this.hasUserAccess(userId, 'falukantusers'))) {
|
||||
throw new Error('noaccess');
|
||||
}
|
||||
|
||||
// Prüfe ob Branch existiert
|
||||
const branch = await Branch.findByPk(branchId);
|
||||
if (!branch) {
|
||||
throw new Error('Branch not found');
|
||||
}
|
||||
|
||||
// Prüfe ob StockType existiert
|
||||
const stockType = await FalukantStockType.findByPk(stockTypeId);
|
||||
if (!stockType) {
|
||||
throw new Error('Stock type not found');
|
||||
}
|
||||
|
||||
// Prüfe ob bereits ein Stock dieses Typs für diesen Branch existiert
|
||||
const existingStock = await FalukantStock.findOne({
|
||||
where: {
|
||||
branchId: branchId,
|
||||
stockTypeId: stockTypeId
|
||||
}
|
||||
});
|
||||
|
||||
if (existingStock) {
|
||||
throw new Error('Stock of this type already exists for this branch');
|
||||
}
|
||||
|
||||
// Erstelle neuen Stock
|
||||
const newStock = await FalukantStock.create({
|
||||
branchId: branchId,
|
||||
stockTypeId: stockTypeId,
|
||||
quantity: quantity
|
||||
});
|
||||
|
||||
// Lade den neuen Stock mit allen Beziehungen
|
||||
const stockWithData = await FalukantStock.findByPk(newStock.id, {
|
||||
include: [{ model: FalukantStockType, as: 'stockType', attributes: ['labelTr'] }]
|
||||
});
|
||||
|
||||
return stockWithData;
|
||||
}
|
||||
|
||||
async getFalukantStockTypes(userId) {
|
||||
if (!(await this.hasUserAccess(userId, 'falukantusers'))) {
|
||||
throw new Error('noaccess');
|
||||
}
|
||||
|
||||
const stockTypes = await FalukantStockType.findAll({
|
||||
attributes: ['id', 'labelTr']
|
||||
});
|
||||
|
||||
return stockTypes;
|
||||
}
|
||||
|
||||
async changeFalukantUser(userId, falukantUserId, falukantData) {
|
||||
if (!(await this.hasUserAccess(userId, 'falukantusers'))) {
|
||||
throw new Error('noaccess');
|
||||
|
||||
Reference in New Issue
Block a user