fix(pricing): persist pricing_config on applyGlobalMargins and fix nullish coalescing in settings
This commit is contained in:
1 parent
0da7cf14e8
commit
2a501637cb
14 files changed
+7089
-7010
No files matched your search
@@ -1273,11 +1273,37 @@ export class AdminService {
|
||||
}
|
||||
}
|
||||
|
||||
let updatedPricing = pricingSettings;
|
||||
if (dto.scope === 'ALL' || !dto.scope) {
|
||||
updatedPricing = {
|
||||
roundingStep: globalRoundingStep,
|
||||
roundingMode: globalRoundingMode,
|
||||
defaultRetailMarginPercent: retailMargin,
|
||||
defaultWholesaleMarginPercent: wholesaleMargin,
|
||||
};
|
||||
const jsonVal = {
|
||||
roundingStep: updatedPricing.roundingStep,
|
||||
roundingMode: updatedPricing.roundingMode,
|
||||
defaultRetailMarginPercent: updatedPricing.defaultRetailMarginPercent,
|
||||
defaultWholesaleMarginPercent: updatedPricing.defaultWholesaleMarginPercent,
|
||||
};
|
||||
await this.prisma.setting.upsert({
|
||||
where: { key: 'pricing_config' },
|
||||
update: { category: 'pricing', value: jsonVal },
|
||||
create: {
|
||||
key: 'pricing_config',
|
||||
category: 'pricing',
|
||||
value: jsonVal,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `درصد سود با موفقیت بر روی ${updatedCount} محصول اعمال و قیمتها گرد شدند.`,
|
||||
updatedCount,
|
||||
totalMatched: products.length,
|
||||
data: updatedPricing,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user