feat: add CPONE package endpoints

This commit is contained in:
2026-08-20 10:11:12 +07:00
parent 21196d8227
commit a7102e6b0e
7 changed files with 832 additions and 1 deletions

View File

@@ -0,0 +1,45 @@
package repository
import "testing"
func TestPaketListWhereParity(t *testing.T) {
where, args := paketListWhere(PaketListParams{
Search: "MCU", Code: "DISP", CareType: "RJ", Status: 2,
Active: "N", StartDate: "2026-08-01", EndDate: "2026-08-31",
})
const expected = "WHERE ph.StatusID = ? AND ph.NA = ? AND ph.Nama LIKE ? AND ph.PaketID LIKE ? AND ph.RJ = 1 AND ph.TglSampai >= ? AND ph.TglDari <= ?"
if where != expected {
t.Fatalf("where=%q", where)
}
if len(args) != 6 || args[0] != 2 || args[1] != "N" || args[2] != "%MCU%" || args[3] != "%DISP%" {
t.Fatalf("args=%v", args)
}
}
func TestPHPNumberFormatParity(t *testing.T) {
tests := []struct {
value float64
decimals int
expected string
}{
{500000, 0, "500,000"},
{1609.5, 2, "1,609.50"},
{1448.55, 2, "1,448.55"},
{0, 2, "0.00"},
{-1234.5, 0, "-1,235"},
}
for _, test := range tests {
if actual := phpNumberFormat(test.value, test.decimals); actual != test.expected {
t.Fatalf("phpNumberFormat(%v, %d)=%q want=%q", test.value, test.decimals, actual, test.expected)
}
}
}
func TestLaravelDateJSONParity(t *testing.T) {
if actual := laravelDateJSON("2026-08-05 17:05:03"); actual != "2026-08-05T10:05:03.000000Z" {
t.Fatalf("date=%q", actual)
}
if actual := laravelDateJSON("0000-00-00 00:00:00"); actual != "-000001-11-29T16:52:48.000000Z" {
t.Fatalf("zero date=%q", actual)
}
}