first commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import '../../home/models/product_category.dart';
|
||||
|
||||
class DiscountModel {
|
||||
final String name;
|
||||
final String code;
|
||||
final int discount;
|
||||
final ProductCategory category;
|
||||
final String? description;
|
||||
|
||||
DiscountModel({
|
||||
required this.name,
|
||||
required this.code,
|
||||
required this.discount,
|
||||
required this.category,
|
||||
required this.description,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
enum PrinterType {
|
||||
wifi('Wifi'),
|
||||
bluetooth('Bluetooth');
|
||||
|
||||
final String value;
|
||||
const PrinterType(this.value);
|
||||
|
||||
bool get isWifi => this == PrinterType.wifi;
|
||||
bool get isBluetooth => this == PrinterType.bluetooth;
|
||||
|
||||
factory PrinterType.fromValue(String value) {
|
||||
return values.firstWhere(
|
||||
(element) => element.value == value,
|
||||
orElse: () => PrinterType.wifi,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PrinterModel {
|
||||
final String name;
|
||||
final String ipAddress;
|
||||
final String size;
|
||||
final PrinterType type;
|
||||
|
||||
PrinterModel({
|
||||
required this.name,
|
||||
required this.ipAddress,
|
||||
required this.size,
|
||||
required this.type,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'dart:convert';
|
||||
|
||||
enum TaxType {
|
||||
layanan,
|
||||
pajak;
|
||||
|
||||
bool get isLayanan => this == TaxType.layanan;
|
||||
bool get isPajak => this == TaxType.pajak;
|
||||
}
|
||||
|
||||
class TaxModel {
|
||||
final String name;
|
||||
final TaxType type;
|
||||
final int value;
|
||||
|
||||
TaxModel({
|
||||
required this.name,
|
||||
required this.type,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'name': name,
|
||||
'type': type.name,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
|
||||
factory TaxModel.fromMap(Map<String, dynamic> map) {
|
||||
return TaxModel(
|
||||
name: map['name'] ?? '',
|
||||
type: TaxType.values.firstWhere(
|
||||
(e) => e.name == map['type'],
|
||||
orElse: () => TaxType.layanan,
|
||||
),
|
||||
value: map['value']?.toInt() ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory TaxModel.fromJson(String source) => TaxModel.fromMap(json.decode(source));
|
||||
}
|
||||
Reference in New Issue
Block a user