🔬 LegacyLens Viewer
Aman

Ringkasan Eksekutif

Dianalisis5file
Diubah1file
Terdampak (ripple)3file
StatusAman

Dihasilkan: 1 Januari 2025 pukul 00.00

Perubahan yang Dilakukan

FilePerubahanAlasan
utils/pricing.jsSignature calculateDiscount(price, rate, callback) → async calculateDiscount(price, rate)Modernisasi dari callback ke async/await; error kini di-throw, bukan di-forward ke callback
checkout.jsprocessCheckout(order, callback) → async processCheckout(order); konsumsi via await calculateDiscount(...)Mengikuti signature baru pricing.js
report.jsRekursi callback processNext() → Promise.all(transactions.map(tx => calculateDiscount(...)))Lebih ringkas + paralel
app.jsSemua route handler function(req,res) → async (req,res) + try/catchMenyesuaikan modul yang kini semua berbasis Promise
package.jsonmoment 2.24.0 → 2.31.0Patch keamanan; tidak ada breaking change di API yang dipakai

Hasil Validasi Test

17 test17 lolos
TestStatusCatatan
menghitung grand total dengan diskon 10%✓ LolosgrandTotal = 180000
menghitung grand total tanpa diskon (rate 0)✓ LolosgrandTotal = 50000
menghitung grand total dengan diskon 100%✓ LolosgrandTotal = 0
melempar error jika harga negatif✓ Lolosthrows 'Harga tidak valid'
melempar error jika rate melebihi 100✓ Lolosthrows 'Rate diskon tidak valid'
createInvoice — totalDue dengan diskon 15%✓ LolostotalDue = 425000 (setelah fix await)
createInvoice — tanpa diskon (0%)✓ LolostotalDue = amount asli
createInvoice — diskon 100%✓ LolostotalDue = 0
createInvoice — properti wajib tidak undefined✓ LolosinvoiceId, issuedAt, totalDue terisi
createInvoice — error amount negatif✓ Lolosthrows 'Harga tidak valid'
createInvoice — error rate > 100✓ Lolosthrows 'Rate diskon tidak valid'
generateDiscountReport — akumulasi multiple transaksi✓ LolostotalOriginal/Discounted/Saved benar
generateDiscountReport — transaksi tunggal tanpa diskon✓ LolostotalDiscounted = amount asli
generateDiscountReport — diskon 100%✓ LolostotalDiscounted = 0
generateDiscountReport — array kosong✓ Lolossemua nilai = 0
generateDiscountReport — null✓ Lolossemua nilai = 0
generateDiscountReport — error amount negatif✓ Lolosthrows 'Harga tidak valid'