chore: add some

This commit is contained in:
mahyargdz
2025-02-12 10:23:36 +03:30
parent 49c62018f0
commit 22198f3240
9 changed files with 105 additions and 22 deletions
+1
View File
@@ -313,6 +313,7 @@ export const enum InvoiceMessage {
USER_ID_SHOULD_BE_A_UUID = "شناسه کاربر باید یک UUID معتبر باشد",
CREATED = "فاکتور با موفقیت ایجاد شد",
SEARCH_QUERY_MUST_BE_A_STRING = "رشته جستجو باید یک رشته باشد",
NOT_FOUND_BY_ID = "فاکتوری با این شناسه یافت نشد",
}
export const enum LearningMessage {
+14 -5
View File
@@ -1,13 +1,22 @@
// eslint-disable-next-line import/no-named-as-default
import Decimal from "decimal.js";
import { ValueTransformer } from "typeorm";
export class DecimalTransformer {
to(value: Decimal | string | number): string {
return new Decimal(value).toString();
export class DecimalTransformer implements ValueTransformer {
// to(value: Decimal | string | number): string {
// return new Decimal(value).toString();
// }
// from(value: string): number {
// return new Decimal(value).toNumber();
// }
to(value: Decimal | null): string | null {
return value ? value.toString() : "0"; // Ensure it's always a valid number
}
from(value: string): number {
return new Decimal(value).toNumber();
from(value: string | null): number {
return value ? new Decimal(value).toNumber() : new Decimal(0).toNumber(); // Default to 0 if null
}
}