Inherited Code — Clean Code

Keep a zakat desk's inherited code working: errors, SOLID and tests, judged by tomorrow's change. 16 levels, right in the browser.

What the levels ask

  1. 15 Ramadan. Mr. Rofiq left Kas Zakat behind when he went to work in Batam, and now Mr. Zaki keeps the UPZ desk. The fitrah rate lives in tarif.js. The neighbourhood head asks one thing: next year another officer, who only knows tarif.js, will enter the new decree, so a decree must change a single file. Pick what fitrah() multiplies by. This year's decree arrives tomorrow.
  2. 16 Ramadan. Zakat mal is worked out from a nisab of 85 grams of gold, and the gold price for each day comes from the regency's list in emas.js. Sometimes the list for a day arrives late. Pick what hargaEmas() does when the day's price is not there yet, so no villager is ever handed a wrong zakat figure.
  3. 17 Ramadan. Villagers who have already transferred give their reference, and transfer.js asks the bank for the amount. If the bank does not answer, loket.js prints "Belum bisa dicek" and the kwitansi follows later. Mr. Bayu from the bank warns that tomorrow morning the bank's system is being updated. Pick what the catch in setoranTransfer() does.
  4. 18 Ramadan. Cash gifts go into the drawer, and the drawer must be locked again after every payment, whether it went through or not. meja.js catches any error and hands the money back. The neighbourhood head brings word that the takmir is preparing a new rule for large payments. Pick what terimaTunai() does after the drawer opens.
  5. 19 Ramadan. loket.js is the edge of the app: it catches any error and sends one message to the villager's phone. In the middle, fitrah() checks the number of people through validasi.js. The neighbourhood head is about to add a rule on how many people one kwitansi may cover. Pick what fitrah() does, so a villager who fills it in wrong gets exactly one clear message.
  6. 20 Ramadan. At night tutupHari() in malam.js adds up the cash book through rekap() and reports to the takmir's WhatsApp group. rekap.test.js tests the sum. Mr. Bayu offers his laptop to run the tests every night. Fill both holes, so the takmir gets exactly one report and the test never touches WhatsApp.
  7. 21 Ramadan. Each way to pay has its own file (tunai.js, transfer.js) and is listed in cara.js. The neighbourhood head is putting up a QRIS stand: the new way to pay arrives as a new file with its test, plus one name on the list in cara.js, without touching any other file. Pick how bayar() chooses the way to pay.
  8. 22 Ramadan. Fitrah envelopes are printed from the village office's list of recipients, plus late names from the neighbourhood. Mr. Rofiq's siapkanAmplop() uses a Daftar as it is and copies any other list first. The village office is about to ask that nobody change its list. Pick the shape of DaftarTetap in daftar.js.
  9. 23 Ramadan. kwitansi.js prints through whatever device loket.js plugs in; the old machine prints, sends WhatsApp and scans QR codes. That machine is wheezing. Pick what pasangPrinter() checks before it accepts a device.
  10. 24 Ramadan. Money given before the Eid prayer is zakat fitrah; after it, sedekah. waktu.test.js wants to check 1 Syawal at 07.00 without waiting for Lebaran, with a fake clock and calendar. loket.js calls jenisSetoran() with no arguments. Pick the shape of jenisSetoran().
  11. 25 Ramadan. Every time fitrah is paid and every time an envelope is ready, the villager's neighbourhood head is told by phone. loket.js and amplop.js both look up the neighbourhood head's number. The village office is tidying its neighbourhood data. Pick how both of them get that number (your choice is used in both files).
  12. 26 Ramadan. Zakat mal is rounded to the nearest Rp500 by bulatkan() from the pecahan library, third-party code we did not write. pecahan.test.js is a learning test: a test that writes down what we rely on from that library. Mr. Piksel says the new version is out. Pick what the learning test checks.

And more, 16 levels in all.