From ef2eb43fbfd904b1aa35007bc56553b2e217ec34 Mon Sep 17 00:00:00 2001 From: Yoga Pratama Date: Mon, 30 Nov 2026 11:20:14 +0700 Subject: [PATCH] Update landscape sidebar logo, RMA replacement SN, auto stock deduction, and cleaner symmetrical UI --- prisma/schema.prisma | 9 +- src/app/api/devices/route.ts | 189 ++++++++- src/app/api/public/rma/route.ts | 5 +- src/app/api/sales/route.ts | 25 +- src/app/api/users/route.ts | 55 +-- src/app/finance/page.tsx | 136 +++---- src/app/inventory/page.tsx | 588 +++++++++++++++------------ src/app/purchases/page.tsx | 176 ++++---- src/app/rma/page.tsx | 7 + src/app/sales/page.tsx | 281 ++++++------- src/app/settings/page.tsx | 307 +++++--------- src/app/users/page.tsx | 308 +++++++------- src/components/SerialNumberInput.tsx | 21 +- src/components/Sidebar.tsx | 76 ++-- src/lib/permissions.ts | 10 +- 15 files changed, 1163 insertions(+), 1030 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 65736bb..3a01c14 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -459,10 +459,11 @@ model CustomerProductPrice { // PENCATATAN RIWAYAT DEVICE: PERNAH DISERVIS, RUSAK TOTAL (AFKIR), & KANIBALAN // ----------------------------------------------------------------------------- model DeviceRecord { - id String @id @default(uuid()) - recordNumber String @unique - serialNumber String - productId String + id String @id @default(uuid()) + recordNumber String @unique + serialNumber String + replacementSerialNumber String? // Serial Number (SN) unit pengganti saat Ganti Unit Garansi + productId String customerId String? salesOrderId String? salesOrderNumber String? diff --git a/src/app/api/devices/route.ts b/src/app/api/devices/route.ts index a92aabe..0913306 100644 --- a/src/app/api/devices/route.ts +++ b/src/app/api/devices/route.ts @@ -118,6 +118,8 @@ export async function POST(req: Request) { const { serialNumbers, serialNumber, + replacementSerialNumbers, + replacementSerialNumber, productId, customerId, salesOrderNumber, @@ -158,6 +160,17 @@ export async function POST(req: Request) { const finalOrigin = VALID_ORIGINS.has(serviceOrigin) ? serviceOrigin : "WAREHOUSE_DEFECT"; const finalCondition = VALID_CONDITIONS.has(condition) ? condition : "IN_SERVICE"; + const replSnList = splitSerialNumbers(replacementSerialNumbers || replacementSerialNumber || ""); + if (finalOrigin === "WARRANTY_REPLACE" && replSnList.length === 0) { + return NextResponse.json( + { + error: + "Serial Number (SN) unit baru pengganti wajib diisi untuk kategori Ganti Unit (Tukar Unit Garansi).", + }, + { status: 400 } + ); + } + // Aturan bisnis: Saat pilih Ganti Unit (WARRANTY_REPLACE), kondisi unit lama HANYA boleh Rusak Total atau Kanibalan! if ( finalOrigin === "WARRANTY_REPLACE" && @@ -196,12 +209,17 @@ export async function POST(req: Request) { ? "OUT_OF_WARRANTY" : "INTERNAL"); - // Jika diminta memotong stok fisik gudang (khusus Gudang/Admin/Manager untuk barang rusak/kanibalan internal) - const shouldDeductStock = - Boolean(deductWarehouseStock) && - !product.isService && - ["ADMIN", "MANAGER", "INVENTORY"].includes(user.role) && + // Otomatis tentukan pemotongan stok fisik gudang berdasarkan Kategori & Kondisi unit: + // 1. Ganti Unit Garansi (WARRANTY_REPLACE) -> OTOMATIS potong stok gudang untuk unit pengganti (SN baru) + // 2. Barang Gudang / Internal (WAREHOUSE_DEFECT) yang Rusak Total / Kanibalan -> OTOMATIS potong stok gudang + // 3. Service Garansi (WARRANTY_FREE), Service Berbayar (PAID_SERVICE), atau masih/selesai service -> TIDAK potong stok gudang + const isWarehouseLoss = + finalOrigin === "WAREHOUSE_DEFECT" && (finalCondition === "DAMAGED_UNUSABLE" || finalCondition === "CANNIBALIZED"); + const isWarrantyReplacement = finalOrigin === "WARRANTY_REPLACE"; + + const shouldDeductStock = !product.isService && (isWarehouseLoss || isWarrantyReplacement); + const deductQty = isWarrantyReplacement ? Math.max(1, replSnList.length) : snList.length; if (shouldDeductStock) { const defaultWh = await prisma.warehouse.findFirst(); @@ -212,12 +230,16 @@ export async function POST(req: Request) { const stockItem = await prisma.stockItem.findUnique({ where: { productId_warehouseId: { productId: product.id, warehouseId: targetWhId } }, }); - if (!stockItem || stockItem.quantity < snList.length) { + if (!stockItem || stockItem.quantity < deductQty) { return NextResponse.json( { - error: `Stok gudang untuk ${product.name} tidak mencukupi untuk dipotong (Tersedia: ${ - stockItem?.quantity || 0 - }, SN dicatat: ${snList.length}). Hilangkan centang potong stok jika barang sudah keluar/bukan dari stok aktif.`, + error: isWarrantyReplacement + ? `Stok gudang untuk unit pengganti ${product.name} tidak mencukupi (Tersedia: ${ + stockItem?.quantity || 0 + }, Dibutuhkan: ${deductQty} unit).` + : `Stok gudang untuk ${product.name} tidak mencukupi untuk dipotong otomatis (Tersedia: ${ + stockItem?.quantity || 0 + }, SN dicatat: ${deductQty} unit).`, }, { status: 400 } ); @@ -225,28 +247,39 @@ export async function POST(req: Request) { await prisma.stockItem.update({ where: { id: stockItem.id }, - data: { quantity: stockItem.quantity - snList.length }, + data: { quantity: stockItem.quantity - deductQty }, }); - const outCat = finalCondition === "CANNIBALIZED" ? "KANIBALAN" : "RUSAK_AFKIR"; + const outCat = isWarrantyReplacement + ? "GANTI_UNIT_GARANSI" + : finalCondition === "CANNIBALIZED" + ? "KANIBALAN" + : "RUSAK_AFKIR"; + const movementSns = isWarrantyReplacement ? replSnList.join(", ") : snList.join(", "); await prisma.stockMovement.create({ data: { productId: product.id, warehouseId: targetWhId, type: "OUT", outboundCategory: outCat, - quantity: snList.length, + quantity: deductQty, referenceType: "DEVICE_RECORD", referenceId: salesOrderNumber ? String(salesOrderNumber).trim() : outCat, companyName: cleanCompany, - serialNumbers: snList.join(", "), - notes: `[${ - finalCondition === "CANNIBALIZED" - ? "Unit Kanibalan / Sparepart" - : "Barang Rusak Total / Tidak Bisa Dipakai" - }] ${snList.length} ${product.unit} ${product.name}. Kerusakan: ${String( - damageDescription - ).trim()}${salvagedParts ? ` | Sparepart Kanibalan: ${String(salvagedParts).trim()}` : ""}`, + serialNumbers: movementSns, + notes: isWarrantyReplacement + ? `[Ganti Unit Garansi] Pengeluaran ${deductQty} ${product.unit} ${product.name} (SN Pengganti: ${replSnList.join( + ", " + )}) untuk mengganti SN Rusak: ${snList.join(", ")}. Kerusakan: ${String( + damageDescription + ).trim()}` + : `[${ + finalCondition === "CANNIBALIZED" + ? "Unit Kanibalan / Sparepart" + : "Barang Rusak Total / Tidak Bisa Dipakai" + }] ${deductQty} ${product.unit} ${product.name}. Kerusakan: ${String( + damageDescription + ).trim()}${salvagedParts ? ` | Sparepart Kanibalan: ${String(salvagedParts).trim()}` : ""}`, }, }); } @@ -257,6 +290,18 @@ export async function POST(req: Request) { for (let idx = 0; idx < snList.length; idx++) { const sn = snList[idx]; + const matchedReplSn = + replSnList.length === 0 + ? null + : replSnList.length === snList.length + ? replSnList[idx] + : replSnList.join(", "); + const defaultAction = + finalOrigin === "WARRANTY_REPLACE" && matchedReplSn && !String(actionTaken || "").trim() + ? `Ganti unit garansi — diganti unit baru SN: ${matchedReplSn}` + : actionTaken + ? String(actionTaken).trim() + : null; const recNo = `DEV-${dateStr}-${String(baseCount + idx + 1).padStart(4, "0")}-${Math.floor( 10 + Math.random() * 89 )}`; @@ -264,6 +309,7 @@ export async function POST(req: Request) { data: { recordNumber: recNo, serialNumber: sn, + replacementSerialNumber: matchedReplSn, productId: product.id, customerId: customerId || null, salesOrderNumber: salesOrderNumber ? String(salesOrderNumber).trim() : null, @@ -277,7 +323,7 @@ export async function POST(req: Request) { returnTrackingNumber: cleanReturnTracking, servicePaymentStatus: finalPayStatus, damageDescription: String(damageDescription).trim(), - actionTaken: actionTaken ? String(actionTaken).trim() : null, + actionTaken: defaultAction, salvagedParts: salvagedParts ? String(salvagedParts).trim() : null, stockAdjusted: shouldDeductStock, recordedBy: user.name, @@ -341,6 +387,7 @@ export async function PUT(req: Request) { actionTaken, salvagedParts, serviceOrigin, + replacementSerialNumber, serviceFee, returnShippingCost, returnCourierName, @@ -380,6 +427,21 @@ export async function PUT(req: Request) { ); } + const effectiveReplacementSn = + replacementSerialNumber !== undefined + ? String(replacementSerialNumber).trim() || null + : existing.replacementSerialNumber || null; + + if (effectiveOrigin === "WARRANTY_REPLACE" && !effectiveReplacementSn) { + return NextResponse.json( + { + error: + "Serial Number (SN) unit baru pengganti wajib dimasukkan untuk kategori Ganti Unit (Tukar Unit Garansi).", + }, + { status: 400 } + ); + } + const updateData: any = {}; if (condition && VALID_CONDITIONS.has(condition)) { updateData.condition = condition; @@ -387,6 +449,9 @@ export async function PUT(req: Request) { if (serviceOrigin && VALID_ORIGINS.has(serviceOrigin)) { updateData.serviceOrigin = serviceOrigin; } + if (replacementSerialNumber !== undefined) { + updateData.replacementSerialNumber = effectiveReplacementSn; + } if (damageDescription !== undefined) { updateData.damageDescription = String(damageDescription).trim() || existing.damageDescription; } @@ -423,6 +488,82 @@ export async function PUT(req: Request) { updateData.servicePaymentStatus = nextTotal > 0 ? "UNPAID" : "FREE"; } + // Potong stok fisik gudang otomatis jika belum pernah dipotong (stockAdjusted === false) + const effectiveCondition = updateData.condition || existing.condition; + const shouldAutoDeductOnPut = + !existing.stockAdjusted && + !existing.product.isService && + (effectiveOrigin === "WARRANTY_REPLACE" || + (effectiveOrigin === "WAREHOUSE_DEFECT" && + (effectiveCondition === "DAMAGED_UNUSABLE" || effectiveCondition === "CANNIBALIZED"))); + + if (shouldAutoDeductOnPut) { + const defaultWh = await prisma.warehouse.findFirst(); + if (!defaultWh) { + return NextResponse.json({ error: "Gudang tidak ditemukan" }, { status: 400 }); + } + const replTokens = effectiveReplacementSn ? splitSerialNumbers(effectiveReplacementSn) : []; + const deductQty = effectiveOrigin === "WARRANTY_REPLACE" ? Math.max(1, replTokens.length) : 1; + const stockItem = await prisma.stockItem.findUnique({ + where: { productId_warehouseId: { productId: existing.productId, warehouseId: defaultWh.id } }, + }); + if (!stockItem || stockItem.quantity < deductQty) { + return NextResponse.json( + { + error: + effectiveOrigin === "WARRANTY_REPLACE" + ? `Stok gudang untuk unit pengganti ${existing.product.name} tidak mencukupi (Tersedia: ${ + stockItem?.quantity || 0 + }, Dibutuhkan: ${deductQty} unit).` + : `Stok gudang untuk ${existing.product.name} tidak mencukupi untuk dipotong otomatis (Tersedia: ${ + stockItem?.quantity || 0 + }).`, + }, + { status: 400 } + ); + } + + await prisma.stockItem.update({ + where: { id: stockItem.id }, + data: { quantity: stockItem.quantity - deductQty }, + }); + + const outCat = + effectiveOrigin === "WARRANTY_REPLACE" + ? "GANTI_UNIT_GARANSI" + : effectiveCondition === "CANNIBALIZED" + ? "KANIBALAN" + : "RUSAK_AFKIR"; + + await prisma.stockMovement.create({ + data: { + productId: existing.productId, + warehouseId: defaultWh.id, + type: "OUT", + outboundCategory: outCat, + quantity: deductQty, + referenceType: "DEVICE_RECORD", + referenceId: existing.salesOrderNumber || existing.recordNumber, + companyName: existing.companyName || "", + serialNumbers: + effectiveOrigin === "WARRANTY_REPLACE" + ? replTokens.join(", ") || effectiveReplacementSn + : existing.serialNumber, + notes: + effectiveOrigin === "WARRANTY_REPLACE" + ? `[Ganti Unit Garansi] Pengeluaran ${deductQty} ${existing.product.unit} ${existing.product.name} (SN Pengganti: ${ + effectiveReplacementSn || "-" + }) untuk mengganti SN Rusak: ${existing.serialNumber} (${existing.recordNumber}).` + : `[${ + effectiveCondition === "CANNIBALIZED" + ? "Unit Kanibalan / Sparepart" + : "Barang Rusak Total / Tidak Bisa Dipakai" + }] ${deductQty} ${existing.product.unit} ${existing.product.name} (SN: ${existing.serialNumber}).`, + }, + }); + updateData.stockAdjusted = true; + } + const updated = await prisma.deviceRecord.update({ where: { id }, data: updateData, @@ -451,6 +592,9 @@ export async function PUT(req: Request) { ...(mappedSoStatus && existing.serviceOrigin !== "WARRANTY_REPLACE" ? { serviceStatus: mappedSoStatus } : {}), + ...(updated.replacementSerialNumber + ? { replacementSerialNumbers: updated.replacementSerialNumber } + : {}), returnShippingCost: updated.returnShippingCost, returnCourierName: updated.returnCourierName, returnTrackingNumber: updated.returnTrackingNumber, @@ -464,10 +608,11 @@ export async function PUT(req: Request) { userName: user.name, action: "UPDATE_DEVICE_RECORD", module: "INVENTORY", - description: `[${user.role}] Memperbarui status device ${existing.recordNumber} (SN: ${existing.serialNumber} - ${existing.product.name}) menjadi ${updated.condition}${updated.returnShippingCost > 0 ? ` | Ongkir Balik (Ditanggung User): Rp ${updated.returnShippingCost.toLocaleString("id-ID")}` : ""}`, + description: `[${user.role}] Memperbarui status device ${existing.recordNumber} (SN: ${existing.serialNumber}${updated.replacementSerialNumber ? ` → SN Pengganti: ${updated.replacementSerialNumber}` : ""} - ${existing.product.name}) menjadi ${updated.condition}${updated.returnShippingCost > 0 ? ` | Ongkir Balik (Ditanggung User): Rp ${updated.returnShippingCost.toLocaleString("id-ID")}` : ""}`, metadata: { id, serialNumber: existing.serialNumber, + replacementSerialNumber: updated.replacementSerialNumber, condition: updated.condition, returnShippingCost: updated.returnShippingCost, returnCourierName: updated.returnCourierName, diff --git a/src/app/api/public/rma/route.ts b/src/app/api/public/rma/route.ts index 4b841c5..a99d7ff 100644 --- a/src/app/api/public/rma/route.ts +++ b/src/app/api/public/rma/route.ts @@ -212,6 +212,7 @@ function serializePublicTicket(rec: any) { return { recordNumber: rec.recordNumber, serialNumber: rec.serialNumber, + replacementSerialNumber: rec.replacementSerialNumber || null, productName: rec.product?.name || "-", productSku: rec.product?.sku || "-", companyName: rec.companyName || "PT EnterpriseCore Utama", @@ -258,6 +259,7 @@ export async function GET(req: Request) { OR: [ { recordNumber: ticketParam }, { serialNumber: ticketParam }, + { replacementSerialNumber: ticketParam }, ], }, include: { product: { select: { name: true, sku: true } } }, @@ -275,7 +277,8 @@ export async function GET(req: Request) { return recent.filter( (r) => r.recordNumber.toLowerCase() === qLower || - r.serialNumber.toLowerCase() === qLower + r.serialNumber.toLowerCase() === qLower || + (r.replacementSerialNumber || "").toLowerCase() === qLower ); }; diff --git a/src/app/api/sales/route.ts b/src/app/api/sales/route.ts index fa9ce56..b607f8e 100644 --- a/src/app/api/sales/route.ts +++ b/src/app/api/sales/route.ts @@ -957,6 +957,16 @@ export async function POST(req: Request) { const cleanReplSn = replacementSerialNumbers ? String(replacementSerialNumbers).trim() : null; const cleanDamagedSn = damagedSerialNumbers ? String(damagedSerialNumbers).trim() : null; + if (!cleanReplSn) { + return NextResponse.json( + { + error: + "Serial Number (SN) unit baru pengganti wajib dimasukkan saat proses klaim garansi ganti unit.", + }, + { status: 400 } + ); + } + // Catat riwayat Mutasi Stok Keluar (OUT) const fullNotes = `[Ganti Unit Garansi] Penggantian ${replaceQty} ${item.product.unit} baru untuk SO ${item.salesOrder.orderNumber} (${item.product.name}) ${batchDeductedNotes}. Alasan: ${replacementNotes || "Klaim kerusakan garansi"}${cleanDamagedSn ? ` | SN Rusak: ${cleanDamagedSn}` : ""}${cleanReplSn ? ` | SN Unit Pengganti: ${cleanReplSn}` : ""}`; await prisma.stockMovement.create({ @@ -1005,10 +1015,17 @@ export async function POST(req: Request) { const damagedSnTokens = cleanDamagedSn ? Array.from(new Set(cleanDamagedSn.split(/[\n,;]+/).map((s) => s.trim()).filter(Boolean))) : [`RETUR-${item.salesOrder.orderNumber}-${item.product.sku}`]; + const replSnTokens = cleanReplSn + ? Array.from(new Set(cleanReplSn.split(/[\n,;]+/).map((s) => s.trim()).filter(Boolean))) + : []; const replDateStr = new Date().toISOString().slice(0, 10).replace(/-/g, ""); const replDevCount = await prisma.deviceRecord.count(); for (let idx = 0; idx < damagedSnTokens.length; idx++) { const sn = damagedSnTokens[idx]; + const matchedReplSn = + replSnTokens.length === damagedSnTokens.length + ? replSnTokens[idx] + : cleanReplSn || null; const existingRec = await prisma.deviceRecord.findFirst({ where: { serialNumber: sn, @@ -1016,11 +1033,12 @@ export async function POST(req: Request) { salesOrderId: item.salesOrderId, }, }); - const actionDesc = `Unit lama retur ganti unit garansi (Diganti unit baru${cleanReplSn ? ` SN: ${cleanReplSn}` : ""})`; + const actionDesc = `Unit lama retur ganti unit garansi (Diganti unit baru${matchedReplSn ? ` SN: ${matchedReplSn}` : ""})`; if (existingRec) { await prisma.deviceRecord.update({ where: { id: existingRec.id }, data: { + replacementSerialNumber: matchedReplSn, condition: finalDamagedCondition, serviceOrigin: "WARRANTY_REPLACE", warrantyStatus: isExpired ? "OUT_OF_WARRANTY" : "IN_WARRANTY", @@ -1032,6 +1050,7 @@ export async function POST(req: Request) { damageDescription: replacementNotes ? String(replacementNotes).trim() : "Klaim tukar unit garansi", actionTaken: actionDesc, salvagedParts: finalDamagedCondition === "CANNIBALIZED" ? cleanSalvagedParts : null, + stockAdjusted: true, recordedBy: user.name, }, }); @@ -1042,11 +1061,12 @@ export async function POST(req: Request) { 10 + Math.random() * 89 )}`, serialNumber: sn, + replacementSerialNumber: matchedReplSn, productId: item.productId, customerId: item.salesOrder.customerId, salesOrderId: item.salesOrderId, salesOrderNumber: item.salesOrder.orderNumber, - companyName: item.salesOrder.companyName || "PT EnterpriseCore Utama", + companyName: item.salesOrder.companyName || "", condition: finalDamagedCondition, serviceOrigin: "WARRANTY_REPLACE", warrantyStatus: isExpired ? "OUT_OF_WARRANTY" : "IN_WARRANTY", @@ -1058,6 +1078,7 @@ export async function POST(req: Request) { damageDescription: replacementNotes ? String(replacementNotes).trim() : "Klaim tukar unit garansi", actionTaken: actionDesc, salvagedParts: finalDamagedCondition === "CANNIBALIZED" ? cleanSalvagedParts : null, + stockAdjusted: true, recordedBy: user.name, }, }); diff --git a/src/app/api/users/route.ts b/src/app/api/users/route.ts index e9c5800..8fd688d 100644 --- a/src/app/api/users/route.ts +++ b/src/app/api/users/route.ts @@ -357,32 +357,35 @@ export async function PUT(req: Request) { const effectiveRole = updateData.role || targetRecord?.role || "SALES"; if (telegramChatId !== undefined) updateData.telegramChatId = telegramChatId ? telegramChatId.trim() : null; - if (notifyEmail !== undefined) updateData.notifyEmail = Boolean(notifyEmail); - if (notifyTelegram !== undefined) updateData.notifyTelegram = Boolean(notifyTelegram); - if (notifStockIn !== undefined || updateData.role) { - updateData.notifStockIn = - isRoleAllowedNotifType(effectiveRole, "STOCK_IN") && - (notifStockIn !== undefined ? Boolean(notifStockIn) : getRoleDefaultNotifications(effectiveRole).notifStockIn); - } - if (notifStockOut !== undefined || updateData.role) { - updateData.notifStockOut = - isRoleAllowedNotifType(effectiveRole, "STOCK_OUT") && - (notifStockOut !== undefined ? Boolean(notifStockOut) : getRoleDefaultNotifications(effectiveRole).notifStockOut); - } - if (notifMoneyIn !== undefined || updateData.role) { - updateData.notifMoneyIn = - isRoleAllowedNotifType(effectiveRole, "MONEY_IN") && - (notifMoneyIn !== undefined ? Boolean(notifMoneyIn) : getRoleDefaultNotifications(effectiveRole).notifMoneyIn); - } - if (notifMoneyOut !== undefined || updateData.role) { - updateData.notifMoneyOut = - isRoleAllowedNotifType(effectiveRole, "MONEY_OUT") && - (notifMoneyOut !== undefined ? Boolean(notifMoneyOut) : getRoleDefaultNotifications(effectiveRole).notifMoneyOut); - } - if (notifRma !== undefined || updateData.role) { - updateData.notifRma = - isRoleAllowedNotifType(effectiveRole, "RMA_SERVICE") && - (notifRma !== undefined ? Boolean(notifRma) : getRoleDefaultNotifications(effectiveRole).notifRma); + // Hanya Super Admin yang dapat mengubah saluran & topik notifikasi user + if (isAdmin) { + if (notifyEmail !== undefined) updateData.notifyEmail = Boolean(notifyEmail); + if (notifyTelegram !== undefined) updateData.notifyTelegram = Boolean(notifyTelegram); + if (notifStockIn !== undefined || updateData.role) { + updateData.notifStockIn = + isRoleAllowedNotifType(effectiveRole, "STOCK_IN") && + (notifStockIn !== undefined ? Boolean(notifStockIn) : getRoleDefaultNotifications(effectiveRole).notifStockIn); + } + if (notifStockOut !== undefined || updateData.role) { + updateData.notifStockOut = + isRoleAllowedNotifType(effectiveRole, "STOCK_OUT") && + (notifStockOut !== undefined ? Boolean(notifStockOut) : getRoleDefaultNotifications(effectiveRole).notifStockOut); + } + if (notifMoneyIn !== undefined || updateData.role) { + updateData.notifMoneyIn = + isRoleAllowedNotifType(effectiveRole, "MONEY_IN") && + (notifMoneyIn !== undefined ? Boolean(notifMoneyIn) : getRoleDefaultNotifications(effectiveRole).notifMoneyIn); + } + if (notifMoneyOut !== undefined || updateData.role) { + updateData.notifMoneyOut = + isRoleAllowedNotifType(effectiveRole, "MONEY_OUT") && + (notifMoneyOut !== undefined ? Boolean(notifMoneyOut) : getRoleDefaultNotifications(effectiveRole).notifMoneyOut); + } + if (notifRma !== undefined || updateData.role) { + updateData.notifRma = + isRoleAllowedNotifType(effectiveRole, "RMA_SERVICE") && + (notifRma !== undefined ? Boolean(notifRma) : getRoleDefaultNotifications(effectiveRole).notifRma); + } } if (mfaEnabled !== undefined) { diff --git a/src/app/finance/page.tsx b/src/app/finance/page.tsx index 3efc0ec..0df42b1 100644 --- a/src/app/finance/page.tsx +++ b/src/app/finance/page.tsx @@ -708,11 +708,12 @@ export default function FinancePage() { reader.onload = () => { const img = new window.Image(); img.onload = () => { - const maxDim = 360; + const maxW = 720; + const maxH = 360; let w = img.width; let h = img.height; - if (w > maxDim || h > maxDim) { - const ratio = Math.min(maxDim / w, maxDim / h); + if (w > maxW || h > maxH) { + const ratio = Math.min(maxW / w, maxH / h); w = Math.round(w * ratio); h = Math.round(h * ratio); } @@ -1310,7 +1311,7 @@ export default function FinancePage() { return ( {/* Financial Summary KPIs */}
@@ -1971,12 +1972,12 @@ export default function FinancePage() { - - - - - - {canCreateJournal && } + + + + + + {canCreateJournal && } @@ -1995,18 +1996,18 @@ export default function FinancePage() { return ( - - - - - {canCreateJournal && ( -
Kode AkunNama Akun / Rekening BankEntitas PT (Perusahaan)KlasifikasiSaldo Saat IniTindakanKodeNama AkunPerusahaan (PT)TipeSaldoAksi
+ {acc.code} + {acc.name} - - {acc.companyName || "PT EnterpriseCore Utama"} + + + {acc.companyName || "-"} + + {formatRupiah(acc.balance)} -
+
+
{currentUser?.role === "ADMIN" && !isSystemAccount && (
@@ -2508,7 +2509,7 @@ export default function FinancePage() { setNewPositionName(e.target.value)} - className="w-full px-3 py-2 border border-emerald-400 rounded-lg font-semibold" + className="w-full h-9 px-3 py-1.5 border border-emerald-400 rounded-lg font-semibold" /> @@ -2538,14 +2539,16 @@ export default function FinancePage() { {/* Dropdown Periode Bulan & Tahun */}
- +
+ +
setPeriodYear(e.target.value)} - className="w-full px-2.5 py-2 border border-slate-300 rounded-lg bg-white font-semibold text-slate-800" + className="w-full h-9 px-2.5 py-1.5 border border-slate-300 rounded-lg bg-white font-semibold text-slate-800" > {YEARS_LIST.map((y) => (