Collection: subscription_invoices
Menyimpan invoice subscription toko — paket yang dibeli, addon, dan status pembayaran.
Struktur Dokumen
json{
"_id": "uuid-string",
"store_id": "uuid-string",
"package_id": "uuid-string",
"plan": 1,
"price": 100000,
"status": "paid",
"paid_at": "2026-06-25T14:30:00.000000Z",
"expired_at": "2026-07-25T14:30:00.000000Z",
"addon_invoices": [
{
"addon_id": "uuid-string",
"price": 50000,
"status": "paid"
}
],
"coupon_id": "uuid-string",
"discount": 10000,
"total": 140000,
"payment_method": "bank_transfer",
"payment_proof": "uploads/bukti-transfer/xxx.jpg",
"notes": "Pembayaran via BCA",
"created_at": "2026-06-25T14:00:00.000000Z",
"updated_at": "2026-06-25T14:30:00.000000Z"
}
Field
| Field | Type | Deskripsi |
|---|
_id | string (UUID) | Primary key |
store_id | string (UUID) | Foreign key ke stores._id |
package_id | string (UUID) | Foreign key ke packages._id |
plan | int | Quantity/duration multiplier (1, 2, 3, …) |
price | int | Harga paket (per unit) |
status | string | Status: pending, paid, expired, cancelled |
paid_at | DateTime | Waktu dibayar |
expired_at | DateTime | Waktu expiry subscription |
addon_invoices | array | Daftar addon yang dibeli |
addon_invoices[].addon_id | string | Foreign key ke addons._id |
addon_invoices[].price | int | Harga addon |
addon_invoices[].status | string | Status addon invoice |
coupon_id | string | Foreign key ke coupons._id (jika pakai coupon) |
discount | int | Jumlah diskon |
total | int | Total bayar (price × plan + addons - discount) |
payment_method | string | Metode pembayaran |
payment_proof | string | Path bukti transfer |
notes | string | Catatan admin |
Relasi
| Relasi | Type | Ke |
|---|
store | belongsTo | stores via store_id |
package | belongsTo | packages via package_id |
payment | hasOne | subscription_payments via invoice_id |
Query Umum
javascript// Invoice pending
db.subscription_invoices.find({ status: "pending" })
// Invoice paid bulan ini
db.subscription_invoices.find({
status: "paid",
paid_at: { $gte: ISODate("2026-06-01T00:00:00Z") }
})
// Invoice by store
db.subscription_invoices.find({ store_id: "uuid-store" })