update address

This commit is contained in:
Phuoc Nguyen
2025-11-18 17:04:00 +07:00
parent a5eb95fa64
commit 0dda402246
33 changed files with 4250 additions and 232 deletions

View File

@@ -0,0 +1,105 @@
/// Address Entity
///
/// Represents a delivery/billing address for the user.
/// Corresponds to Frappe ERPNext Address doctype.
library;
import 'package:equatable/equatable.dart';
/// Address Entity
///
/// Domain entity representing a user's delivery or billing address.
class Address extends Equatable {
final String name;
final String addressTitle;
final String addressLine1;
final String phone;
final String? email;
final String? fax;
final String? taxCode;
final String cityCode;
final String wardCode;
final bool isDefault;
final String? cityName;
final String? wardName;
const Address({
required this.name,
required this.addressTitle,
required this.addressLine1,
required this.phone,
this.email,
this.fax,
this.taxCode,
required this.cityCode,
required this.wardCode,
this.isDefault = false,
this.cityName,
this.wardName,
});
@override
List<Object?> get props => [
name,
addressTitle,
addressLine1,
phone,
email,
fax,
taxCode,
cityCode,
wardCode,
isDefault,
cityName,
wardName,
];
/// Get full address display string
String get fullAddress {
final parts = <String>[];
parts.add(addressLine1);
if (wardName != null && wardName!.isNotEmpty) {
parts.add(wardName!);
}
if (cityName != null && cityName!.isNotEmpty) {
parts.add(cityName!);
}
return parts.join(', ');
}
/// Create a copy with modified fields
Address copyWith({
String? name,
String? addressTitle,
String? addressLine1,
String? phone,
String? email,
String? fax,
String? taxCode,
String? cityCode,
String? wardCode,
bool? isDefault,
String? cityName,
String? wardName,
}) {
return Address(
name: name ?? this.name,
addressTitle: addressTitle ?? this.addressTitle,
addressLine1: addressLine1 ?? this.addressLine1,
phone: phone ?? this.phone,
email: email ?? this.email,
fax: fax ?? this.fax,
taxCode: taxCode ?? this.taxCode,
cityCode: cityCode ?? this.cityCode,
wardCode: wardCode ?? this.wardCode,
isDefault: isDefault ?? this.isDefault,
cityName: cityName ?? this.cityName,
wardName: wardName ?? this.wardName,
);
}
@override
String toString() {
return 'Address(name: $name, addressTitle: $addressTitle, addressLine1: $addressLine1, phone: $phone, isDefault: $isDefault)';
}
}

View File

@@ -0,0 +1,27 @@
/// City Entity
///
/// Represents a city/province in Vietnam.
library;
import 'package:equatable/equatable.dart';
/// City Entity
///
/// Domain entity representing a city or province.
class City extends Equatable {
final String name; // Frappe ERPNext name/ID
final String cityName; // Display name
final String code; // City code
const City({
required this.name,
required this.cityName,
required this.code,
});
@override
List<Object?> get props => [name, cityName, code];
@override
String toString() => 'City(name: $name, cityName: $cityName, code: $code)';
}

View File

@@ -0,0 +1,27 @@
/// Ward Entity
///
/// Represents a ward/district in a city.
library;
import 'package:equatable/equatable.dart';
/// Ward Entity
///
/// Domain entity representing a ward or district within a city.
class Ward extends Equatable {
final String name; // Frappe ERPNext name/ID
final String wardName; // Display name
final String code; // Ward code
const Ward({
required this.name,
required this.wardName,
required this.code,
});
@override
List<Object?> get props => [name, wardName, code];
@override
String toString() => 'Ward(name: $name, wardName: $wardName, code: $code)';
}