Spaces:
Sleeping

Muhasebe / frontend /src /lib /format.js
Caner Giden
Cursor
Talaş modulune firma bazli aylik finans ozeti dashboard ekle.
2b3e7de
Raw History Blame Contribute Delete
1.05 kB
/** Para birimi ve tarih string yardımcıları. */
export function money(value) {
return `${Number(value || 0).toFixed(2)} TL`;
}
/** Sipariş listesinde kesinti hücreleri: tutar hep gider gibi (-) ile. */
export function moneyDeduction(value) {
const n = Number(value ?? 0);
if (!Number.isFinite(n) || n === 0) return `${(0).toFixed(2)} TL`;
return `${(-Math.abs(n)).toFixed(2)} TL`;
}
export function currentDateValue() {
return new Date().toISOString().slice(0, 10);
}
export function currentMonthValue() {
return new Date().toISOString().slice(0, 7);
}
const TR_MONTH_NAMES = [
"Ocak",
"Subat",
"Mart",
"Nisan",
"Mayis",
"Haziran",
"Temmuz",
"Agustos",
"Eylul",
"Ekim",
"Kasim",
"Aralik",
];
/** YYYY-MM → "Eylul 2026" */
export function formatMonthLabel(monthValue) {
if (!monthValue || typeof monthValue !== "string") return "";
const [y, m] = monthValue.split("-");
const idx = Number(m) - 1;
if (!y || idx < 0 || idx > 11) return monthValue;
return `${TR_MONTH_NAMES[idx]} ${y}`;
}