CentralBackend/models/Abonemment.js
2025-12-13 11:15:20 +01:00

36 lines
1.3 KiB
JavaScript

class Abonemment {
constructor(row) {
this.id = row.id;
this.status = row.status;
this.started_at = row.started_at;
this.ended_at = row.ended_at;
this.next_billing_at = row.next_billing_at;
this.billing_interval = row.billing_interval;
this.interval_count = row.interval_count;
this.price = row.price;
this.currency = row.currency;
this.is_auto_renew = !!row.is_auto_renew;
this.notes = row.notes;
this.pack_group = row.pack_group;
this.pack_breakdown = row.pack_breakdown ? (typeof row.pack_breakdown === 'string' ? JSON.parse(row.pack_breakdown) : row.pack_breakdown) : null;
this.first_name = row.first_name;
this.last_name = row.last_name;
this.email = row.email;
this.street = row.street;
this.postal_code = row.postal_code;
this.city = row.city;
this.country = row.country;
this.frequency = row.frequency;
this.referred_by = row.referred_by; // NEW
this.created_at = row.created_at;
this.updated_at = row.updated_at;
}
get isActive() { return this.status === 'active'; }
get isPaused() { return this.status === 'paused'; }
get isCanceled() { return this.status === 'canceled'; }
get isExpired() { return this.status === 'expired'; }
}
module.exports = Abonemment;