first commit

This commit is contained in:
Aditya Siregar
2025-07-30 22:38:44 +07:00
commit 73320561b0
444 changed files with 64633 additions and 0 deletions
@@ -0,0 +1,33 @@
import 'dart:convert';
import 'package:enaklo_pos/data/models/response/product_response_model.dart';
class AddProductResponseModel {
final bool success;
final String message;
final Product data;
AddProductResponseModel({
required this.success,
required this.message,
required this.data,
});
factory AddProductResponseModel.fromJson(String str) =>
AddProductResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory AddProductResponseModel.fromMap(Map<String, dynamic> json) =>
AddProductResponseModel(
success: json["success"],
message: json["message"],
data: Product.fromMap(json["data"]),
);
Map<String, dynamic> toMap() => {
"success": success,
"message": message,
"data": data.toMap(),
};
}
@@ -0,0 +1,85 @@
import 'dart:convert';
class AuthResponseModel {
final String? status;
final String? token;
final User? user;
AuthResponseModel({
this.status,
this.token,
this.user,
});
factory AuthResponseModel.fromJson(String str) => AuthResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory AuthResponseModel.fromMap(Map<String, dynamic> json) => AuthResponseModel(
status: json["status"],
token: json["token"],
user: json["user"] == null ? null : User.fromMap(json["user"]),
);
Map<String, dynamic> toMap() => {
"status": status,
"token": token,
"user": user?.toMap(),
};
}
class User {
final int? id;
final String? name;
final String? email;
final DateTime? emailVerifiedAt;
final dynamic twoFactorSecret;
final dynamic twoFactorRecoveryCodes;
final dynamic twoFactorConfirmedAt;
final DateTime? createdAt;
final DateTime? updatedAt;
final String? role;
User({
this.id,
this.name,
this.email,
this.emailVerifiedAt,
this.twoFactorSecret,
this.twoFactorRecoveryCodes,
this.twoFactorConfirmedAt,
this.createdAt,
this.updatedAt,
this.role,
});
factory User.fromJson(String str) => User.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory User.fromMap(Map<String, dynamic> json) => User(
id: json["id"],
name: json["name"],
email: json["email"],
emailVerifiedAt: json["email_verified_at"] == null ? null : DateTime.parse(json["email_verified_at"]),
twoFactorSecret: json["two_factor_secret"],
twoFactorRecoveryCodes: json["two_factor_recovery_codes"],
twoFactorConfirmedAt: json["two_factor_confirmed_at"],
createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"] == null ? null : DateTime.parse(json["updated_at"]),
role: json["role"],
);
Map<String, dynamic> toMap() => {
"id": id,
"name": name,
"email": email,
"email_verified_at": emailVerifiedAt?.toIso8601String(),
"two_factor_secret": twoFactorSecret,
"two_factor_recovery_codes": twoFactorRecoveryCodes,
"two_factor_confirmed_at": twoFactorConfirmedAt,
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
"role": role,
};
}
@@ -0,0 +1,91 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
class CategroyResponseModel {
final String status;
final List<CategoryModel> data;
CategroyResponseModel({
required this.status,
required this.data,
});
Map<String, dynamic> toMap() {
return <String, dynamic>{
'status': status,
'data': data.map((x) => x.toMap()).toList(),
};
}
factory CategroyResponseModel.fromMap(Map<String, dynamic> map) {
return CategroyResponseModel(
status: map['status'] as String,
data: List<CategoryModel>.from(
(map['data']).map<CategoryModel>(
(x) => CategoryModel.fromMap(x as Map<String, dynamic>),
),
),
);
}
factory CategroyResponseModel.fromJson(String str) =>
CategroyResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
}
class CategoryModel {
int? id;
String? name;
int? categoryId;
int? isSync;
String? image;
// DateTime createdAt;
// DateTime updatedAt;
CategoryModel({this.id, this.name, this.categoryId, this.isSync, this.image});
Map<String, dynamic> toMap() {
return <String, dynamic>{
// 'id': id,
'name': name,
'is_sync': isSync ?? 1,
'category_id': id,
'image': image
};
}
factory CategoryModel.fromMap(Map<String, dynamic> map) {
return CategoryModel(
id: map['id'] as int?,
name: map['name'] as String?,
isSync: map['is_sync'] as int?,
categoryId: map['id'],
image: map['image']);
}
factory CategoryModel.fromJson(String str) =>
CategoryModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
@override
bool operator ==(covariant CategoryModel other) {
if (identical(this, other)) return true;
return other.id == id &&
other.name == name &&
other.categoryId == categoryId &&
other.isSync == isSync &&
other.image == image;
}
@override
int get hashCode {
return id.hashCode ^
name.hashCode ^
categoryId.hashCode ^
isSync.hashCode ^
image.hashCode;
}
}
@@ -0,0 +1,90 @@
import 'dart:convert';
class DiscountResponseModel {
final String? status;
final List<Discount>? data;
DiscountResponseModel({
this.status,
this.data,
});
factory DiscountResponseModel.fromJson(String str) =>
DiscountResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory DiscountResponseModel.fromMap(Map<String, dynamic> json) =>
DiscountResponseModel(
status: json["status"],
data: json["data"] == null
? []
: List<Discount>.from(
json["data"]!.map((x) => Discount.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"status": status,
"data":
data == null ? [] : List<dynamic>.from(data!.map((x) => x.toMap())),
};
}
class Discount {
final int? id;
final String? name;
final String? description;
final String? type;
final String? value;
final String? status;
final DateTime? expiredDate;
final DateTime? createdAt;
final DateTime? updatedAt;
Discount({
this.id,
this.name,
this.description,
this.type,
this.value,
this.status,
this.expiredDate,
this.createdAt,
this.updatedAt,
});
factory Discount.fromJson(String str) => Discount.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory Discount.fromMap(Map<String, dynamic> json) => Discount(
id: json["id"],
name: json["name"],
description: json["description"],
type: json["type"],
value: json["value"],
status: json["status"],
expiredDate: json["expired_date"] == null
? null
: DateTime.parse(json["expired_date"]),
createdAt: json["created_at"] == null
? null
: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"] == null
? null
: DateTime.parse(json["updated_at"]),
);
Map<String, dynamic> toMap() => {
"id": id,
"name": name,
"description": description,
"type": type,
"value": value,
"status": status,
"expired_date":
"${expiredDate!.year.toString().padLeft(4, '0')}-${expiredDate!.month.toString().padLeft(2, '0')}-${expiredDate!.day.toString().padLeft(2, '0')}",
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
};
}
@@ -0,0 +1,83 @@
import 'dart:convert';
class ItemSalesResponseModel {
String? status;
List<ItemSales>? data;
ItemSalesResponseModel({
this.status,
this.data,
});
factory ItemSalesResponseModel.fromJson(String str) =>
ItemSalesResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory ItemSalesResponseModel.fromMap(Map<String, dynamic> json) =>
ItemSalesResponseModel(
status: json["status"],
data: json["data"] == null
? []
: List<ItemSales>.from(
json["data"]!.map((x) => ItemSales.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"status": status,
"data":
data == null ? [] : List<dynamic>.from(data!.map((x) => x.toMap())),
};
}
class ItemSales {
int? id;
int? orderId;
int? productId;
int? quantity;
int? price;
DateTime? createdAt;
DateTime? updatedAt;
String? productName;
ItemSales({
this.id,
this.orderId,
this.productId,
this.quantity,
this.price,
this.createdAt,
this.updatedAt,
this.productName,
});
factory ItemSales.fromJson(String str) => ItemSales.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory ItemSales.fromMap(Map<String, dynamic> json) => ItemSales(
id: json["id"],
orderId: json["order_id"],
productId: json["product_id"],
quantity: json["quantity"],
price: json["price"],
createdAt: json["created_at"] == null
? null
: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"] == null
? null
: DateTime.parse(json["updated_at"]),
productName: json["product_name"]!,
);
Map<String, dynamic> toMap() => {
"id": id,
"order_id": orderId,
"product_id": productId,
"quantity": quantity,
"price": price,
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
"product_name": productName,
};
}
@@ -0,0 +1,113 @@
import 'dart:convert';
class OrderResponseModel {
String? status;
List<ItemOrder>? data;
OrderResponseModel({
this.status,
this.data,
});
factory OrderResponseModel.fromJson(String str) =>
OrderResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory OrderResponseModel.fromMap(Map<String, dynamic> json) =>
OrderResponseModel(
status: json["status"],
data: json["data"] == null
? []
: List<ItemOrder>.from(
json["data"]!.map((x) => ItemOrder.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"status": status,
"data":
data == null ? [] : List<dynamic>.from(data!.map((x) => x.toMap())),
};
}
class ItemOrder {
int? id;
int? paymentAmount;
int? subTotal;
int? tax;
int? discount;
String? discountAmount;
int? serviceCharge;
int? total;
String? paymentMethod;
int? totalItem;
int? idKasir;
String? namaKasir;
DateTime? transactionTime;
DateTime? createdAt;
DateTime? updatedAt;
ItemOrder({
this.id,
this.paymentAmount,
this.subTotal,
this.tax,
this.discount,
this.discountAmount,
this.serviceCharge,
this.total,
this.paymentMethod,
this.totalItem,
this.idKasir,
this.namaKasir,
this.transactionTime,
this.createdAt,
this.updatedAt,
});
factory ItemOrder.fromJson(String str) => ItemOrder.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory ItemOrder.fromMap(Map<String, dynamic> json) => ItemOrder(
id: json["id"],
paymentAmount: json["payment_amount"],
subTotal: json["sub_total"],
tax: json["tax"],
discount: json["discount"],
discountAmount: json["discount_amount"],
serviceCharge: json["service_charge"],
total: json["total"],
paymentMethod: json["payment_method"]!,
totalItem: json["total_item"],
idKasir: json["id_kasir"],
namaKasir: json["nama_kasir"],
transactionTime: json["transaction_time"] == null
? null
: DateTime.parse(json["transaction_time"]),
createdAt: json["created_at"] == null
? null
: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"] == null
? null
: DateTime.parse(json["updated_at"]),
);
Map<String, dynamic> toMap() => {
"id": id,
"payment_amount": paymentAmount,
"sub_total": subTotal,
"tax": tax,
"discount": discount,
"discount_amount": discountAmount,
"service_charge": serviceCharge,
"total": total,
"payment_method": paymentMethod,
"total_item": totalItem,
"id_kasir": idKasir,
"nama_kasir": namaKasir,
"transaction_time": transactionTime?.toIso8601String(),
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
};
}
@@ -0,0 +1,90 @@
import 'dart:convert';
class PaymentMethodResponseModel {
final String? status;
final PaymentMethodData? data;
PaymentMethodResponseModel({
this.status,
this.data,
});
factory PaymentMethodResponseModel.fromJson(String str) =>
PaymentMethodResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory PaymentMethodResponseModel.fromMap(Map<String, dynamic> json) =>
PaymentMethodResponseModel(
status: json["status"],
data: json["data"] == null
? null
: PaymentMethodData.fromMap(json["data"]),
);
Map<String, dynamic> toMap() => {
"status": status,
"data": data?.toMap(),
};
}
class PaymentMethodData {
final String? total;
final List<PaymentMethodItem>? paymentMethods;
PaymentMethodData({
this.total,
this.paymentMethods,
});
factory PaymentMethodData.fromJson(String str) =>
PaymentMethodData.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory PaymentMethodData.fromMap(Map<String, dynamic> json) =>
PaymentMethodData(
total: json["total"],
paymentMethods: json["payment_methods"] == null
? []
: List<PaymentMethodItem>.from(
json["payment_methods"]!.map((x) => PaymentMethodItem.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"total": total,
"payment_methods": paymentMethods == null
? []
: List<dynamic>.from(paymentMethods!.map((x) => x.toMap())),
};
}
class PaymentMethodItem {
final String? paymentMethod;
final String? totalAmount;
final int? transactionCount;
PaymentMethodItem({
this.paymentMethod,
this.totalAmount,
this.transactionCount,
});
factory PaymentMethodItem.fromJson(String str) =>
PaymentMethodItem.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory PaymentMethodItem.fromMap(Map<String, dynamic> json) =>
PaymentMethodItem(
paymentMethod: json["payment_method"],
totalAmount: json["total_amount"],
transactionCount: json["transaction_count"],
);
Map<String, dynamic> toMap() => {
"payment_method": paymentMethod,
"total_amount": totalAmount,
"transaction_count": transactionCount,
};
}
@@ -0,0 +1,81 @@
import 'dart:convert';
class PaymentMethodsResponseModel {
final String? status;
final List<PaymentMethod>? data;
PaymentMethodsResponseModel({
this.status,
this.data,
});
factory PaymentMethodsResponseModel.fromJson(String str) =>
PaymentMethodsResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory PaymentMethodsResponseModel.fromMap(Map<String, dynamic> json) =>
PaymentMethodsResponseModel(
status: json["status"],
data: json["data"] == null
? []
: List<PaymentMethod>.from(
json["data"]!.map((x) => PaymentMethod.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"status": status,
"data": data == null
? []
: List<dynamic>.from(data!.map((x) => x.toMap())),
};
}
class PaymentMethod {
final int? id;
final String? name;
final String? description;
final bool? isActive;
final int? sortOrder;
final DateTime? createdAt;
final DateTime? updatedAt;
PaymentMethod({
this.id,
this.name,
this.description,
this.isActive,
this.sortOrder,
this.createdAt,
this.updatedAt,
});
factory PaymentMethod.fromJson(String str) =>
PaymentMethod.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory PaymentMethod.fromMap(Map<String, dynamic> json) => PaymentMethod(
id: json["id"],
name: json["name"],
description: json["description"],
isActive: json["is_active"],
sortOrder: json["sort_order"],
createdAt: json["created_at"] == null
? null
: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"] == null
? null
: DateTime.parse(json["updated_at"]),
);
Map<String, dynamic> toMap() => {
"id": id,
"name": name,
"description": description,
"is_active": isActive,
"sort_order": sortOrder,
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
};
}
+38
View File
@@ -0,0 +1,38 @@
class PrintModel {
int? id;
final String code;
final String name;
final String address;
final String paper;
final String type;
PrintModel({
this.id,
required this.code,
required this.name,
required this.address,
required this.paper,
required this.type,
});
// from map
factory PrintModel.fromMap(Map<String, dynamic> map) {
return PrintModel(
id: map['id'],
code: map['code'],
name: map['name'],
address: map['address'],
paper: map['paper'],
type: map['type'],
);
}
// to map
Map<String, dynamic> toMap() => {
"code": code,
"name": name,
"address": address,
"paper": paper,
"type": type,
};
}
@@ -0,0 +1,299 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:enaklo_pos/presentation/home/pages/confirm_payment_page.dart';
class ProductResponseModel {
final String? status;
final List<Product>? data;
ProductResponseModel({
this.status,
this.data,
});
factory ProductResponseModel.fromJson(String str) =>
ProductResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory ProductResponseModel.fromMap(Map<String, dynamic> json) =>
ProductResponseModel(
status: json["status"],
data: json["data"] == null
? []
: List<Product>.from(json["data"]!.map((x) => Product.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"status": status,
"data":
data == null ? [] : List<dynamic>.from(data!.map((x) => x.toMap())),
};
}
class Product {
final int? id;
final int? productId;
final int? categoryId;
final String? name;
final String? description;
final String? image;
final String? price;
final int? stock;
final int? status;
final int? isFavorite;
final DateTime? createdAt;
final DateTime? updatedAt;
final Category? category;
final String? printerType;
Product({
this.id,
this.productId,
this.categoryId,
this.name,
this.description,
this.image,
this.price,
this.stock,
this.status,
this.isFavorite,
this.createdAt,
this.updatedAt,
this.category,
this.printerType,
});
factory Product.fromJson(String str) => Product.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory Product.fromMap(Map<String, dynamic> json) => Product(
id: json["id"] is String ? int.tryParse(json["id"]) : json["id"],
productId: json["product_id"] is String ? int.tryParse(json["product_id"]) : json["product_id"],
categoryId: json["category_id"] is String
? int.tryParse(json["category_id"])
: json["category_id"],
name: json["name"],
description: json["description"],
image: json["image"],
// price: json["price"].substring(0, json["price"].length - 3),
price: json["price"].toString().replaceAll('.00', ''),
stock: json["stock"] is String ? int.tryParse(json["stock"]) : json["stock"],
status: json["status"] is String ? int.tryParse(json["status"]) : json["status"],
isFavorite: json["is_favorite"] is String ? int.tryParse(json["is_favorite"]) : json["is_favorite"],
createdAt: json["created_at"] == null
? null
: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"] == null
? null
: DateTime.parse(json["updated_at"]),
category: json["category"] == null
? null
: Category.fromMap(json["category"]),
printerType: json["printer_type"] ?? 'bar',
);
factory Product.fromOrderMap(Map<String, dynamic> json) => Product(
id: json["id_product"],
price: json["price"].toString(),
);
factory Product.fromLocalMap(Map<String, dynamic> json) => Product(
id: json["id"],
productId: json["product_id"],
categoryId: json["categoryId"],
category: Category(
id: json["categoryId"],
name: json["categoryName"],
),
name: json["name"],
description: json["description"],
image: json["image"],
price: json["price"],
stock: json["stock"],
status: json["status"],
isFavorite: json["isFavorite"],
createdAt: json["createdAt"] == null
? null
: DateTime.parse(json["createdAt"]),
updatedAt: json["updatedAt"] == null
? null
: DateTime.parse(json["updatedAt"]),
printerType: json["printer_type"] ?? 'bar',
);
Map<String, dynamic> toLocalMap() => {
"product_id": id,
"categoryId": categoryId,
"categoryName": category?.name,
"name": name,
"description": description,
"image": image,
"price": price?.replaceAll(RegExp(r'\.0+$'), ''),
"stock": stock,
"status": status,
"isFavorite": isFavorite,
"createdAt": createdAt?.toIso8601String(),
"updatedAt": updatedAt?.toIso8601String(),
"printer_type": printerType,
};
Map<String, dynamic> toMap() => {
"id": id,
"product_id": productId,
"category_id": categoryId,
"name": name,
"description": description,
"image": image,
"price": price,
"stock": stock,
"status": status,
"is_favorite": isFavorite,
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
"category": category?.toMap(),
"printer_type": printerType,
};
@override
bool operator ==(covariant Product other) {
if (identical(this, other)) return true;
return other.id == id &&
other.productId == productId &&
other.categoryId == categoryId &&
other.name == name &&
other.description == description &&
other.image == image &&
other.price == price &&
other.stock == stock &&
other.status == status &&
other.isFavorite == isFavorite &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt &&
other.category == category &&
other.printerType == printerType;
}
@override
int get hashCode {
return id.hashCode ^
productId.hashCode ^
categoryId.hashCode ^
name.hashCode ^
description.hashCode ^
image.hashCode ^
price.hashCode ^
stock.hashCode ^
status.hashCode ^
isFavorite.hashCode ^
createdAt.hashCode ^
updatedAt.hashCode ^
category.hashCode ^
printerType.hashCode;
}
Product copyWith({
int? id,
int? productId,
int? categoryId,
String? name,
String? description,
String? image,
String? price,
int? stock,
int? status,
int? isFavorite,
DateTime? createdAt,
DateTime? updatedAt,
Category? category,
String? printerType,
}) {
return Product(
id: id ?? this.id,
productId: productId ?? this.productId,
categoryId: categoryId ?? this.categoryId,
name: name ?? this.name,
description: description ?? this.description,
image: image ?? this.image,
price: price ?? this.price,
stock: stock ?? this.stock,
status: status ?? this.status,
isFavorite: isFavorite ?? this.isFavorite,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
category: category ?? this.category,
printerType: printerType ?? this.printerType,
);
}
}
class Category {
final int? id;
final String? name;
final String? description;
final String? image;
final DateTime? createdAt;
final DateTime? updatedAt;
Category({
this.id,
this.name,
this.description,
this.image,
this.createdAt,
this.updatedAt,
});
factory Category.fromJson(String str) => Category.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory Category.fromMap(Map<String, dynamic> json) => Category(
id: json["id"] is String ? int.tryParse(json["id"]) : json["id"],
name: json["name"],
description: json["description"],
image: json["image"],
createdAt: json["created_at"] == null
? null
: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"] == null
? null
: DateTime.parse(json["updated_at"]),
);
Map<String, dynamic> toMap() => {
"id": id,
"name": name,
"description": description,
"image": image,
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
};
@override
bool operator ==(covariant Category other) {
if (identical(this, other)) return true;
return other.id == id &&
other.name == name &&
other.description == description &&
other.image == image &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return id.hashCode ^
name.hashCode ^
description.hashCode ^
image.hashCode ^
createdAt.hashCode ^
updatedAt.hashCode;
}
}
@@ -0,0 +1,60 @@
import 'dart:convert';
class ProductSalesResponseModel {
String? status;
List<ProductSales>? data;
ProductSalesResponseModel({
this.status,
this.data,
});
factory ProductSalesResponseModel.fromJson(String str) =>
ProductSalesResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory ProductSalesResponseModel.fromMap(Map<String, dynamic> json) =>
ProductSalesResponseModel(
status: json["status"],
data: json["data"] == null
? []
: List<ProductSales>.from(
json["data"]!.map((x) => ProductSales.fromMap(x))),
);
Map<String, dynamic> toMap() => {
"status": status,
"data":
data == null ? [] : List<dynamic>.from(data!.map((x) => x.toMap())),
};
}
class ProductSales {
int? productId;
String? productName;
String? totalQuantity;
ProductSales({
this.productId,
this.productName,
this.totalQuantity,
});
factory ProductSales.fromJson(String str) =>
ProductSales.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory ProductSales.fromMap(Map<String, dynamic> json) => ProductSales(
productId: json["product_id"],
productName: json["product_name"],
totalQuantity: json["total_quantity"],
);
Map<String, dynamic> toMap() => {
"product_id": productId,
"product_name": productName,
"total_quantity": totalQuantity,
};
}
@@ -0,0 +1,107 @@
import 'dart:convert';
class QrisResponseModel {
final String? statusCode;
final String? statusMessage;
final String? transactionId;
final String? orderId;
final String? merchantId;
final String? grossAmount;
final String? currency;
final String? paymentType;
final DateTime? transactionTime;
final String? transactionStatus;
final String? fraudStatus;
final List<Action>? actions;
final DateTime? expiryTime;
QrisResponseModel({
this.statusCode,
this.statusMessage,
this.transactionId,
this.orderId,
this.merchantId,
this.grossAmount,
this.currency,
this.paymentType,
this.transactionTime,
this.transactionStatus,
this.fraudStatus,
this.actions,
this.expiryTime,
});
factory QrisResponseModel.fromJson(String str) =>
QrisResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory QrisResponseModel.fromMap(Map<String, dynamic> json) =>
QrisResponseModel(
statusCode: json["status_code"],
statusMessage: json["status_message"],
transactionId: json["transaction_id"],
orderId: json["order_id"],
merchantId: json["merchant_id"],
grossAmount: json["gross_amount"],
currency: json["currency"],
paymentType: json["payment_type"],
transactionTime: json["transaction_time"] == null
? null
: DateTime.parse(json["transaction_time"]),
transactionStatus: json["transaction_status"],
fraudStatus: json["fraud_status"],
actions: json["actions"] == null
? []
: List<Action>.from(json["actions"]!.map((x) => Action.fromMap(x))),
expiryTime: json["expiry_time"] == null
? null
: DateTime.parse(json["expiry_time"]),
);
Map<String, dynamic> toMap() => {
"status_code": statusCode,
"status_message": statusMessage,
"transaction_id": transactionId,
"order_id": orderId,
"merchant_id": merchantId,
"gross_amount": grossAmount,
"currency": currency,
"payment_type": paymentType,
"transaction_time": transactionTime?.toIso8601String(),
"transaction_status": transactionStatus,
"fraud_status": fraudStatus,
"actions": actions == null
? []
: List<dynamic>.from(actions!.map((x) => x.toMap())),
"expiry_time": expiryTime?.toIso8601String(),
};
}
class Action {
final String? name;
final String? method;
final String? url;
Action({
this.name,
this.method,
this.url,
});
factory Action.fromJson(String str) => Action.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory Action.fromMap(Map<String, dynamic> json) => Action(
name: json["name"],
method: json["method"],
url: json["url"],
);
Map<String, dynamic> toMap() => {
"name": name,
"method": method,
"url": url,
};
}
@@ -0,0 +1,111 @@
import 'dart:convert';
class QrisStatusResponseModel {
final String? maskedCard;
final String? approvalCode;
final String? bank;
final String? eci;
final String? channelResponseCode;
final String? channelResponseMessage;
final DateTime? transactionTime;
final String? grossAmount;
final String? currency;
final String? orderId;
final String? paymentType;
final String? signatureKey;
final String? statusCode;
final String? transactionId;
final String? transactionStatus;
final String? fraudStatus;
final DateTime? settlementTime;
final String? statusMessage;
final String? merchantId;
final String? cardType;
final String? threeDsVersion;
final bool? challengeCompletion;
QrisStatusResponseModel({
this.maskedCard,
this.approvalCode,
this.bank,
this.eci,
this.channelResponseCode,
this.channelResponseMessage,
this.transactionTime,
this.grossAmount,
this.currency,
this.orderId,
this.paymentType,
this.signatureKey,
this.statusCode,
this.transactionId,
this.transactionStatus,
this.fraudStatus,
this.settlementTime,
this.statusMessage,
this.merchantId,
this.cardType,
this.threeDsVersion,
this.challengeCompletion,
});
factory QrisStatusResponseModel.fromJson(String str) =>
QrisStatusResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory QrisStatusResponseModel.fromMap(Map<String, dynamic> json) =>
QrisStatusResponseModel(
maskedCard: json["masked_card"],
approvalCode: json["approval_code"],
bank: json["bank"],
eci: json["eci"],
channelResponseCode: json["channel_response_code"],
channelResponseMessage: json["channel_response_message"],
transactionTime: json["transaction_time"] == null
? null
: DateTime.parse(json["transaction_time"]),
grossAmount: json["gross_amount"],
currency: json["currency"],
orderId: json["order_id"],
paymentType: json["payment_type"],
signatureKey: json["signature_key"],
statusCode: json["status_code"],
transactionId: json["transaction_id"],
transactionStatus: json["transaction_status"],
fraudStatus: json["fraud_status"],
settlementTime: json["settlement_time"] == null
? null
: DateTime.parse(json["settlement_time"]),
statusMessage: json["status_message"],
merchantId: json["merchant_id"],
cardType: json["card_type"],
threeDsVersion: json["three_ds_version"],
challengeCompletion: json["challenge_completion"],
);
Map<String, dynamic> toMap() => {
"masked_card": maskedCard,
"approval_code": approvalCode,
"bank": bank,
"eci": eci,
"channel_response_code": channelResponseCode,
"channel_response_message": channelResponseMessage,
"transaction_time": transactionTime?.toIso8601String(),
"gross_amount": grossAmount,
"currency": currency,
"order_id": orderId,
"payment_type": paymentType,
"signature_key": signatureKey,
"status_code": statusCode,
"transaction_id": transactionId,
"transaction_status": transactionStatus,
"fraud_status": fraudStatus,
"settlement_time": settlementTime?.toIso8601String(),
"status_message": statusMessage,
"merchant_id": merchantId,
"card_type": cardType,
"three_ds_version": threeDsVersion,
"challenge_completion": challengeCompletion,
};
}
@@ -0,0 +1,78 @@
import 'dart:convert';
class SummaryResponseModel {
String? status;
SummaryModel? data;
SummaryResponseModel({
this.status,
this.data,
});
factory SummaryResponseModel.fromJson(String str) =>
SummaryResponseModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory SummaryResponseModel.fromMap(Map<String, dynamic> json) =>
SummaryResponseModel(
status: json["status"],
data: json["data"] == null ? null : SummaryModel.fromMap(json["data"]),
);
Map<String, dynamic> toMap() => {
"status": status,
"data": data?.toMap(),
};
}
class SummaryModel {
String? totalRevenue;
String? totalDiscount;
String? totalTax;
String? totalSubtotal;
String? totalServiceCharge;
int? total;
SummaryModel({
this.totalRevenue,
this.totalDiscount,
this.totalTax,
this.totalSubtotal,
this.totalServiceCharge,
this.total,
});
factory SummaryModel.fromJson(String str) =>
SummaryModel.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory SummaryModel.fromMap(Map<String, dynamic> json) => SummaryModel(
totalRevenue: json["total_revenue"] is int
? json["total_revenue"].toString()
: json["total_revenue"],
totalDiscount: json["total_discount"] is int
? json["total_discount"].toString()
: json["total_discount"],
totalTax: json["total_tax"] is int
? json["total_tax"].toString()
: json["total_tax"],
totalSubtotal: json["total_subtotal"] is int
? json["total_subtotal"].toString()
: json["total_subtotal"],
totalServiceCharge: json["total_service_charge"] is int
? json["total_service_charge"].toString()
: json["total_service_charge"],
total: json["total"],
);
Map<String, dynamic> toMap() => {
"total_revenue": totalRevenue,
"total_discount": totalDiscount,
"total_tax": totalTax,
"total_subtotal": totalSubtotal,
"total_service_charge": totalServiceCharge,
"total": total,
};
}
+74
View File
@@ -0,0 +1,74 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:ui';
class TableModel {
int? id;
final String tableName;
final String startTime;
final String status;
final int orderId;
final int paymentAmount;
final Offset position;
TableModel({
this.id,
required this.tableName,
required this.startTime,
required this.status,
required this.orderId,
required this.paymentAmount,
required this.position,
});
@override
// from map
factory TableModel.fromMap(Map<String, dynamic> map) {
return TableModel(
id: map['id'],
tableName: map['table_name'],
startTime: map['start_time'],
status: map['status'],
orderId: map['order_id'],
paymentAmount: map['payment_amount'],
position: Offset(map['x_position'], map['y_position']),
);
}
// to map
Map<String, dynamic> toMap() {
return {
'table_name': tableName,
'status': status,
'start_time': startTime,
'order_id': orderId,
'payment_amount': paymentAmount,
'x_position': position.dx,
'y_position': position.dy,
};
}
@override
bool operator ==(covariant TableModel other) {
if (identical(this, other)) return true;
return other.id == id &&
other.tableName == tableName &&
other.startTime == startTime &&
other.status == status &&
other.orderId == orderId &&
other.paymentAmount == paymentAmount &&
other.position == position;
}
@override
int get hashCode {
return id.hashCode ^
tableName.hashCode ^
startTime.hashCode ^
status.hashCode ^
orderId.hashCode ^
paymentAmount.hashCode ^
position.hashCode;
}
}