generated from bastian/boilerplate
guide
This commit is contained in:
@@ -1120,8 +1120,8 @@ export class FurnitureService {
|
||||
}
|
||||
private optionValues(dto: CreateFurnitureOptionDto) {
|
||||
const text = (value?: string) => value?.trim() || null;
|
||||
const decimal = (value?: number) =>
|
||||
value === undefined ? null : value.toFixed(2);
|
||||
const decimal = (value?: number | null) =>
|
||||
value === undefined || value === null ? null : value.toFixed(2);
|
||||
return {
|
||||
name: dto.name?.trim() || 'Unbenannter Möbelvorschlag',
|
||||
manufacturer: text(dto.manufacturer),
|
||||
@@ -1130,13 +1130,13 @@ export class FurnitureService {
|
||||
retailer: text(dto.retailer),
|
||||
productUrl: text(dto.productUrl),
|
||||
articleNumber: text(dto.articleNumber),
|
||||
unitPrice: dto.unitPrice.toFixed(2),
|
||||
unitPrice: (dto.unitPrice ?? 0).toFixed(2),
|
||||
originalPrice: decimal(dto.originalPrice),
|
||||
shippingCost: dto.shippingCost.toFixed(2),
|
||||
additionalCost: dto.additionalCost.toFixed(2),
|
||||
discount: dto.discount.toFixed(2),
|
||||
shippingCost: (dto.shippingCost ?? 0).toFixed(2),
|
||||
additionalCost: (dto.additionalCost ?? 0).toFixed(2),
|
||||
discount: (dto.discount ?? 0).toFixed(2),
|
||||
currency: dto.currency.toUpperCase(),
|
||||
quantity: dto.quantity,
|
||||
quantity: dto.quantity ?? 1,
|
||||
width: decimal(dto.width),
|
||||
height: decimal(dto.height),
|
||||
depth: decimal(dto.depth),
|
||||
@@ -1154,15 +1154,19 @@ export class FurnitureService {
|
||||
budgetCategoryId: dto.budgetCategoryId ?? null,
|
||||
existingItem: dto.existingItem,
|
||||
estimatedCurrentValue: decimal(dto.estimatedCurrentValue),
|
||||
movingCost: dto.movingCost.toFixed(2),
|
||||
refurbishmentCost: dto.refurbishmentCost.toFixed(2),
|
||||
movingCost: (dto.movingCost ?? 0).toFixed(2),
|
||||
refurbishmentCost: (dto.refurbishmentCost ?? 0).toFixed(2),
|
||||
currentLocation: text(dto.currentLocation),
|
||||
condition: dto.condition ?? null,
|
||||
};
|
||||
}
|
||||
private total(dto: CreateFurnitureOptionDto) {
|
||||
try {
|
||||
return calculateFurnitureTotal(dto);
|
||||
return calculateFurnitureTotal({
|
||||
...dto,
|
||||
unitPrice: dto.unitPrice ?? 0,
|
||||
quantity: dto.quantity ?? 1,
|
||||
});
|
||||
} catch {
|
||||
this.validation(
|
||||
'Der Rabatt darf die berechneten Gesamtkosten nicht überschreiten.',
|
||||
|
||||
Reference in New Issue
Block a user