save before flutter upgrade
This commit is contained in:
44
lib/models/customers/address.dart
Normal file
44
lib/models/customers/address.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:nethive_neo/models/state.dart';
|
||||
|
||||
class Address {
|
||||
Address({
|
||||
required this.id,
|
||||
required this.address1,
|
||||
required this.address2,
|
||||
required this.zipcode,
|
||||
required this.city,
|
||||
required this.stateFk,
|
||||
required this.state,
|
||||
required this.country,
|
||||
});
|
||||
|
||||
int id;
|
||||
String address1;
|
||||
String? address2;
|
||||
String zipcode;
|
||||
String city;
|
||||
int stateFk;
|
||||
StateAPI state;
|
||||
String country;
|
||||
|
||||
String get fullAddress => '$address1 $city, ${state.code} $zipcode $country';
|
||||
|
||||
factory Address.fromJson(String str) => Address.fromMap(json.decode(str));
|
||||
|
||||
factory Address.fromMap(Map<String, dynamic> json) {
|
||||
Address address = Address(
|
||||
id: json["address_id"],
|
||||
address1: json['address_1'],
|
||||
address2: json['address_2'],
|
||||
zipcode: json['zipcode'],
|
||||
city: json['city'],
|
||||
stateFk: json['state_fk'],
|
||||
state: StateAPI.fromMap(json['state']),
|
||||
country: json['country'],
|
||||
);
|
||||
|
||||
return address;
|
||||
}
|
||||
}
|
||||
31
lib/models/customers/bill_cycle.dart
Normal file
31
lib/models/customers/bill_cycle.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class BillCycle {
|
||||
BillCycle({
|
||||
required this.customerId,
|
||||
required this.day,
|
||||
required this.billDueDay,
|
||||
required this.graceDays,
|
||||
required this.frequency,
|
||||
});
|
||||
|
||||
int customerId;
|
||||
int day;
|
||||
int billDueDay;
|
||||
int graceDays;
|
||||
int frequency;
|
||||
|
||||
factory BillCycle.fromJson(String str) => BillCycle.fromMap(json.decode(str));
|
||||
|
||||
factory BillCycle.fromMap(Map<String, dynamic> json) {
|
||||
BillCycle billCycle = BillCycle(
|
||||
customerId: json["customer_id"],
|
||||
day: json['day'],
|
||||
billDueDay: json['bill_due_day'],
|
||||
graceDays: json['grace_days'],
|
||||
frequency: json['frequency'],
|
||||
);
|
||||
|
||||
return billCycle;
|
||||
}
|
||||
}
|
||||
33
lib/models/customers/credit_card.dart
Normal file
33
lib/models/customers/credit_card.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CreditCard {
|
||||
CreditCard({
|
||||
required this.creditCardId,
|
||||
required this.type,
|
||||
required this.token,
|
||||
required this.automatic,
|
||||
required this.customerFk,
|
||||
});
|
||||
|
||||
int creditCardId;
|
||||
String type;
|
||||
String token;
|
||||
bool automatic;
|
||||
int customerFk;
|
||||
|
||||
String get last4Digits => token.substring(token.length - 4);
|
||||
|
||||
factory CreditCard.fromJson(String str) => CreditCard.fromMap(json.decode(str));
|
||||
|
||||
factory CreditCard.fromMap(Map<String, dynamic> json) {
|
||||
CreditCard creditCard = CreditCard(
|
||||
creditCardId: json["credit_card_id"],
|
||||
type: json['type'] ?? 'Credit Card',
|
||||
token: json['token'],
|
||||
automatic: json['automatic'] ?? true,
|
||||
customerFk: json['customer_fk'],
|
||||
);
|
||||
|
||||
return creditCard;
|
||||
}
|
||||
}
|
||||
45
lib/models/customers/customer.dart
Normal file
45
lib/models/customers/customer.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Customer {
|
||||
Customer({
|
||||
required this.id,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.email,
|
||||
required this.createdAt,
|
||||
required this.status,
|
||||
required this.phoneNumber,
|
||||
required this.balance,
|
||||
this.image,
|
||||
});
|
||||
|
||||
int id;
|
||||
String firstName;
|
||||
String lastName;
|
||||
String email;
|
||||
DateTime createdAt;
|
||||
String status;
|
||||
String phoneNumber;
|
||||
num balance;
|
||||
String? image;
|
||||
|
||||
String get fullName => '$firstName $lastName';
|
||||
|
||||
factory Customer.fromJson(String str) => Customer.fromMap(json.decode(str));
|
||||
|
||||
factory Customer.fromMap(Map<String, dynamic> json) {
|
||||
Customer customer = Customer(
|
||||
id: json["customer_id"],
|
||||
firstName: json['first_name'],
|
||||
lastName: json['last_name'],
|
||||
email: json["email"],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
status: json['status'],
|
||||
phoneNumber: json['mobile_phone'],
|
||||
balance: json['balance'] ?? 0.00,
|
||||
image: json['image'],
|
||||
);
|
||||
|
||||
return customer;
|
||||
}
|
||||
}
|
||||
37
lib/models/customers/customer_dashboards.dart
Normal file
37
lib/models/customers/customer_dashboards.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CustomerDashboards {
|
||||
int? customerId;
|
||||
DateTime? createdAt;
|
||||
String? firstName;
|
||||
String? lastName;
|
||||
String? status;
|
||||
|
||||
CustomerDashboards({
|
||||
this.customerId,
|
||||
this.createdAt,
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
this.status,
|
||||
});
|
||||
|
||||
factory CustomerDashboards.fromJson(String str) => CustomerDashboards.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CustomerDashboards.fromMap(Map<String, dynamic> json) => CustomerDashboards(
|
||||
customerId: json["customer_id"],
|
||||
createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]),
|
||||
firstName: json["first_name"],
|
||||
lastName: json["last_name"],
|
||||
status: json["status"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"customer_id": customerId,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"first_name": firstName,
|
||||
"last_name": lastName,
|
||||
"status": status,
|
||||
};
|
||||
}
|
||||
72
lib/models/customers/customer_details.dart
Normal file
72
lib/models/customers/customer_details.dart
Normal file
@@ -0,0 +1,72 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:nethive_neo/models/models.dart';
|
||||
|
||||
class CustomerDetails {
|
||||
CustomerDetails({
|
||||
required this.id,
|
||||
required this.createdDate,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.email,
|
||||
required this.billingAddress,
|
||||
required this.status,
|
||||
required this.phoneNumber,
|
||||
required this.balance,
|
||||
this.image,
|
||||
required this.billCycle,
|
||||
required this.services,
|
||||
required this.notes,
|
||||
required this.messages,
|
||||
});
|
||||
|
||||
int id;
|
||||
DateTime createdDate;
|
||||
String firstName;
|
||||
String lastName;
|
||||
String email;
|
||||
Address billingAddress;
|
||||
String status;
|
||||
String phoneNumber;
|
||||
num balance;
|
||||
String? image;
|
||||
BillCycle billCycle;
|
||||
List<Service> services;
|
||||
List<Note> notes;
|
||||
List<Message> messages;
|
||||
|
||||
String get fullName => '$firstName $lastName';
|
||||
|
||||
DateTime get billingDate {
|
||||
final now = DateTime.now();
|
||||
return DateTime(now.year, now.month, billCycle.day);
|
||||
}
|
||||
|
||||
factory CustomerDetails.fromJson(String str) =>
|
||||
CustomerDetails.fromMap(json.decode(str));
|
||||
|
||||
factory CustomerDetails.fromMap(Map<String, dynamic> json) {
|
||||
CustomerDetails customer = CustomerDetails(
|
||||
id: json["customer_id"],
|
||||
createdDate: DateTime.parse(json['created_date']),
|
||||
firstName: json['first_name'],
|
||||
lastName: json['last_name'],
|
||||
email: json["email"],
|
||||
billingAddress: Address.fromMap(json['billing_address']),
|
||||
status: json['status'],
|
||||
phoneNumber: json['mobile_phone'],
|
||||
balance: json['balance'] ?? 0.00,
|
||||
image: json['image'],
|
||||
billCycle: BillCycle.fromMap(json['billing_cycle']),
|
||||
services: (json['services'] as List)
|
||||
.map((service) => Service.fromMap(service))
|
||||
.toList(),
|
||||
notes: (json['notes'] as List).map((note) => Note.fromMap(note)).toList(),
|
||||
messages: (json['messages'] as List)
|
||||
.map((note) => Message.fromMap(note))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
return customer;
|
||||
}
|
||||
}
|
||||
73
lib/models/customers/customer_marcadores.dart
Normal file
73
lib/models/customers/customer_marcadores.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CustomerMarcadores {
|
||||
int? id;
|
||||
DateTime? createdAt;
|
||||
double? customersTotals;
|
||||
double? activeTotals;
|
||||
double? leadTotals;
|
||||
List<NewCustomersId>? newCustomersId;
|
||||
|
||||
CustomerMarcadores({
|
||||
this.id,
|
||||
this.createdAt,
|
||||
this.customersTotals,
|
||||
this.activeTotals,
|
||||
this.leadTotals,
|
||||
this.newCustomersId,
|
||||
});
|
||||
|
||||
factory CustomerMarcadores.fromJson(String str) => CustomerMarcadores.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CustomerMarcadores.fromMap(Map<String, dynamic> json) => CustomerMarcadores(
|
||||
id: json["id"],
|
||||
createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]),
|
||||
customersTotals: json["customers_totals"],
|
||||
activeTotals: json["active_totals"],
|
||||
leadTotals: json["lead_totals"],
|
||||
newCustomersId: json["new_customers_id"] == null ? [] : List<NewCustomersId>.from(json["new_customers_id"]!.map((x) => NewCustomersId.fromMap(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"id": id,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"customers_totals": customersTotals,
|
||||
"active_totals": activeTotals,
|
||||
"lead_totals": leadTotals,
|
||||
"new_customers_id": newCustomersId == null ? [] : List<dynamic>.from(newCustomersId!.map((x) => x.toMap())),
|
||||
};
|
||||
}
|
||||
|
||||
class NewCustomersId {
|
||||
int? count;
|
||||
String? status;
|
||||
DateTime? createdAt;
|
||||
List<int>? customerIds;
|
||||
|
||||
NewCustomersId({
|
||||
this.count,
|
||||
this.status,
|
||||
this.createdAt,
|
||||
this.customerIds,
|
||||
});
|
||||
|
||||
factory NewCustomersId.fromJson(String str) => NewCustomersId.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory NewCustomersId.fromMap(Map<String, dynamic> json) => NewCustomersId(
|
||||
count: json["count"],
|
||||
status: json["status"],
|
||||
createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]),
|
||||
customerIds: json["customer_ids"] == null ? [] : List<int>.from(json["customer_ids"]!.map((x) => x)),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"count": count,
|
||||
"status": status,
|
||||
"created_at": "${createdAt!.year.toString().padLeft(4, '0')}-${createdAt!.month.toString().padLeft(2, '0')}-${createdAt!.day.toString().padLeft(2, '0')}",
|
||||
"customer_ids": customerIds == null ? [] : List<dynamic>.from(customerIds!.map((x) => x)),
|
||||
};
|
||||
}
|
||||
47
lib/models/customers/customer_subscriptions.dart
Normal file
47
lib/models/customers/customer_subscriptions.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CustomerSubscription {
|
||||
int subscriptionId;
|
||||
String description;
|
||||
double amount;
|
||||
String status;
|
||||
String createdAt;
|
||||
String periodStart;
|
||||
String? periodEnd;
|
||||
|
||||
CustomerSubscription({
|
||||
required this.subscriptionId,
|
||||
required this.description,
|
||||
required this.amount,
|
||||
required this.status,
|
||||
required this.createdAt,
|
||||
required this.periodStart,
|
||||
required this.periodEnd,
|
||||
});
|
||||
|
||||
factory CustomerSubscription.fromJson(String str) =>
|
||||
CustomerSubscription.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CustomerSubscription.fromMap(Map<String, dynamic> json) =>
|
||||
CustomerSubscription(
|
||||
subscriptionId: json["subscription_id"],
|
||||
description: json["description"],
|
||||
amount: json["amount"],
|
||||
status: json["status"],
|
||||
createdAt: json["created_at"],
|
||||
periodStart: json["period_start"],
|
||||
periodEnd: json["period_end"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"subscription_id": subscriptionId,
|
||||
"description": description,
|
||||
"amount": amount,
|
||||
"status": status,
|
||||
"created_at": createdAt,
|
||||
"period_start": periodStart,
|
||||
"period_end": periodEnd,
|
||||
};
|
||||
}
|
||||
57
lib/models/customers/heatmap_customer_model.dart
Normal file
57
lib/models/customers/heatmap_customer_model.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class HeatmapCustomers {
|
||||
int? year;
|
||||
int? month;
|
||||
Registro? registro;
|
||||
|
||||
HeatmapCustomers({
|
||||
this.year,
|
||||
this.month,
|
||||
this.registro,
|
||||
});
|
||||
|
||||
factory HeatmapCustomers.fromJson(String str) => HeatmapCustomers.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory HeatmapCustomers.fromMap(Map<String, dynamic> json) => HeatmapCustomers(
|
||||
year: json["year"],
|
||||
month: json["month"],
|
||||
registro: json["registro"] == null ? null : Registro.fromMap(json["registro"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"year": year,
|
||||
"month": month,
|
||||
"registro": registro?.toMap(),
|
||||
};
|
||||
}
|
||||
|
||||
class Registro {
|
||||
double? leads;
|
||||
double? total;
|
||||
double? actives;
|
||||
|
||||
Registro({
|
||||
this.leads,
|
||||
this.total,
|
||||
this.actives,
|
||||
});
|
||||
|
||||
factory Registro.fromJson(String str) => Registro.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Registro.fromMap(Map<String, dynamic> json) => Registro(
|
||||
leads: json["Leads"],
|
||||
total: json["Total"],
|
||||
actives: json["Actives"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"Leads": leads,
|
||||
"Total": total,
|
||||
"Actives": actives,
|
||||
};
|
||||
}
|
||||
25
lib/models/customers/invoice.dart
Normal file
25
lib/models/customers/invoice.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Invoice {
|
||||
Invoice({
|
||||
required this.invoiceId,
|
||||
required this.date,
|
||||
required this.code,
|
||||
});
|
||||
|
||||
int invoiceId;
|
||||
DateTime date;
|
||||
String code;
|
||||
|
||||
factory Invoice.fromJson(String str) => Invoice.fromMap(json.decode(str));
|
||||
|
||||
factory Invoice.fromMap(Map<String, dynamic> json) {
|
||||
Invoice invoice = Invoice(
|
||||
invoiceId: json['invoice_id'],
|
||||
date: DateTime.parse(json["created_at"]),
|
||||
code: json['invoice'],
|
||||
);
|
||||
|
||||
return invoice;
|
||||
}
|
||||
}
|
||||
26
lib/models/customers/messages.dart
Normal file
26
lib/models/customers/messages.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Message {
|
||||
Message({
|
||||
required this.messageId,
|
||||
required this.createdAt,
|
||||
required this.customerFk,
|
||||
required this.text,
|
||||
});
|
||||
|
||||
int messageId;
|
||||
DateTime createdAt;
|
||||
int customerFk;
|
||||
String text;
|
||||
|
||||
factory Message.fromJson(String str) => Message.fromMap(json.decode(str));
|
||||
|
||||
factory Message.fromMap(Map<String, dynamic> json) {
|
||||
return Message(
|
||||
messageId: json["notification_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
customerFk: json['from'],
|
||||
text: json['message'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
28
lib/models/customers/note.dart
Normal file
28
lib/models/customers/note.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Note {
|
||||
Note({
|
||||
required this.noteId,
|
||||
required this.createdAt,
|
||||
required this.customerFk,
|
||||
required this.text,
|
||||
});
|
||||
|
||||
int noteId;
|
||||
DateTime createdAt;
|
||||
int customerFk;
|
||||
String text;
|
||||
|
||||
factory Note.fromJson(String str) => Note.fromMap(json.decode(str));
|
||||
|
||||
factory Note.fromMap(Map<String, dynamic> json) {
|
||||
Note note = Note(
|
||||
noteId: json["note_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
customerFk: json['customer_fk'],
|
||||
text: json['note'] ?? '',
|
||||
);
|
||||
|
||||
return note;
|
||||
}
|
||||
}
|
||||
44
lib/models/customers/payment.dart
Normal file
44
lib/models/customers/payment.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Payment {
|
||||
Payment({
|
||||
required this.paymentId,
|
||||
required this.transactionId,
|
||||
required this.date,
|
||||
required this.method,
|
||||
required this.description,
|
||||
required this.status,
|
||||
required this.amount,
|
||||
required this.error,
|
||||
});
|
||||
|
||||
int transactionId;
|
||||
int paymentId;
|
||||
DateTime date;
|
||||
String method;
|
||||
String description;
|
||||
String status;
|
||||
num amount;
|
||||
String error;
|
||||
|
||||
// String get displayValue => creditCard == '-' ? creditCard : '****$last4Digits';
|
||||
|
||||
// String get last4Digits => creditCard.substring(creditCard.length - 4);
|
||||
|
||||
factory Payment.fromJson(String str) => Payment.fromMap(json.decode(str));
|
||||
|
||||
factory Payment.fromMap(Map<String, dynamic> json) {
|
||||
Payment payment = Payment(
|
||||
paymentId: json['payment_id'],
|
||||
transactionId: json['transaction_id'],
|
||||
date: DateTime.parse(json["date"]),
|
||||
method: json['method'],
|
||||
description: json['description'],
|
||||
status: json['status'],
|
||||
amount: json['amount'],
|
||||
error: json['error'] ?? '',
|
||||
);
|
||||
|
||||
return payment;
|
||||
}
|
||||
}
|
||||
26
lib/models/customers/recent_activity.dart
Normal file
26
lib/models/customers/recent_activity.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class RecentActivity {
|
||||
RecentActivity({
|
||||
required this.recentActivityId,
|
||||
required this.createdAt,
|
||||
required this.customerFk,
|
||||
required this.activity,
|
||||
});
|
||||
|
||||
int recentActivityId;
|
||||
DateTime createdAt;
|
||||
int customerFk;
|
||||
String activity;
|
||||
|
||||
factory RecentActivity.fromJson(String str) => RecentActivity.fromMap(json.decode(str));
|
||||
|
||||
factory RecentActivity.fromMap(Map<String, dynamic> json) {
|
||||
return RecentActivity(
|
||||
recentActivityId: json["recent_activity_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
customerFk: json['customer_fk'],
|
||||
activity: json['activity'],
|
||||
);
|
||||
}
|
||||
}
|
||||
30
lib/models/customers/transaction.dart
Normal file
30
lib/models/customers/transaction.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Transaction {
|
||||
Transaction(
|
||||
{required this.date,
|
||||
required this.description,
|
||||
required this.type,
|
||||
required this.amount,
|
||||
required this.status});
|
||||
|
||||
DateTime date;
|
||||
String description;
|
||||
String type;
|
||||
num amount;
|
||||
String status;
|
||||
|
||||
factory Transaction.fromJson(String str) =>
|
||||
Transaction.fromMap(json.decode(str));
|
||||
|
||||
factory Transaction.fromMap(Map<String, dynamic> json) {
|
||||
Transaction transaction = Transaction(
|
||||
date: DateTime.parse(json["created_at"]),
|
||||
description: json['description'],
|
||||
type: json['type_transaction'],
|
||||
amount: json['total_amout'],
|
||||
status: json['status']);
|
||||
|
||||
return transaction;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user