update invoice
This commit is contained in:
97
docs/invoice.sh
Normal file
97
docs/invoice.sh
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
#get list of invoices
|
||||||
|
curl --location 'https://land.dbiz.com//api/method/building_material.building_material.api.invoice.get_list' \
|
||||||
|
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
|
||||||
|
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
"limit_page_length" : 0,
|
||||||
|
"limit_start" : 0
|
||||||
|
}'
|
||||||
|
|
||||||
|
#response
|
||||||
|
{
|
||||||
|
"message": [
|
||||||
|
{
|
||||||
|
"name": "ACC-SINV-2025-00041",
|
||||||
|
"posting_date": "2025-12-02",
|
||||||
|
"status": "Chưa thanh toán",
|
||||||
|
"status_color": "Danger",
|
||||||
|
"order_id": null,
|
||||||
|
"grand_total": 486400.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ACC-SINV-2025-00026",
|
||||||
|
"posting_date": "2025-11-25",
|
||||||
|
"status": "Đã trả",
|
||||||
|
"status_color": "Success",
|
||||||
|
"order_id": "SAL-ORD-2025-00119",
|
||||||
|
"grand_total": 1153433.6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ACC-SINV-2025-00025",
|
||||||
|
"posting_date": "2025-11-24",
|
||||||
|
"status": "Đã trả",
|
||||||
|
"status_color": "Success",
|
||||||
|
"order_id": "SAL-ORD-2025-00104",
|
||||||
|
"grand_total": 3580257.894
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
#get invoice detail
|
||||||
|
curl --location 'https://land.dbiz.com//api/method/building_material.building_material.api.invoice.get_detail' \
|
||||||
|
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
|
||||||
|
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
"name" : "ACC-SINV-2025-00041"
|
||||||
|
}'
|
||||||
|
|
||||||
|
#response
|
||||||
|
{
|
||||||
|
"message": {
|
||||||
|
"name": "ACC-SINV-2025-00041",
|
||||||
|
"posting_date": "2025-12-02",
|
||||||
|
"status": "Chưa thanh toán",
|
||||||
|
"status_color": "Danger",
|
||||||
|
"customer_name": "Ha Duy Lam",
|
||||||
|
"order_id": null,
|
||||||
|
"seller_info": {
|
||||||
|
"phone": "0243 543 0726",
|
||||||
|
"email": "info@viglacera.com.vn",
|
||||||
|
"fax": "(024) 3553 6671",
|
||||||
|
"tax_code": "0105908818",
|
||||||
|
"company_name": "Công Ty Cổ Phần Kinh Doanh Gạch Ốp Lát Viglacera",
|
||||||
|
"address_line1": "Tầng 2 tòa nhà Viglacera, số 1 đại lộ Thăng Long",
|
||||||
|
"city_code": "01",
|
||||||
|
"ward_code": "00637",
|
||||||
|
"city_name": "Thành phố Hà Nội",
|
||||||
|
"ward_name": "Phường Đại Mỗ"
|
||||||
|
},
|
||||||
|
"buyer_info": {
|
||||||
|
"name": "phuoc-thanh toán",
|
||||||
|
"address_title": "phuoc",
|
||||||
|
"address_line1": "123 tt",
|
||||||
|
"phone": "0985225855",
|
||||||
|
"email": null,
|
||||||
|
"fax": null,
|
||||||
|
"tax_code": null,
|
||||||
|
"city_code": "75",
|
||||||
|
"ward_code": "25252",
|
||||||
|
"city_name": "Tỉnh Đồng Nai",
|
||||||
|
"ward_name": "Xã Phú Riềng"
|
||||||
|
},
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"item_name": "Hội An HOA E01",
|
||||||
|
"item_code": "HOA E01",
|
||||||
|
"qty": 1.0,
|
||||||
|
"rate": 486400.0,
|
||||||
|
"amount": 486400.0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"total": 486400.0,
|
||||||
|
"discount_amount": 0.0,
|
||||||
|
"grand_total": 486400.0
|
||||||
|
}
|
||||||
|
}
|
||||||
632
html/invoice-detail.html
Normal file
632
html/invoice-detail.html
Normal file
@@ -0,0 +1,632 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="vi">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Chi tiết Hóa đơn - EuroTile Worker</title>
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
<link rel="stylesheet" href="assets/css/style.css">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||||
|
<style>
|
||||||
|
.invoice-container {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background: #f8fafc;
|
||||||
|
min-height: 100vh;
|
||||||
|
padding-bottom: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-content {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-card {
|
||||||
|
background: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 24px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Invoice Header */
|
||||||
|
.invoice-header-section {
|
||||||
|
text-align: center;
|
||||||
|
padding-bottom: 24px;
|
||||||
|
border-bottom: 2px solid #e5e7eb;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.company-logo {
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
|
||||||
|
border-radius: 12px;
|
||||||
|
margin: 0 auto 16px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: white;
|
||||||
|
font-size: 32px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-title {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-number {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #2563eb;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-meta {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-meta-item {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-meta-label {
|
||||||
|
color: #6b7280;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-meta-value {
|
||||||
|
color: #1f2937;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Company Info */
|
||||||
|
.company-info-section {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 24px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.company-info-block h3 {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.company-info-block p {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #6b7280;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.company-info-block p strong {
|
||||||
|
color: #1f2937;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Products Table */
|
||||||
|
.products-section h3 {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.products-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.products-table thead {
|
||||||
|
background: #f8fafc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.products-table th {
|
||||||
|
padding: 12px;
|
||||||
|
text-align: left;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #6b7280;
|
||||||
|
border-bottom: 2px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.products-table th:last-child,
|
||||||
|
.products-table td:last-child {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.products-table td {
|
||||||
|
padding: 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #1f2937;
|
||||||
|
border-bottom: 1px solid #f3f4f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.products-table tbody tr:hover {
|
||||||
|
background: #f8fafc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-name {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-sku {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Summary */
|
||||||
|
.invoice-summary {
|
||||||
|
background: #f8fafc;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 16px;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 8px 0;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-row.total {
|
||||||
|
border-top: 2px solid #e5e7eb;
|
||||||
|
padding-top: 16px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-label {
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-value {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1f2937;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-row.total .summary-label,
|
||||||
|
.summary-row.total .summary-value {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-row.total .summary-value {
|
||||||
|
color: #dc2626;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Notes */
|
||||||
|
.invoice-notes {
|
||||||
|
margin-top: 24px;
|
||||||
|
padding-top: 24px;
|
||||||
|
border-top: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-notes h4 {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-notes p {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b7280;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status Badge */
|
||||||
|
.status-badge {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 20px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-paid {
|
||||||
|
background: #d1fae5;
|
||||||
|
color: #065f46;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-unpaid {
|
||||||
|
background: #fef3c7;
|
||||||
|
color: #d97706;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-partial {
|
||||||
|
background: #e0e7ff;
|
||||||
|
color: #3730a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sticky Footer Actions */
|
||||||
|
.invoice-actions {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background: white;
|
||||||
|
border-top: 2px solid #e5e7eb;
|
||||||
|
padding: 16px 20px;
|
||||||
|
box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
|
||||||
|
z-index: 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-actions-content {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
flex: 1;
|
||||||
|
padding: 14px 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 15px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
border: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
background: white;
|
||||||
|
color: #374151;
|
||||||
|
border: 2px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary:hover {
|
||||||
|
border-color: #2563eb;
|
||||||
|
color: #2563eb;
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Toast Notification */
|
||||||
|
.toast {
|
||||||
|
position: fixed;
|
||||||
|
top: 80px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
background: #1f2937;
|
||||||
|
color: white;
|
||||||
|
padding: 12px 24px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 4px 16px rgba(0,0,0,0.2);
|
||||||
|
z-index: 1000;
|
||||||
|
display: none;
|
||||||
|
animation: slideDown 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast.show {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast.success {
|
||||||
|
background: #065f46;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast.error {
|
||||||
|
background: #dc2626;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slideDown {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(-50%) translateY(-20px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateX(-50%) translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.invoice-content {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-card {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.company-info-section {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.products-table {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.products-table th,
|
||||||
|
.products-table td {
|
||||||
|
padding: 8px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-actions-content {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="page-wrapper">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="header">
|
||||||
|
<a href="invoice-list.html" class="back-button">
|
||||||
|
<i class="fas fa-arrow-left"></i>
|
||||||
|
</a>
|
||||||
|
<h1 class="header-title">Chi tiết Hóa đơn</h1>
|
||||||
|
<button class="header-action-btn" onclick="shareInvoice()">
|
||||||
|
<i class="fas fa-share-alt"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="invoice-container">
|
||||||
|
<div class="invoice-content">
|
||||||
|
<!-- Invoice Header Card -->
|
||||||
|
<div class="invoice-card">
|
||||||
|
<div class="invoice-header-section">
|
||||||
|
<div class="company-logo">
|
||||||
|
<i class="fas fa-file-invoice-dollar"></i>
|
||||||
|
</div>
|
||||||
|
<h1 class="invoice-title">HÓA ĐƠN GTGT</h1>
|
||||||
|
<div class="invoice-number">#INV20240001</div>
|
||||||
|
<span class="status-badge status-paid">Đã thanh toán</span>
|
||||||
|
|
||||||
|
<div class="invoice-meta">
|
||||||
|
<!--<div class="invoice-meta-item">
|
||||||
|
<div class="invoice-meta-label">Mẫu số:</div>
|
||||||
|
<div class="invoice-meta-value">01GTKT0/001</div>
|
||||||
|
</div>-->
|
||||||
|
<!--<div class="invoice-meta-item">
|
||||||
|
<div class="invoice-meta-label">Ký hiệu:</div>
|
||||||
|
<div class="invoice-meta-value">AA/24E</div>
|
||||||
|
</div>-->
|
||||||
|
<div class="invoice-meta-item">
|
||||||
|
<div class="invoice-meta-label">Ngày xuất:</div>
|
||||||
|
<div class="invoice-meta-value">03/08/2024</div>
|
||||||
|
</div>
|
||||||
|
<div class="invoice-meta-item">
|
||||||
|
<div class="invoice-meta-label">Đơn hàng:</div>
|
||||||
|
<div class="invoice-meta-value">#DH001234</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Company Information -->
|
||||||
|
<div class="company-info-section">
|
||||||
|
<div class="company-info-block">
|
||||||
|
<h3>
|
||||||
|
<i class="fas fa-building text-blue-600"></i>
|
||||||
|
Đơn vị bán hàng
|
||||||
|
</h3>
|
||||||
|
<p><strong>Công ty:</strong> CÔNG TY CP EUROTILE VIỆT NAM</p>
|
||||||
|
<p><strong>Mã số thuế:</strong> 0301234567</p>
|
||||||
|
<p><strong>Địa chỉ:</strong> 123 Đường Nguyễn Văn Linh, Quận 7, TP.HCM</p>
|
||||||
|
<p><strong>Điện thoại:</strong> (028) 1900 1234</p>
|
||||||
|
<p><strong>Email:</strong> sales@eurotile.vn</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="company-info-block">
|
||||||
|
<h3>
|
||||||
|
<i class="fas fa-user-tie text-green-600"></i>
|
||||||
|
Đơn vị mua hàng
|
||||||
|
</h3>
|
||||||
|
<p><strong>Người mua hàng:</strong> Lê Hoàng Hiệp </p>
|
||||||
|
<p><strong>Tên đơn vị:</strong> Công ty TNHH Xây dựng Minh Long</p>
|
||||||
|
<p><strong>Mã số thuế:</strong> 0134000687</p>
|
||||||
|
<p><strong>Địa chỉ:</strong> 11 Đường Hoàng Hữu Nam, Phường Linh Chiểu, TP. Thủ Đức, TP.HCM</p>
|
||||||
|
<p><strong>Điện thoại:</strong> 0339797979</p>
|
||||||
|
<p><strong>Email:</strong> minhlong.org@gmail.com</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Products Section -->
|
||||||
|
<div class="invoice-card products-section">
|
||||||
|
<h3>
|
||||||
|
<i class="fas fa-box-open"></i>
|
||||||
|
Chi tiết hàng hóa
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<table class="products-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 40px;">#</th>
|
||||||
|
<th>Tên hàng hóa</th>
|
||||||
|
<!--<th style="width: 80px;">ĐVT</th>-->
|
||||||
|
<th style="width: 80px;">Số lượng</th>
|
||||||
|
<th style="width: 110px;">Đơn giá</th>
|
||||||
|
<th style="width: 120px;">Thành tiền</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>1</td>
|
||||||
|
<td>
|
||||||
|
<div class="product-name">Gạch Eurotile MỘC LAM E03</div>
|
||||||
|
<div class="product-sku">SKU: ET-ML-E03-60x60</div>
|
||||||
|
</td>
|
||||||
|
<!--<td>m²</td>-->
|
||||||
|
<td>30,12</td>
|
||||||
|
<td>285.000đ</td>
|
||||||
|
<td><strong>8.550.000đ</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>2</td>
|
||||||
|
<td>
|
||||||
|
<div class="product-name">Gạch Eurotile STONE GREY S02</div>
|
||||||
|
<div class="product-sku">SKU: ET-SG-S02-80x80</div>
|
||||||
|
</td>
|
||||||
|
<!--<td>m²</td>-->
|
||||||
|
<td>20,24</td>
|
||||||
|
<td>217.500đ</td>
|
||||||
|
<td><strong>4.350.000đ</strong></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- Invoice Summary -->
|
||||||
|
<div class="invoice-summary">
|
||||||
|
<div class="summary-row">
|
||||||
|
<span class="summary-label">Tổng tiền hàng:</span>
|
||||||
|
<span class="summary-value">12.900.000đ</span>
|
||||||
|
</div>
|
||||||
|
<div class="summary-row">
|
||||||
|
<span class="summary-label">Chiết khấu VIP (1%):</span>
|
||||||
|
<span class="summary-value" style="color: #059669;">-129.000đ</span>
|
||||||
|
</div>
|
||||||
|
<!--<div class="summary-row">
|
||||||
|
<span class="summary-label">Tiền trước thuế:</span>
|
||||||
|
<span class="summary-value">12.771.000đ</span>
|
||||||
|
</div>-->
|
||||||
|
<!--<div class="summary-row">
|
||||||
|
<span class="summary-label">Thuế GTGT (0%):</span>
|
||||||
|
<span class="summary-value">0đ</span>
|
||||||
|
</div>-->
|
||||||
|
<div class="summary-row total">
|
||||||
|
<span class="summary-label">TỔNG THANH TOÁN:</span>
|
||||||
|
<span class="summary-value">12.771.000đ</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Notes -->
|
||||||
|
<!--<div class="invoice-notes">
|
||||||
|
<h4>Ghi chú:</h4>
|
||||||
|
<p>- Số tiền viết bằng chữ: <strong>Mười hai triệu bảy trăm bảy mươi mốt nghìn đồng chẵn.</strong></p>
|
||||||
|
<p>- Hình thức thanh toán: Chuyển khoản ngân hàng</p>
|
||||||
|
<p>- Hóa đơn điện tử đã được ký số và có giá trị pháp lý</p>
|
||||||
|
</div>-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Action Buttons -->
|
||||||
|
<div id="actionButtons" class="action-buttons">
|
||||||
|
<button class="btn btn-secondary" onclick="contactSupport()">
|
||||||
|
<i class="fas fa-comments"></i>
|
||||||
|
Liên hệ hỗ trợ
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Sticky Footer Actions -->
|
||||||
|
<!--<div class="invoice-actions">
|
||||||
|
<div class="invoice-actions-content">
|
||||||
|
<button class="btn btn-secondary" onclick="downloadPDF()">
|
||||||
|
<i class="fas fa-download"></i>
|
||||||
|
Tải xuống PDF
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-primary" onclick="sendEmail()">
|
||||||
|
<i class="fas fa-envelope"></i>
|
||||||
|
Gửi qua Email
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>-->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Toast Notification -->
|
||||||
|
<div id="toast" class="toast"></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Show toast notification
|
||||||
|
function showToast(message, type = 'success') {
|
||||||
|
const toast = document.getElementById('toast');
|
||||||
|
toast.textContent = message;
|
||||||
|
toast.className = `toast ${type} show`;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
toast.classList.remove('show');
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Download PDF function
|
||||||
|
function downloadPDF() {
|
||||||
|
showToast('Đang tải xuống hóa đơn PDF...', 'success');
|
||||||
|
|
||||||
|
// Simulate PDF download
|
||||||
|
setTimeout(() => {
|
||||||
|
showToast('Hóa đơn đã được tải xuống thành công!', 'success');
|
||||||
|
|
||||||
|
// In a real app, this would trigger actual PDF download
|
||||||
|
// window.location.href = '/api/invoices/INV20240001/download';
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send Email function
|
||||||
|
function sendEmail() {
|
||||||
|
showToast('Đang gửi hóa đơn qua email...', 'success');
|
||||||
|
|
||||||
|
// Simulate email sending
|
||||||
|
setTimeout(() => {
|
||||||
|
showToast('Hóa đơn đã được gửi đến email: minhlong.org@gmail.com', 'success');
|
||||||
|
|
||||||
|
// In a real app, this would call API to send email
|
||||||
|
// fetch('/api/invoices/INV20240001/send-email', { method: 'POST' })
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Share invoice function
|
||||||
|
function shareInvoice() {
|
||||||
|
if (navigator.share) {
|
||||||
|
navigator.share({
|
||||||
|
title: 'Hóa đơn #INV20240001',
|
||||||
|
text: 'Chi tiết hóa đơn EuroTile',
|
||||||
|
url: window.location.href
|
||||||
|
}).catch(err => console.log('Error sharing:', err));
|
||||||
|
} else {
|
||||||
|
// Fallback to copy link
|
||||||
|
navigator.clipboard.writeText(window.location.href);
|
||||||
|
showToast('Đã sao chép link hóa đơn!', 'success');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get invoice ID from URL parameter
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const invoiceId = urlParams.get('id') || 'INV20240001';
|
||||||
|
|
||||||
|
// Update page with invoice ID (in real app, would fetch from API)
|
||||||
|
document.title = `Chi tiết Hóa đơn #${invoiceId} - EuroTile Worker`;
|
||||||
|
document.querySelector('.invoice-number').textContent = `#${invoiceId}`;
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
351
html/invoice-list.html
Normal file
351
html/invoice-list.html
Normal file
@@ -0,0 +1,351 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="vi">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Hóa đơn đã mua - EuroTile Worker</title>
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
<link rel="stylesheet" href="assets/css/style.css">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||||
|
<style>
|
||||||
|
.invoices-container {
|
||||||
|
max-width: 480px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background: #f8fafc;
|
||||||
|
min-height: calc(100vh - 120px);
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-card {
|
||||||
|
background: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 16px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-card:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 16px rgba(0,0,0,0.12);
|
||||||
|
border-color: #2563eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-codes {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-id {
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1f2937;
|
||||||
|
font-size: 16px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-date {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-status {
|
||||||
|
padding: 6px 12px;
|
||||||
|
border-radius: 20px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-paid {
|
||||||
|
background: #d1fae5;
|
||||||
|
color: #065f46;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-unpaid {
|
||||||
|
background: #fef3c7;
|
||||||
|
color: #d97706;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-partial {
|
||||||
|
background: #e0e7ff;
|
||||||
|
color: #3730a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-details {
|
||||||
|
padding: 12px 0;
|
||||||
|
border-top: 1px solid #f3f4f6;
|
||||||
|
border-bottom: 1px solid #f3f4f6;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-detail-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-detail-row:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-detail-label {
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-detail-value {
|
||||||
|
color: #1f2937;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-detail-value.total {
|
||||||
|
color: #dc2626;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-company {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b7280;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-arrow {
|
||||||
|
color: #9ca3af;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
text-align: center;
|
||||||
|
padding: 80px 20px;
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state i {
|
||||||
|
font-size: 64px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
color: #d1d5db;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state h3 {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #374151;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state p {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.invoices-container {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-card {
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="page-wrapper">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="header">
|
||||||
|
<a href="account.html" class="back-button">
|
||||||
|
<i class="fas fa-arrow-left"></i>
|
||||||
|
</a>
|
||||||
|
<h1 class="header-title">Hóa đơn đã mua</h1>
|
||||||
|
<div style="width: 32px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="invoices-container">
|
||||||
|
<!-- Invoice Card 1 - Paid -->
|
||||||
|
<div class="invoice-card" onclick="window.location.href='invoice-detail.html?id=INV20240001'">
|
||||||
|
<div class="invoice-header">
|
||||||
|
<div class="invoice-codes">
|
||||||
|
<div class="invoice-id">#INV20240001</div>
|
||||||
|
<div class="invoice-date">Ngày xuất: 03/08/2024</div>
|
||||||
|
</div>
|
||||||
|
<span class="invoice-status status-paid">Đã thanh toán</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="invoice-details">
|
||||||
|
<div class="invoice-detail-row">
|
||||||
|
<span class="invoice-detail-label">Đơn hàng:</span>
|
||||||
|
<span class="invoice-detail-value">#DH001234</span>
|
||||||
|
</div>
|
||||||
|
<div class="invoice-detail-row">
|
||||||
|
<span class="invoice-detail-label">Tổng tiền:</span>
|
||||||
|
<span class="invoice-detail-value total">12.771.000đ</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<div class="invoice-footer">
|
||||||
|
<div class="invoice-company">
|
||||||
|
<i class="fas fa-building"></i>
|
||||||
|
<span>Lê Hoàng Hiệp</span>
|
||||||
|
</div>
|
||||||
|
<i class="fas fa-chevron-right invoice-arrow"></i>
|
||||||
|
</div>-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Invoice Card 2 - Partial -->
|
||||||
|
<div class="invoice-card" onclick="window.location.href='invoice-detail.html?id=INV20240002'">
|
||||||
|
<div class="invoice-header">
|
||||||
|
<div class="invoice-codes">
|
||||||
|
<div class="invoice-id">#INV20240002</div>
|
||||||
|
<div class="invoice-date">Ngày xuất: 15/07/2024</div>
|
||||||
|
</div>
|
||||||
|
<span class="invoice-status status-partial">Thanh toán 1 phần</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="invoice-details">
|
||||||
|
<div class="invoice-detail-row">
|
||||||
|
<span class="invoice-detail-label">Đơn hàng:</span>
|
||||||
|
<span class="invoice-detail-value">#DH001198</span>
|
||||||
|
</div>
|
||||||
|
<div class="invoice-detail-row">
|
||||||
|
<span class="invoice-detail-label">Tổng tiền:</span>
|
||||||
|
<span class="invoice-detail-value total">85.600.000đ</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<div class="invoice-footer">
|
||||||
|
<div class="invoice-company">
|
||||||
|
<i class="fas fa-building"></i>
|
||||||
|
<span>Công ty TNHH Xây dựng Minh Long</span>
|
||||||
|
</div>
|
||||||
|
<i class="fas fa-chevron-right invoice-arrow"></i>
|
||||||
|
</div>-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Invoice Card 3 - Paid -->
|
||||||
|
<div class="invoice-card" onclick="window.location.href='invoice-detail.html?id=INV20240003'">
|
||||||
|
<div class="invoice-header">
|
||||||
|
<div class="invoice-codes">
|
||||||
|
<div class="invoice-id">#INV20240003</div>
|
||||||
|
<div class="invoice-date">Ngày xuất: 25/06/2024</div>
|
||||||
|
</div>
|
||||||
|
<span class="invoice-status status-paid">Đã thanh toán</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="invoice-details">
|
||||||
|
<div class="invoice-detail-row">
|
||||||
|
<span class="invoice-detail-label">Đơn hàng:</span>
|
||||||
|
<span class="invoice-detail-value">#DH001087</span>
|
||||||
|
</div>
|
||||||
|
<div class="invoice-detail-row">
|
||||||
|
<span class="invoice-detail-label">Tổng tiền:</span>
|
||||||
|
<span class="invoice-detail-value total">42.500.000đ</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<div class="invoice-footer">
|
||||||
|
<div class="invoice-company">
|
||||||
|
<i class="fas fa-building"></i>
|
||||||
|
<span>Công ty TNHH Xây dựng Minh Long</span>
|
||||||
|
</div>
|
||||||
|
<i class="fas fa-chevron-right invoice-arrow"></i>
|
||||||
|
</div>-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Invoice Card 4 - Unpaid -->
|
||||||
|
<div class="invoice-card" onclick="window.location.href='invoice-detail.html?id=INV20240004'">
|
||||||
|
<div class="invoice-header">
|
||||||
|
<div class="invoice-codes">
|
||||||
|
<div class="invoice-id">#INV20240004</div>
|
||||||
|
<div class="invoice-date">Ngày xuất: 10/06/2024</div>
|
||||||
|
</div>
|
||||||
|
<span class="invoice-status status-unpaid">Chưa thanh toán</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="invoice-details">
|
||||||
|
<div class="invoice-detail-row">
|
||||||
|
<span class="invoice-detail-label">Đơn hàng:</span>
|
||||||
|
<span class="invoice-detail-value">#DH000945</span>
|
||||||
|
</div>
|
||||||
|
<div class="invoice-detail-row">
|
||||||
|
<span class="invoice-detail-label">Tổng tiền:</span>
|
||||||
|
<span class="invoice-detail-value total">28.300.000đ</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<div class="invoice-footer">
|
||||||
|
<div class="invoice-company">
|
||||||
|
<i class="fas fa-building"></i>
|
||||||
|
<span>Công ty TNHH Xây dựng Minh Long</span>
|
||||||
|
</div>
|
||||||
|
<i class="fas fa-chevron-right invoice-arrow"></i>
|
||||||
|
</div>-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Invoice Card 5 - Paid -->
|
||||||
|
<div class="invoice-card" onclick="window.location.href='invoice-detail.html?id=INV20240005'">
|
||||||
|
<div class="invoice-header">
|
||||||
|
<div class="invoice-codes">
|
||||||
|
<div class="invoice-id">#INV20240005</div>
|
||||||
|
<div class="invoice-date">Ngày xuất: 15/05/2024</div>
|
||||||
|
</div>
|
||||||
|
<span class="invoice-status status-paid">Đã thanh toán</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="invoice-details">
|
||||||
|
<div class="invoice-detail-row">
|
||||||
|
<span class="invoice-detail-label">Đơn hàng:</span>
|
||||||
|
<span class="invoice-detail-value">#DH000821</span>
|
||||||
|
</div>
|
||||||
|
<div class="invoice-detail-row">
|
||||||
|
<span class="invoice-detail-label">Tổng tiền:</span>
|
||||||
|
<span class="invoice-detail-value total">56.750.000đ</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<div class="invoice-footer">
|
||||||
|
<div class="invoice-company">
|
||||||
|
<i class="fas fa-building"></i>
|
||||||
|
<span>Công ty TNHH Xây dựng Minh Long</span>
|
||||||
|
</div>
|
||||||
|
<i class="fas fa-chevron-right invoice-arrow"></i>
|
||||||
|
</div>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Add animation to cards on page load
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const cards = document.querySelectorAll('.invoice-card');
|
||||||
|
cards.forEach((card, index) => {
|
||||||
|
card.style.opacity = '0';
|
||||||
|
card.style.transform = 'translateY(20px)';
|
||||||
|
card.style.transition = 'all 0.5s ease';
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
card.style.opacity = '1';
|
||||||
|
card.style.transform = 'translateY(0)';
|
||||||
|
}, index * 100);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -283,6 +283,18 @@ class ApiConstants {
|
|||||||
static const String getPaymentDetail =
|
static const String getPaymentDetail =
|
||||||
'/building_material.building_material.api.payment.get_detail';
|
'/building_material.building_material.api.payment.get_detail';
|
||||||
|
|
||||||
|
/// Get invoice list (Frappe API)
|
||||||
|
/// POST /api/method/building_material.building_material.api.invoice.get_list
|
||||||
|
/// Body: { "limit_start": 0, "limit_page_length": 0 }
|
||||||
|
static const String getInvoiceList =
|
||||||
|
'/building_material.building_material.api.invoice.get_list';
|
||||||
|
|
||||||
|
/// Get invoice detail (Frappe API)
|
||||||
|
/// POST /api/method/building_material.building_material.api.invoice.get_detail
|
||||||
|
/// Body: { "name": "ACC-SINV-2025-00041" }
|
||||||
|
static const String getInvoiceDetail =
|
||||||
|
'/building_material.building_material.api.invoice.get_detail';
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Project Endpoints (Frappe ERPNext)
|
// Project Endpoints (Frappe ERPNext)
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ import 'package:worker/features/showrooms/presentation/pages/design_request_deta
|
|||||||
import 'package:worker/features/showrooms/presentation/pages/model_house_detail_page.dart';
|
import 'package:worker/features/showrooms/presentation/pages/model_house_detail_page.dart';
|
||||||
import 'package:worker/features/showrooms/presentation/pages/model_houses_page.dart';
|
import 'package:worker/features/showrooms/presentation/pages/model_houses_page.dart';
|
||||||
import 'package:worker/features/account/presentation/pages/theme_settings_page.dart';
|
import 'package:worker/features/account/presentation/pages/theme_settings_page.dart';
|
||||||
|
import 'package:worker/features/invoices/presentation/pages/invoices_page.dart';
|
||||||
|
import 'package:worker/features/invoices/presentation/pages/invoice_detail_page.dart';
|
||||||
|
|
||||||
/// Router Provider
|
/// Router Provider
|
||||||
///
|
///
|
||||||
@@ -488,6 +490,27 @@ final routerProvider = Provider<GoRouter>((ref) {
|
|||||||
MaterialPage(key: state.pageKey, child: const ThemeSettingsPage()),
|
MaterialPage(key: state.pageKey, child: const ThemeSettingsPage()),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Invoices Route
|
||||||
|
GoRoute(
|
||||||
|
path: RouteNames.invoices,
|
||||||
|
name: RouteNames.invoices,
|
||||||
|
pageBuilder: (context, state) =>
|
||||||
|
MaterialPage(key: state.pageKey, child: const InvoicesPage()),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Invoice Detail Route
|
||||||
|
GoRoute(
|
||||||
|
path: RouteNames.invoiceDetail,
|
||||||
|
name: RouteNames.invoiceDetail,
|
||||||
|
pageBuilder: (context, state) {
|
||||||
|
final invoiceId = state.pathParameters['id'];
|
||||||
|
return MaterialPage(
|
||||||
|
key: state.pageKey,
|
||||||
|
child: InvoiceDetailPage(invoiceId: invoiceId ?? ''),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
// Chat List Route
|
// Chat List Route
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: RouteNames.chat,
|
path: RouteNames.chat,
|
||||||
@@ -638,6 +661,10 @@ class RouteNames {
|
|||||||
static const String themeSettings = '$account/theme-settings';
|
static const String themeSettings = '$account/theme-settings';
|
||||||
static const String settings = '$account/settings';
|
static const String settings = '$account/settings';
|
||||||
|
|
||||||
|
// Invoice Routes
|
||||||
|
static const String invoices = '/invoices';
|
||||||
|
static const String invoiceDetail = '$invoices/:id';
|
||||||
|
|
||||||
// Promotions & Notifications Routes
|
// Promotions & Notifications Routes
|
||||||
static const String promotions = '/promotions';
|
static const String promotions = '/promotions';
|
||||||
static const String promotionDetail = '$promotions/:id';
|
static const String promotionDetail = '$promotions/:id';
|
||||||
|
|||||||
@@ -140,6 +140,14 @@ class AccountPage extends ConsumerWidget {
|
|||||||
context.push(RouteNames.orders);
|
context.push(RouteNames.orders);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
AccountMenuItem(
|
||||||
|
icon: FontAwesomeIcons.fileInvoiceDollar,
|
||||||
|
title: 'Hóa đơn đã mua',
|
||||||
|
subtitle: 'Xem các hóa đơn đã xuất',
|
||||||
|
onTap: () {
|
||||||
|
context.push(RouteNames.invoices);
|
||||||
|
},
|
||||||
|
),
|
||||||
AccountMenuItem(
|
AccountMenuItem(
|
||||||
icon: FontAwesomeIcons.locationDot,
|
icon: FontAwesomeIcons.locationDot,
|
||||||
title: 'Địa chỉ đã lưu',
|
title: 'Địa chỉ đã lưu',
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/// Invoice Remote Data Source
|
||||||
|
///
|
||||||
|
/// Handles API calls for invoice-related data.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:worker/core/constants/api_constants.dart';
|
||||||
|
import 'package:worker/core/network/dio_client.dart';
|
||||||
|
import 'package:worker/features/invoices/data/models/invoice_model.dart';
|
||||||
|
|
||||||
|
/// Invoice Remote Data Source
|
||||||
|
class InvoiceRemoteDataSource {
|
||||||
|
const InvoiceRemoteDataSource(this._dioClient);
|
||||||
|
|
||||||
|
final DioClient _dioClient;
|
||||||
|
|
||||||
|
/// Get invoices list
|
||||||
|
///
|
||||||
|
/// Calls: POST /api/method/building_material.building_material.api.invoice.get_list
|
||||||
|
/// Returns: List of invoices
|
||||||
|
Future<List<InvoiceModel>> getInvoicesList({
|
||||||
|
int limitStart = 0,
|
||||||
|
int limitPageLength = 0,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final response = await _dioClient.post<Map<String, dynamic>>(
|
||||||
|
'${ApiConstants.frappeApiMethod}${ApiConstants.getInvoiceList}',
|
||||||
|
data: {
|
||||||
|
'limit_start': limitStart,
|
||||||
|
'limit_page_length': limitPageLength,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
final data = response.data;
|
||||||
|
if (data == null) {
|
||||||
|
throw Exception('No data received from getInvoicesList API');
|
||||||
|
}
|
||||||
|
|
||||||
|
// API returns: { "message": [...] }
|
||||||
|
final message = data['message'];
|
||||||
|
if (message == null) {
|
||||||
|
throw Exception('No message field in getInvoicesList response');
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<dynamic> invoicesList = message as List<dynamic>;
|
||||||
|
return invoicesList
|
||||||
|
.map((json) => InvoiceModel.fromJson(json as Map<String, dynamic>))
|
||||||
|
.toList();
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to get invoices list: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get invoice detail
|
||||||
|
///
|
||||||
|
/// Calls: POST /api/method/building_material.building_material.api.invoice.get_detail
|
||||||
|
/// Returns: Invoice detail
|
||||||
|
Future<InvoiceModel> getInvoiceDetail(String name) async {
|
||||||
|
try {
|
||||||
|
final response = await _dioClient.post<Map<String, dynamic>>(
|
||||||
|
'${ApiConstants.frappeApiMethod}${ApiConstants.getInvoiceDetail}',
|
||||||
|
data: {'name': name},
|
||||||
|
);
|
||||||
|
|
||||||
|
final data = response.data;
|
||||||
|
if (data == null) {
|
||||||
|
throw Exception('No data received from getInvoiceDetail API');
|
||||||
|
}
|
||||||
|
|
||||||
|
// API returns: { "message": {...} }
|
||||||
|
final message = data['message'];
|
||||||
|
if (message == null) {
|
||||||
|
throw Exception('No message field in getInvoiceDetail response');
|
||||||
|
}
|
||||||
|
|
||||||
|
return InvoiceModel.fromJson(message as Map<String, dynamic>);
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to get invoice detail: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
306
lib/features/invoices/data/models/invoice_model.dart
Normal file
306
lib/features/invoices/data/models/invoice_model.dart
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
/// Data Model: Invoice Model
|
||||||
|
///
|
||||||
|
/// Model for invoice data with API serialization.
|
||||||
|
/// Not stored in local database.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:worker/features/invoices/domain/entities/invoice.dart';
|
||||||
|
|
||||||
|
/// Seller Info Model
|
||||||
|
class SellerInfoModel {
|
||||||
|
final String? phone;
|
||||||
|
final String? email;
|
||||||
|
final String? fax;
|
||||||
|
final String? taxCode;
|
||||||
|
final String? companyName;
|
||||||
|
final String? addressLine1;
|
||||||
|
final String? cityCode;
|
||||||
|
final String? wardCode;
|
||||||
|
final String? cityName;
|
||||||
|
final String? wardName;
|
||||||
|
|
||||||
|
const SellerInfoModel({
|
||||||
|
this.phone,
|
||||||
|
this.email,
|
||||||
|
this.fax,
|
||||||
|
this.taxCode,
|
||||||
|
this.companyName,
|
||||||
|
this.addressLine1,
|
||||||
|
this.cityCode,
|
||||||
|
this.wardCode,
|
||||||
|
this.cityName,
|
||||||
|
this.wardName,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory SellerInfoModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
return SellerInfoModel(
|
||||||
|
phone: json['phone'] as String?,
|
||||||
|
email: json['email'] as String?,
|
||||||
|
fax: json['fax'] as String?,
|
||||||
|
taxCode: json['tax_code'] as String?,
|
||||||
|
companyName: json['company_name'] as String?,
|
||||||
|
addressLine1: json['address_line1'] as String?,
|
||||||
|
cityCode: json['city_code'] as String?,
|
||||||
|
wardCode: json['ward_code'] as String?,
|
||||||
|
cityName: json['city_name'] as String?,
|
||||||
|
wardName: json['ward_name'] as String?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'phone': phone,
|
||||||
|
'email': email,
|
||||||
|
'fax': fax,
|
||||||
|
'tax_code': taxCode,
|
||||||
|
'company_name': companyName,
|
||||||
|
'address_line1': addressLine1,
|
||||||
|
'city_code': cityCode,
|
||||||
|
'ward_code': wardCode,
|
||||||
|
'city_name': cityName,
|
||||||
|
'ward_name': wardName,
|
||||||
|
};
|
||||||
|
|
||||||
|
SellerInfo toEntity() => SellerInfo(
|
||||||
|
phone: phone,
|
||||||
|
email: email,
|
||||||
|
fax: fax,
|
||||||
|
taxCode: taxCode,
|
||||||
|
companyName: companyName,
|
||||||
|
addressLine1: addressLine1,
|
||||||
|
cityCode: cityCode,
|
||||||
|
wardCode: wardCode,
|
||||||
|
cityName: cityName,
|
||||||
|
wardName: wardName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Buyer Info Model
|
||||||
|
class BuyerInfoModel {
|
||||||
|
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 String? cityName;
|
||||||
|
final String? wardName;
|
||||||
|
|
||||||
|
const BuyerInfoModel({
|
||||||
|
this.name,
|
||||||
|
this.addressTitle,
|
||||||
|
this.addressLine1,
|
||||||
|
this.phone,
|
||||||
|
this.email,
|
||||||
|
this.fax,
|
||||||
|
this.taxCode,
|
||||||
|
this.cityCode,
|
||||||
|
this.wardCode,
|
||||||
|
this.cityName,
|
||||||
|
this.wardName,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory BuyerInfoModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
return BuyerInfoModel(
|
||||||
|
name: json['name'] as String?,
|
||||||
|
addressTitle: json['address_title'] as String?,
|
||||||
|
addressLine1: json['address_line1'] as String?,
|
||||||
|
phone: json['phone'] as String?,
|
||||||
|
email: json['email'] as String?,
|
||||||
|
fax: json['fax'] as String?,
|
||||||
|
taxCode: json['tax_code'] as String?,
|
||||||
|
cityCode: json['city_code'] as String?,
|
||||||
|
wardCode: json['ward_code'] as String?,
|
||||||
|
cityName: json['city_name'] as String?,
|
||||||
|
wardName: json['ward_name'] as String?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'name': name,
|
||||||
|
'address_title': addressTitle,
|
||||||
|
'address_line1': addressLine1,
|
||||||
|
'phone': phone,
|
||||||
|
'email': email,
|
||||||
|
'fax': fax,
|
||||||
|
'tax_code': taxCode,
|
||||||
|
'city_code': cityCode,
|
||||||
|
'ward_code': wardCode,
|
||||||
|
'city_name': cityName,
|
||||||
|
'ward_name': wardName,
|
||||||
|
};
|
||||||
|
|
||||||
|
BuyerInfo toEntity() => BuyerInfo(
|
||||||
|
name: name,
|
||||||
|
addressTitle: addressTitle,
|
||||||
|
addressLine1: addressLine1,
|
||||||
|
phone: phone,
|
||||||
|
email: email,
|
||||||
|
fax: fax,
|
||||||
|
taxCode: taxCode,
|
||||||
|
cityCode: cityCode,
|
||||||
|
wardCode: wardCode,
|
||||||
|
cityName: cityName,
|
||||||
|
wardName: wardName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Invoice Item Model
|
||||||
|
class InvoiceItemModel {
|
||||||
|
final String itemName;
|
||||||
|
final String itemCode;
|
||||||
|
final double qty;
|
||||||
|
final double rate;
|
||||||
|
final double amount;
|
||||||
|
|
||||||
|
const InvoiceItemModel({
|
||||||
|
required this.itemName,
|
||||||
|
required this.itemCode,
|
||||||
|
required this.qty,
|
||||||
|
required this.rate,
|
||||||
|
required this.amount,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory InvoiceItemModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
return InvoiceItemModel(
|
||||||
|
itemName: json['item_name'] as String? ?? '',
|
||||||
|
itemCode: json['item_code'] as String? ?? '',
|
||||||
|
qty: (json['qty'] as num?)?.toDouble() ?? 0.0,
|
||||||
|
rate: (json['rate'] as num?)?.toDouble() ?? 0.0,
|
||||||
|
amount: (json['amount'] as num?)?.toDouble() ?? 0.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'item_name': itemName,
|
||||||
|
'item_code': itemCode,
|
||||||
|
'qty': qty,
|
||||||
|
'rate': rate,
|
||||||
|
'amount': amount,
|
||||||
|
};
|
||||||
|
|
||||||
|
InvoiceItem toEntity() => InvoiceItem(
|
||||||
|
itemName: itemName,
|
||||||
|
itemCode: itemCode,
|
||||||
|
qty: qty,
|
||||||
|
rate: rate,
|
||||||
|
amount: amount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Invoice Model
|
||||||
|
///
|
||||||
|
/// Model for API parsing only (no Hive storage).
|
||||||
|
class InvoiceModel {
|
||||||
|
final String name;
|
||||||
|
final String postingDate;
|
||||||
|
final String status;
|
||||||
|
final String statusColor;
|
||||||
|
final String? orderId;
|
||||||
|
final double grandTotal;
|
||||||
|
|
||||||
|
// Detail-only fields
|
||||||
|
final String? customerName;
|
||||||
|
final SellerInfoModel? sellerInfo;
|
||||||
|
final BuyerInfoModel? buyerInfo;
|
||||||
|
final List<InvoiceItemModel>? items;
|
||||||
|
final double? total;
|
||||||
|
final double? discountAmount;
|
||||||
|
|
||||||
|
const InvoiceModel({
|
||||||
|
required this.name,
|
||||||
|
required this.postingDate,
|
||||||
|
required this.status,
|
||||||
|
required this.statusColor,
|
||||||
|
this.orderId,
|
||||||
|
required this.grandTotal,
|
||||||
|
this.customerName,
|
||||||
|
this.sellerInfo,
|
||||||
|
this.buyerInfo,
|
||||||
|
this.items,
|
||||||
|
this.total,
|
||||||
|
this.discountAmount,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Create from JSON (API response - list item)
|
||||||
|
factory InvoiceModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
return InvoiceModel(
|
||||||
|
name: json['name'] as String? ?? '',
|
||||||
|
postingDate: json['posting_date'] as String? ?? '',
|
||||||
|
status: json['status'] as String? ?? '',
|
||||||
|
statusColor: json['status_color'] as String? ?? 'Secondary',
|
||||||
|
orderId: json['order_id'] as String?,
|
||||||
|
grandTotal: (json['grand_total'] as num?)?.toDouble() ?? 0.0,
|
||||||
|
customerName: json['customer_name'] as String?,
|
||||||
|
sellerInfo: json['seller_info'] != null
|
||||||
|
? SellerInfoModel.fromJson(json['seller_info'] as Map<String, dynamic>)
|
||||||
|
: null,
|
||||||
|
buyerInfo: json['buyer_info'] != null
|
||||||
|
? BuyerInfoModel.fromJson(json['buyer_info'] as Map<String, dynamic>)
|
||||||
|
: null,
|
||||||
|
items: json['items'] != null
|
||||||
|
? (json['items'] as List<dynamic>)
|
||||||
|
.map((e) => InvoiceItemModel.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList()
|
||||||
|
: null,
|
||||||
|
total: (json['total'] as num?)?.toDouble(),
|
||||||
|
discountAmount: (json['discount_amount'] as num?)?.toDouble(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convert to JSON
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'name': name,
|
||||||
|
'posting_date': postingDate,
|
||||||
|
'status': status,
|
||||||
|
'status_color': statusColor,
|
||||||
|
'order_id': orderId,
|
||||||
|
'grand_total': grandTotal,
|
||||||
|
'customer_name': customerName,
|
||||||
|
'seller_info': sellerInfo?.toJson(),
|
||||||
|
'buyer_info': buyerInfo?.toJson(),
|
||||||
|
'items': items?.map((e) => e.toJson()).toList(),
|
||||||
|
'total': total,
|
||||||
|
'discount_amount': discountAmount,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Convert to domain entity
|
||||||
|
Invoice toEntity() {
|
||||||
|
return Invoice(
|
||||||
|
name: name,
|
||||||
|
postingDate: DateTime.tryParse(postingDate) ?? DateTime.now(),
|
||||||
|
status: status,
|
||||||
|
statusColor: statusColor,
|
||||||
|
orderId: orderId,
|
||||||
|
grandTotal: grandTotal,
|
||||||
|
customerName: customerName,
|
||||||
|
sellerInfo: sellerInfo?.toEntity(),
|
||||||
|
buyerInfo: buyerInfo?.toEntity(),
|
||||||
|
items: items?.map((e) => e.toEntity()).toList(),
|
||||||
|
total: total,
|
||||||
|
discountAmount: discountAmount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create from domain entity
|
||||||
|
factory InvoiceModel.fromEntity(Invoice entity) {
|
||||||
|
return InvoiceModel(
|
||||||
|
name: entity.name,
|
||||||
|
postingDate: entity.postingDate.toIso8601String().split('T').first,
|
||||||
|
status: entity.status,
|
||||||
|
statusColor: entity.statusColor,
|
||||||
|
orderId: entity.orderId,
|
||||||
|
grandTotal: entity.grandTotal,
|
||||||
|
customerName: entity.customerName,
|
||||||
|
total: entity.total,
|
||||||
|
discountAmount: entity.discountAmount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'InvoiceModel(name: $name, status: $status, grandTotal: $grandTotal)';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/// Invoice Repository Implementation
|
||||||
|
///
|
||||||
|
/// Implements the invoice repository interface.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:worker/features/invoices/data/datasources/invoice_remote_datasource.dart';
|
||||||
|
import 'package:worker/features/invoices/domain/entities/invoice.dart';
|
||||||
|
import 'package:worker/features/invoices/domain/repositories/invoice_repository.dart';
|
||||||
|
|
||||||
|
/// Invoice Repository Implementation
|
||||||
|
class InvoiceRepositoryImpl implements InvoiceRepository {
|
||||||
|
const InvoiceRepositoryImpl(this._remoteDataSource);
|
||||||
|
|
||||||
|
final InvoiceRemoteDataSource _remoteDataSource;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Invoice>> getInvoicesList({
|
||||||
|
int limitStart = 0,
|
||||||
|
int limitPageLength = 0,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final invoicesData = await _remoteDataSource.getInvoicesList(
|
||||||
|
limitStart: limitStart,
|
||||||
|
limitPageLength: limitPageLength,
|
||||||
|
);
|
||||||
|
// Convert Model → Entity
|
||||||
|
return invoicesData.map((model) => model.toEntity()).toList();
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to get invoices list: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Invoice> getInvoiceDetail(String name) async {
|
||||||
|
try {
|
||||||
|
final invoiceData = await _remoteDataSource.getInvoiceDetail(name);
|
||||||
|
// Convert Model → Entity
|
||||||
|
return invoiceData.toEntity();
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to get invoice detail: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
272
lib/features/invoices/domain/entities/invoice.dart
Normal file
272
lib/features/invoices/domain/entities/invoice.dart
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
/// Domain Entity: Invoice
|
||||||
|
///
|
||||||
|
/// Represents an invoice from the API.
|
||||||
|
/// Used for both list and detail views.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
|
/// Seller/Company Information
|
||||||
|
class SellerInfo extends Equatable {
|
||||||
|
final String? phone;
|
||||||
|
final String? email;
|
||||||
|
final String? fax;
|
||||||
|
final String? taxCode;
|
||||||
|
final String? companyName;
|
||||||
|
final String? addressLine1;
|
||||||
|
final String? cityCode;
|
||||||
|
final String? wardCode;
|
||||||
|
final String? cityName;
|
||||||
|
final String? wardName;
|
||||||
|
|
||||||
|
const SellerInfo({
|
||||||
|
this.phone,
|
||||||
|
this.email,
|
||||||
|
this.fax,
|
||||||
|
this.taxCode,
|
||||||
|
this.companyName,
|
||||||
|
this.addressLine1,
|
||||||
|
this.cityCode,
|
||||||
|
this.wardCode,
|
||||||
|
this.cityName,
|
||||||
|
this.wardName,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Get formatted full address
|
||||||
|
String get fullAddress {
|
||||||
|
final parts = <String>[];
|
||||||
|
if (addressLine1 != null && addressLine1!.isNotEmpty) {
|
||||||
|
parts.add(addressLine1!);
|
||||||
|
}
|
||||||
|
if (wardName != null && wardName!.isNotEmpty) {
|
||||||
|
parts.add(wardName!);
|
||||||
|
}
|
||||||
|
if (cityName != null && cityName!.isNotEmpty) {
|
||||||
|
parts.add(cityName!);
|
||||||
|
}
|
||||||
|
return parts.join(', ');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [
|
||||||
|
phone,
|
||||||
|
email,
|
||||||
|
fax,
|
||||||
|
taxCode,
|
||||||
|
companyName,
|
||||||
|
addressLine1,
|
||||||
|
cityCode,
|
||||||
|
wardCode,
|
||||||
|
cityName,
|
||||||
|
wardName,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Buyer/Customer Information
|
||||||
|
class BuyerInfo 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 String? cityName;
|
||||||
|
final String? wardName;
|
||||||
|
|
||||||
|
const BuyerInfo({
|
||||||
|
this.name,
|
||||||
|
this.addressTitle,
|
||||||
|
this.addressLine1,
|
||||||
|
this.phone,
|
||||||
|
this.email,
|
||||||
|
this.fax,
|
||||||
|
this.taxCode,
|
||||||
|
this.cityCode,
|
||||||
|
this.wardCode,
|
||||||
|
this.cityName,
|
||||||
|
this.wardName,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Get formatted full address
|
||||||
|
String get fullAddress {
|
||||||
|
final parts = <String>[];
|
||||||
|
if (addressLine1 != null && addressLine1!.isNotEmpty) {
|
||||||
|
parts.add(addressLine1!);
|
||||||
|
}
|
||||||
|
if (wardName != null && wardName!.isNotEmpty) {
|
||||||
|
parts.add(wardName!);
|
||||||
|
}
|
||||||
|
if (cityName != null && cityName!.isNotEmpty) {
|
||||||
|
parts.add(cityName!);
|
||||||
|
}
|
||||||
|
return parts.join(', ');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [
|
||||||
|
name,
|
||||||
|
addressTitle,
|
||||||
|
addressLine1,
|
||||||
|
phone,
|
||||||
|
email,
|
||||||
|
fax,
|
||||||
|
taxCode,
|
||||||
|
cityCode,
|
||||||
|
wardCode,
|
||||||
|
cityName,
|
||||||
|
wardName,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Invoice Line Item
|
||||||
|
class InvoiceItem extends Equatable {
|
||||||
|
final String itemName;
|
||||||
|
final String itemCode;
|
||||||
|
final double qty;
|
||||||
|
final double rate;
|
||||||
|
final double amount;
|
||||||
|
|
||||||
|
const InvoiceItem({
|
||||||
|
required this.itemName,
|
||||||
|
required this.itemCode,
|
||||||
|
required this.qty,
|
||||||
|
required this.rate,
|
||||||
|
required this.amount,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [itemName, itemCode, qty, rate, amount];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Invoice Entity
|
||||||
|
///
|
||||||
|
/// Contains invoice information from API:
|
||||||
|
/// - name: Invoice ID (e.g., "ACC-SINV-2025-00041")
|
||||||
|
/// - postingDate: Invoice date
|
||||||
|
/// - status: Status label (Vietnamese)
|
||||||
|
/// - statusColor: Status color (Danger, Success, etc.)
|
||||||
|
/// - orderId: Related order ID (nullable)
|
||||||
|
/// - grandTotal: Total amount
|
||||||
|
/// - customerName: Customer name (detail only)
|
||||||
|
/// - sellerInfo: Seller company info (detail only)
|
||||||
|
/// - buyerInfo: Buyer info (detail only)
|
||||||
|
/// - items: Invoice line items (detail only)
|
||||||
|
/// - total: Subtotal before discount (detail only)
|
||||||
|
/// - discountAmount: Discount amount (detail only)
|
||||||
|
class Invoice extends Equatable {
|
||||||
|
/// Invoice ID (e.g., "ACC-SINV-2025-00041")
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
/// Invoice posting date
|
||||||
|
final DateTime postingDate;
|
||||||
|
|
||||||
|
/// Status label (Vietnamese)
|
||||||
|
final String status;
|
||||||
|
|
||||||
|
/// Status color (Danger, Success, Warning, etc.)
|
||||||
|
final String statusColor;
|
||||||
|
|
||||||
|
/// Related order ID (nullable)
|
||||||
|
final String? orderId;
|
||||||
|
|
||||||
|
/// Grand total amount
|
||||||
|
final double grandTotal;
|
||||||
|
|
||||||
|
// Detail-only fields (nullable for list view)
|
||||||
|
|
||||||
|
/// Customer name
|
||||||
|
final String? customerName;
|
||||||
|
|
||||||
|
/// Seller company information
|
||||||
|
final SellerInfo? sellerInfo;
|
||||||
|
|
||||||
|
/// Buyer information
|
||||||
|
final BuyerInfo? buyerInfo;
|
||||||
|
|
||||||
|
/// Invoice line items
|
||||||
|
final List<InvoiceItem>? items;
|
||||||
|
|
||||||
|
/// Subtotal before discount
|
||||||
|
final double? total;
|
||||||
|
|
||||||
|
/// Discount amount
|
||||||
|
final double? discountAmount;
|
||||||
|
|
||||||
|
const Invoice({
|
||||||
|
required this.name,
|
||||||
|
required this.postingDate,
|
||||||
|
required this.status,
|
||||||
|
required this.statusColor,
|
||||||
|
this.orderId,
|
||||||
|
required this.grandTotal,
|
||||||
|
this.customerName,
|
||||||
|
this.sellerInfo,
|
||||||
|
this.buyerInfo,
|
||||||
|
this.items,
|
||||||
|
this.total,
|
||||||
|
this.discountAmount,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Check if this is a detail invoice (has all detail fields)
|
||||||
|
bool get isDetail => sellerInfo != null && buyerInfo != null && items != null;
|
||||||
|
|
||||||
|
/// Get formatted posting date
|
||||||
|
String get formattedDate {
|
||||||
|
return '${postingDate.day.toString().padLeft(2, '0')}/${postingDate.month.toString().padLeft(2, '0')}/${postingDate.year}';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Copy with method for immutability
|
||||||
|
Invoice copyWith({
|
||||||
|
String? name,
|
||||||
|
DateTime? postingDate,
|
||||||
|
String? status,
|
||||||
|
String? statusColor,
|
||||||
|
String? orderId,
|
||||||
|
double? grandTotal,
|
||||||
|
String? customerName,
|
||||||
|
SellerInfo? sellerInfo,
|
||||||
|
BuyerInfo? buyerInfo,
|
||||||
|
List<InvoiceItem>? items,
|
||||||
|
double? total,
|
||||||
|
double? discountAmount,
|
||||||
|
}) {
|
||||||
|
return Invoice(
|
||||||
|
name: name ?? this.name,
|
||||||
|
postingDate: postingDate ?? this.postingDate,
|
||||||
|
status: status ?? this.status,
|
||||||
|
statusColor: statusColor ?? this.statusColor,
|
||||||
|
orderId: orderId ?? this.orderId,
|
||||||
|
grandTotal: grandTotal ?? this.grandTotal,
|
||||||
|
customerName: customerName ?? this.customerName,
|
||||||
|
sellerInfo: sellerInfo ?? this.sellerInfo,
|
||||||
|
buyerInfo: buyerInfo ?? this.buyerInfo,
|
||||||
|
items: items ?? this.items,
|
||||||
|
total: total ?? this.total,
|
||||||
|
discountAmount: discountAmount ?? this.discountAmount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [
|
||||||
|
name,
|
||||||
|
postingDate,
|
||||||
|
status,
|
||||||
|
statusColor,
|
||||||
|
orderId,
|
||||||
|
grandTotal,
|
||||||
|
customerName,
|
||||||
|
sellerInfo,
|
||||||
|
buyerInfo,
|
||||||
|
items,
|
||||||
|
total,
|
||||||
|
discountAmount,
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Invoice(name: $name, status: $status, grandTotal: $grandTotal)';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/// Invoice Repository Interface
|
||||||
|
///
|
||||||
|
/// Defines the contract for invoice-related data operations.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:worker/features/invoices/domain/entities/invoice.dart';
|
||||||
|
|
||||||
|
/// Invoice Repository Interface
|
||||||
|
abstract class InvoiceRepository {
|
||||||
|
/// Get list of invoices
|
||||||
|
Future<List<Invoice>> getInvoicesList({
|
||||||
|
int limitStart = 0,
|
||||||
|
int limitPageLength = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Get invoice detail by ID
|
||||||
|
Future<Invoice> getInvoiceDetail(String name);
|
||||||
|
}
|
||||||
@@ -0,0 +1,921 @@
|
|||||||
|
/// Page: Invoice Detail Page
|
||||||
|
///
|
||||||
|
/// Displays invoice detail following html/invoice-detail.html design.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
import 'package:worker/core/constants/ui_constants.dart';
|
||||||
|
import 'package:worker/core/utils/extensions.dart';
|
||||||
|
import 'package:worker/features/invoices/domain/entities/invoice.dart';
|
||||||
|
import 'package:worker/features/invoices/presentation/providers/invoices_provider.dart';
|
||||||
|
|
||||||
|
/// Invoice Detail Page
|
||||||
|
///
|
||||||
|
/// Features:
|
||||||
|
/// - Invoice header with status
|
||||||
|
/// - Seller and buyer information (2-column grid)
|
||||||
|
/// - Product list table with unit price
|
||||||
|
/// - Invoice summary (total, discount, grand total)
|
||||||
|
/// - Share and contact support actions
|
||||||
|
class InvoiceDetailPage extends ConsumerWidget {
|
||||||
|
const InvoiceDetailPage({
|
||||||
|
super.key,
|
||||||
|
required this.invoiceId,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String invoiceId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final invoiceAsync = ref.watch(invoiceDetailProvider(invoiceId));
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: colorScheme.surfaceContainerLowest,
|
||||||
|
appBar: AppBar(
|
||||||
|
leading: IconButton(
|
||||||
|
icon: Icon(Icons.arrow_back, color: colorScheme.onSurface),
|
||||||
|
onPressed: () => context.pop(),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
'Chi tiết Hóa đơn',
|
||||||
|
style: TextStyle(
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
elevation: AppBarSpecs.elevation,
|
||||||
|
backgroundColor: colorScheme.surface,
|
||||||
|
centerTitle: false,
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: FaIcon(
|
||||||
|
FontAwesomeIcons.shareNodes,
|
||||||
|
size: 20,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
onPressed: () => _shareInvoice(context),
|
||||||
|
),
|
||||||
|
const SizedBox(width: AppSpacing.sm),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: invoiceAsync.when(
|
||||||
|
data: (invoice) => _buildContent(context, invoice),
|
||||||
|
loading: () => const Center(child: CircularProgressIndicator()),
|
||||||
|
error: (error, stack) => _buildErrorState(context, ref, error),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildContent(BuildContext context, Invoice invoice) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Invoice Header Card
|
||||||
|
_buildHeaderCard(context, invoice),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Products Section
|
||||||
|
_buildProductsCard(context, invoice),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Action Button
|
||||||
|
_buildActionButton(context),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build invoice header card
|
||||||
|
Widget _buildHeaderCard(BuildContext context, Invoice invoice) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.surface,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: colorScheme.outline.withValues(alpha: 0.1),
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: colorScheme.shadow.withValues(alpha: 0.08),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Invoice Header Section (centered)
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(bottom: 24),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(
|
||||||
|
color: colorScheme.outlineVariant,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Invoice Icon
|
||||||
|
Container(
|
||||||
|
width: 80,
|
||||||
|
height: 80,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
colors: [
|
||||||
|
colorScheme.primary,
|
||||||
|
colorScheme.primary.withValues(alpha: 0.8),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: const Center(
|
||||||
|
child: FaIcon(
|
||||||
|
FontAwesomeIcons.fileInvoiceDollar,
|
||||||
|
size: 32,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Title
|
||||||
|
Text(
|
||||||
|
'HÓA ĐƠN GTGT',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 28,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
|
// Invoice Number
|
||||||
|
Text(
|
||||||
|
'#${invoice.name}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
|
||||||
|
// Status Badge
|
||||||
|
_StatusBadge(
|
||||||
|
status: invoice.status,
|
||||||
|
statusColor: invoice.statusColor,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Invoice Meta Info
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
_MetaItem(label: 'Ngày xuất:', value: invoice.formattedDate),
|
||||||
|
if (invoice.orderId != null) ...[
|
||||||
|
const SizedBox(width: 32),
|
||||||
|
_MetaItem(label: 'Đơn hàng:', value: '#${invoice.orderId}'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Company Information Section (2-column grid)
|
||||||
|
if (invoice.sellerInfo != null || invoice.buyerInfo != null) ...[
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
_buildCompanyInfoSection(context, invoice),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build company info section (seller and buyer) - 2 column grid
|
||||||
|
Widget _buildCompanyInfoSection(BuildContext context, Invoice invoice) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
final isWideScreen = screenWidth > 600;
|
||||||
|
|
||||||
|
if (isWideScreen) {
|
||||||
|
// 2-column grid for wide screens
|
||||||
|
return Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Seller Info
|
||||||
|
if (invoice.sellerInfo != null)
|
||||||
|
Expanded(
|
||||||
|
child: _CompanyInfoBlock(
|
||||||
|
icon: FontAwesomeIcons.building,
|
||||||
|
iconColor: colorScheme.primary,
|
||||||
|
title: 'Đơn vị bán hàng',
|
||||||
|
lines: _buildSellerInfoLines(invoice),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
if (invoice.sellerInfo != null && invoice.buyerInfo != null)
|
||||||
|
const SizedBox(width: 24),
|
||||||
|
|
||||||
|
// Buyer Info
|
||||||
|
if (invoice.buyerInfo != null)
|
||||||
|
Expanded(
|
||||||
|
child: _CompanyInfoBlock(
|
||||||
|
icon: FontAwesomeIcons.userTie,
|
||||||
|
iconColor: Colors.green.shade600,
|
||||||
|
title: 'Đơn vị mua hàng',
|
||||||
|
lines: _buildBuyerInfoLines(invoice),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Single column for narrow screens
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
// Seller Info
|
||||||
|
if (invoice.sellerInfo != null)
|
||||||
|
_CompanyInfoBlock(
|
||||||
|
icon: FontAwesomeIcons.building,
|
||||||
|
iconColor: colorScheme.primary,
|
||||||
|
title: 'Đơn vị bán hàng',
|
||||||
|
lines: _buildSellerInfoLines(invoice),
|
||||||
|
),
|
||||||
|
|
||||||
|
if (invoice.sellerInfo != null && invoice.buyerInfo != null)
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
|
// Buyer Info
|
||||||
|
if (invoice.buyerInfo != null)
|
||||||
|
_CompanyInfoBlock(
|
||||||
|
icon: FontAwesomeIcons.userTie,
|
||||||
|
iconColor: Colors.green.shade600,
|
||||||
|
title: 'Đơn vị mua hàng',
|
||||||
|
lines: _buildBuyerInfoLines(invoice),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<_InfoLine> _buildSellerInfoLines(Invoice invoice) {
|
||||||
|
return [
|
||||||
|
if (invoice.sellerInfo!.companyName != null)
|
||||||
|
_InfoLine(label: 'Công ty', value: invoice.sellerInfo!.companyName!),
|
||||||
|
if (invoice.sellerInfo!.taxCode != null)
|
||||||
|
_InfoLine(label: 'Mã số thuế', value: invoice.sellerInfo!.taxCode!),
|
||||||
|
if (invoice.sellerInfo!.fullAddress.isNotEmpty)
|
||||||
|
_InfoLine(label: 'Địa chỉ', value: invoice.sellerInfo!.fullAddress),
|
||||||
|
if (invoice.sellerInfo!.phone != null)
|
||||||
|
_InfoLine(label: 'Điện thoại', value: invoice.sellerInfo!.phone!),
|
||||||
|
if (invoice.sellerInfo!.email != null)
|
||||||
|
_InfoLine(label: 'Email', value: invoice.sellerInfo!.email!),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
List<_InfoLine> _buildBuyerInfoLines(Invoice invoice) {
|
||||||
|
return [
|
||||||
|
if (invoice.buyerInfo!.name != null)
|
||||||
|
_InfoLine(label: 'Người mua hàng', value: invoice.buyerInfo!.name!),
|
||||||
|
if (invoice.customerName != null)
|
||||||
|
_InfoLine(label: 'Tên đơn vị', value: invoice.customerName!),
|
||||||
|
if (invoice.buyerInfo!.taxCode != null)
|
||||||
|
_InfoLine(label: 'Mã số thuế', value: invoice.buyerInfo!.taxCode!),
|
||||||
|
if (invoice.buyerInfo!.fullAddress.isNotEmpty)
|
||||||
|
_InfoLine(label: 'Địa chỉ', value: invoice.buyerInfo!.fullAddress),
|
||||||
|
if (invoice.buyerInfo!.phone != null)
|
||||||
|
_InfoLine(label: 'Điện thoại', value: invoice.buyerInfo!.phone!),
|
||||||
|
if (invoice.buyerInfo!.email != null)
|
||||||
|
_InfoLine(label: 'Email', value: invoice.buyerInfo!.email!),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build products card
|
||||||
|
Widget _buildProductsCard(BuildContext context, Invoice invoice) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.surface,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: colorScheme.outline.withValues(alpha: 0.1),
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: colorScheme.shadow.withValues(alpha: 0.08),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Section Title
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
FaIcon(
|
||||||
|
FontAwesomeIcons.boxOpen,
|
||||||
|
size: 18,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'Chi tiết hàng hóa',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Products Table
|
||||||
|
if (invoice.items != null && invoice.items!.isNotEmpty)
|
||||||
|
_buildProductsTable(context, invoice)
|
||||||
|
else
|
||||||
|
Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Text(
|
||||||
|
'Không có thông tin sản phẩm',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
|
// Invoice Summary
|
||||||
|
_buildInvoiceSummary(context, invoice),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build products table - with Đơn giá column
|
||||||
|
Widget _buildProductsTable(BuildContext context, Invoice invoice) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
// Table Header
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.surface,
|
||||||
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(8)),
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(
|
||||||
|
color: colorScheme.outlineVariant,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// # column
|
||||||
|
SizedBox(
|
||||||
|
width: 32,
|
||||||
|
child: Text(
|
||||||
|
'#',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Tên hàng hóa column
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text(
|
||||||
|
'Tên hàng hóa',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Số lượng column
|
||||||
|
SizedBox(
|
||||||
|
width: 55,
|
||||||
|
child: Text(
|
||||||
|
'SL',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Đơn giá column
|
||||||
|
SizedBox(
|
||||||
|
width: 80,
|
||||||
|
child: Text(
|
||||||
|
'Đơn giá',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.right,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Thành tiền column
|
||||||
|
SizedBox(
|
||||||
|
width: 90,
|
||||||
|
child: Text(
|
||||||
|
'Thành tiền',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.right,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Table Body
|
||||||
|
...invoice.items!.asMap().entries.map((entry) {
|
||||||
|
final index = entry.key;
|
||||||
|
final item = entry.value;
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(color: colorScheme.outlineVariant.withValues(alpha: 0.5)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// # column
|
||||||
|
SizedBox(
|
||||||
|
width: 32,
|
||||||
|
child: Text(
|
||||||
|
'${index + 1}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Tên hàng hóa column
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
item.itemName,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
'SKU: ${item.itemCode}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.7),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Số lượng column
|
||||||
|
SizedBox(
|
||||||
|
width: 55,
|
||||||
|
child: Text(
|
||||||
|
item.qty.toStringAsFixed(item.qty.truncateToDouble() == item.qty ? 0 : 2),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Đơn giá column
|
||||||
|
SizedBox(
|
||||||
|
width: 80,
|
||||||
|
child: Text(
|
||||||
|
item.rate.toVNCurrency,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.right,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Thành tiền column
|
||||||
|
SizedBox(
|
||||||
|
width: 90,
|
||||||
|
child: Text(
|
||||||
|
item.amount.toVNCurrency,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.right,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build invoice summary
|
||||||
|
Widget _buildInvoiceSummary(BuildContext context, Invoice invoice) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.surfaceContainerLowest,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Subtotal
|
||||||
|
if (invoice.total != null)
|
||||||
|
_SummaryRow(
|
||||||
|
label: 'Tổng tiền hàng:',
|
||||||
|
value: invoice.total!.toVNCurrency,
|
||||||
|
),
|
||||||
|
|
||||||
|
// Discount
|
||||||
|
if (invoice.discountAmount != null && invoice.discountAmount! > 0)
|
||||||
|
_SummaryRow(
|
||||||
|
label: 'Chiết khấu:',
|
||||||
|
value: '-${invoice.discountAmount!.toVNCurrency}',
|
||||||
|
valueColor: const Color(0xFF059669),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Grand Total
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(top: 16),
|
||||||
|
margin: const EdgeInsets.only(top: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
top: BorderSide(color: colorScheme.outlineVariant, width: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'TỔNG THANH TOÁN:',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
invoice.grandTotal.toVNCurrency,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: Color(0xFFDC2626),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build action button
|
||||||
|
Widget _buildActionButton(BuildContext context) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: OutlinedButton.icon(
|
||||||
|
onPressed: () => _contactSupport(context),
|
||||||
|
icon: const FaIcon(FontAwesomeIcons.comments, size: 18),
|
||||||
|
label: const Text('Liên hệ hỗ trợ'),
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
foregroundColor: colorScheme.onSurface,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 20),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
side: BorderSide(color: colorScheme.outlineVariant, width: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build error state
|
||||||
|
Widget _buildErrorState(BuildContext context, WidgetRef ref, Object error) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
FaIcon(
|
||||||
|
FontAwesomeIcons.circleExclamation,
|
||||||
|
size: 64,
|
||||||
|
color: colorScheme.error.withValues(alpha: 0.7),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'Có lỗi xảy ra',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||||
|
child: Text(
|
||||||
|
error.toString(),
|
||||||
|
style: TextStyle(fontSize: 14, color: colorScheme.onSurfaceVariant),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () => ref.invalidate(invoiceDetailProvider(invoiceId)),
|
||||||
|
child: const Text('Thử lại'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Share invoice
|
||||||
|
void _shareInvoice(BuildContext context) {
|
||||||
|
SharePlus.instance.share(
|
||||||
|
ShareParams(
|
||||||
|
text: 'Chi tiết hóa đơn #$invoiceId - EuroTile Worker',
|
||||||
|
subject: 'Hóa đơn #$invoiceId',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Contact support
|
||||||
|
void _contactSupport(BuildContext context) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Hotline hỗ trợ: 1900 1234'),
|
||||||
|
duration: Duration(seconds: 3),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Status Badge Widget - with uppercase text
|
||||||
|
class _StatusBadge extends StatelessWidget {
|
||||||
|
const _StatusBadge({
|
||||||
|
required this.status,
|
||||||
|
required this.statusColor,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String status;
|
||||||
|
final String statusColor;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Color backgroundColor;
|
||||||
|
Color textColor;
|
||||||
|
|
||||||
|
switch (statusColor.toLowerCase()) {
|
||||||
|
case 'success':
|
||||||
|
backgroundColor = const Color(0xFFD1FAE5);
|
||||||
|
textColor = const Color(0xFF065F46);
|
||||||
|
case 'danger':
|
||||||
|
backgroundColor = const Color(0xFFFEF3C7);
|
||||||
|
textColor = const Color(0xFFD97706);
|
||||||
|
case 'warning':
|
||||||
|
backgroundColor = const Color(0xFFFEF3C7);
|
||||||
|
textColor = const Color(0xFFD97706);
|
||||||
|
case 'info':
|
||||||
|
backgroundColor = const Color(0xFFE0E7FF);
|
||||||
|
textColor = const Color(0xFF3730A3);
|
||||||
|
default:
|
||||||
|
backgroundColor = const Color(0xFFF3F4F6);
|
||||||
|
textColor = const Color(0xFF6B7280);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: backgroundColor,
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
status.toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: textColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Meta Item Widget
|
||||||
|
class _MetaItem extends StatelessWidget {
|
||||||
|
const _MetaItem({
|
||||||
|
required this.label,
|
||||||
|
required this.value,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final String value;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
value,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Company Info Block Widget
|
||||||
|
class _CompanyInfoBlock extends StatelessWidget {
|
||||||
|
const _CompanyInfoBlock({
|
||||||
|
required this.icon,
|
||||||
|
required this.iconColor,
|
||||||
|
required this.title,
|
||||||
|
required this.lines,
|
||||||
|
});
|
||||||
|
|
||||||
|
final IconData icon;
|
||||||
|
final Color iconColor;
|
||||||
|
final String title;
|
||||||
|
final List<_InfoLine> lines;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
FaIcon(icon, size: 16, color: iconColor),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
...lines,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Info Line Widget
|
||||||
|
class _InfoLine extends StatelessWidget {
|
||||||
|
const _InfoLine({
|
||||||
|
required this.label,
|
||||||
|
required this.value,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final String value;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 6),
|
||||||
|
child: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
height: 1.6,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: '$label: ',
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.w400),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: value,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Summary Row Widget
|
||||||
|
class _SummaryRow extends StatelessWidget {
|
||||||
|
const _SummaryRow({
|
||||||
|
required this.label,
|
||||||
|
required this.value,
|
||||||
|
this.valueColor,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final String value;
|
||||||
|
final Color? valueColor;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
value,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: valueColor ?? colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
362
lib/features/invoices/presentation/pages/invoices_page.dart
Normal file
362
lib/features/invoices/presentation/pages/invoices_page.dart
Normal file
@@ -0,0 +1,362 @@
|
|||||||
|
/// Page: Invoices Page
|
||||||
|
///
|
||||||
|
/// Displays list of invoices following html/invoice-list.html design.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:worker/core/constants/ui_constants.dart';
|
||||||
|
import 'package:worker/core/router/app_router.dart';
|
||||||
|
import 'package:worker/core/utils/extensions.dart';
|
||||||
|
import 'package:worker/features/invoices/domain/entities/invoice.dart';
|
||||||
|
import 'package:worker/features/invoices/presentation/providers/invoices_provider.dart';
|
||||||
|
|
||||||
|
/// Invoices Page
|
||||||
|
///
|
||||||
|
/// Features:
|
||||||
|
/// - List of invoice cards
|
||||||
|
/// - Status badges (Đã thanh toán, Chưa thanh toán, Thanh toán 1 phần)
|
||||||
|
/// - Pull-to-refresh
|
||||||
|
/// - Empty state
|
||||||
|
/// - Navigation to invoice detail
|
||||||
|
class InvoicesPage extends ConsumerWidget {
|
||||||
|
const InvoicesPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final invoicesAsync = ref.watch(invoicesProvider);
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: colorScheme.surfaceContainerLowest,
|
||||||
|
appBar: AppBar(
|
||||||
|
leading: IconButton(
|
||||||
|
icon: Icon(Icons.arrow_back, color: colorScheme.onSurface),
|
||||||
|
onPressed: () => context.pop(),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
'Hóa đơn đã mua',
|
||||||
|
style: TextStyle(
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
elevation: AppBarSpecs.elevation,
|
||||||
|
backgroundColor: colorScheme.surface,
|
||||||
|
centerTitle: false,
|
||||||
|
actions: const [SizedBox(width: AppSpacing.sm)],
|
||||||
|
),
|
||||||
|
body: invoicesAsync.when(
|
||||||
|
data: (invoices) {
|
||||||
|
if (invoices.isEmpty) {
|
||||||
|
return _buildEmptyState(context, ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RefreshIndicator(
|
||||||
|
onRefresh: () async {
|
||||||
|
await ref.read(invoicesProvider.notifier).refresh();
|
||||||
|
},
|
||||||
|
child: ListView.builder(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
itemCount: invoices.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final invoice = invoices[index];
|
||||||
|
return _InvoiceCard(
|
||||||
|
invoice: invoice,
|
||||||
|
onTap: () => context.push(
|
||||||
|
RouteNames.invoiceDetail.replaceFirst(':id', invoice.name),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
loading: () => const Center(child: CircularProgressIndicator()),
|
||||||
|
error: (error, stack) => _buildErrorState(context, ref, error),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build error state
|
||||||
|
Widget _buildErrorState(BuildContext context, WidgetRef ref, Object error) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
FaIcon(
|
||||||
|
FontAwesomeIcons.circleExclamation,
|
||||||
|
size: 64,
|
||||||
|
color: colorScheme.error.withValues(alpha: 0.7),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'Có lỗi xảy ra',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
error.toString(),
|
||||||
|
style: TextStyle(fontSize: 14, color: colorScheme.onSurfaceVariant),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () => ref.invalidate(invoicesProvider),
|
||||||
|
child: const Text('Thử lại'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build empty state
|
||||||
|
Widget _buildEmptyState(BuildContext context, WidgetRef ref) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return RefreshIndicator(
|
||||||
|
onRefresh: () async {
|
||||||
|
await ref.read(invoicesProvider.notifier).refresh();
|
||||||
|
},
|
||||||
|
child: ListView(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 500,
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
FaIcon(
|
||||||
|
FontAwesomeIcons.fileInvoiceDollar,
|
||||||
|
size: 64,
|
||||||
|
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
'Không có hóa đơn nào',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: colorScheme.onSurface.withValues(alpha: 0.8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Khi bạn mua hàng, hóa đơn sẽ xuất hiện ở đây',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Invoice Card Widget
|
||||||
|
class _InvoiceCard extends StatelessWidget {
|
||||||
|
const _InvoiceCard({
|
||||||
|
required this.invoice,
|
||||||
|
this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Invoice invoice;
|
||||||
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Card(
|
||||||
|
margin: const EdgeInsets.only(bottom: 16),
|
||||||
|
elevation: 2,
|
||||||
|
shadowColor: colorScheme.shadow.withValues(alpha: 0.08),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
side: BorderSide(color: colorScheme.outline.withValues(alpha: 0.1), width: 1),
|
||||||
|
),
|
||||||
|
color: colorScheme.surface,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Header: Invoice ID and Status
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Invoice ID and Date
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'#${invoice.name}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
'Ngày xuất: ${invoice.formattedDate}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Status Badge
|
||||||
|
_StatusBadge(
|
||||||
|
status: invoice.status,
|
||||||
|
statusColor: invoice.statusColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
|
||||||
|
// Details Section
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
top: BorderSide(color: colorScheme.outlineVariant),
|
||||||
|
bottom: BorderSide(color: colorScheme.outlineVariant),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Order ID (if available)
|
||||||
|
if (invoice.orderId != null)
|
||||||
|
_DetailRow(
|
||||||
|
label: 'Đơn hàng:',
|
||||||
|
value: '#${invoice.orderId}',
|
||||||
|
),
|
||||||
|
_DetailRow(
|
||||||
|
label: 'Tổng tiền:',
|
||||||
|
value: invoice.grandTotal.toVNCurrency,
|
||||||
|
isTotal: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Status Badge Widget
|
||||||
|
class _StatusBadge extends StatelessWidget {
|
||||||
|
const _StatusBadge({
|
||||||
|
required this.status,
|
||||||
|
required this.statusColor,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String status;
|
||||||
|
final String statusColor;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Color backgroundColor;
|
||||||
|
Color textColor;
|
||||||
|
|
||||||
|
switch (statusColor.toLowerCase()) {
|
||||||
|
case 'success':
|
||||||
|
backgroundColor = const Color(0xFFD1FAE5);
|
||||||
|
textColor = const Color(0xFF065F46);
|
||||||
|
case 'danger':
|
||||||
|
backgroundColor = const Color(0xFFFEF3C7);
|
||||||
|
textColor = const Color(0xFFD97706);
|
||||||
|
case 'warning':
|
||||||
|
backgroundColor = const Color(0xFFFEF3C7);
|
||||||
|
textColor = const Color(0xFFD97706);
|
||||||
|
case 'info':
|
||||||
|
backgroundColor = const Color(0xFFE0E7FF);
|
||||||
|
textColor = const Color(0xFF3730A3);
|
||||||
|
default:
|
||||||
|
backgroundColor = const Color(0xFFF3F4F6);
|
||||||
|
textColor = const Color(0xFF6B7280);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: backgroundColor,
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
status,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: textColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Detail Row Widget
|
||||||
|
class _DetailRow extends StatelessWidget {
|
||||||
|
const _DetailRow({
|
||||||
|
required this.label,
|
||||||
|
required this.value,
|
||||||
|
this.isTotal = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final String value;
|
||||||
|
final bool isTotal;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
value,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: isTotal ? 16 : 14,
|
||||||
|
fontWeight: isTotal ? FontWeight.w700 : FontWeight.w600,
|
||||||
|
color: isTotal ? colorScheme.error : colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/// Invoices Provider
|
||||||
|
///
|
||||||
|
/// Riverpod providers for managing invoices state.
|
||||||
|
library;
|
||||||
|
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:worker/core/network/dio_client.dart';
|
||||||
|
import 'package:worker/features/invoices/data/datasources/invoice_remote_datasource.dart';
|
||||||
|
import 'package:worker/features/invoices/data/repositories/invoice_repository_impl.dart';
|
||||||
|
import 'package:worker/features/invoices/domain/entities/invoice.dart';
|
||||||
|
import 'package:worker/features/invoices/domain/repositories/invoice_repository.dart';
|
||||||
|
|
||||||
|
part 'invoices_provider.g.dart';
|
||||||
|
|
||||||
|
/// Invoice Repository Provider
|
||||||
|
@riverpod
|
||||||
|
Future<InvoiceRepository> invoiceRepository(Ref ref) async {
|
||||||
|
final dioClient = await ref.watch(dioClientProvider.future);
|
||||||
|
final remoteDataSource = InvoiceRemoteDataSource(dioClient);
|
||||||
|
return InvoiceRepositoryImpl(remoteDataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Invoices Provider
|
||||||
|
///
|
||||||
|
/// Provides list of all invoices from repository.
|
||||||
|
@riverpod
|
||||||
|
class Invoices extends _$Invoices {
|
||||||
|
@override
|
||||||
|
Future<List<Invoice>> build() async {
|
||||||
|
try {
|
||||||
|
final repository = await ref.read(invoiceRepositoryProvider.future);
|
||||||
|
final invoices = await repository.getInvoicesList(
|
||||||
|
limitStart: 0,
|
||||||
|
limitPageLength: 0, // 0 = get all
|
||||||
|
);
|
||||||
|
// Sort by posting date (newest first)
|
||||||
|
invoices.sort((a, b) => b.postingDate.compareTo(a.postingDate));
|
||||||
|
return invoices;
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to load invoices: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Refresh invoices
|
||||||
|
Future<void> refresh() async {
|
||||||
|
state = const AsyncValue.loading();
|
||||||
|
state = await AsyncValue.guard(() async {
|
||||||
|
final repository = await ref.read(invoiceRepositoryProvider.future);
|
||||||
|
final invoices = await repository.getInvoicesList(
|
||||||
|
limitStart: 0,
|
||||||
|
limitPageLength: 0,
|
||||||
|
);
|
||||||
|
// Sort by posting date (newest first)
|
||||||
|
invoices.sort((a, b) => b.postingDate.compareTo(a.postingDate));
|
||||||
|
return invoices;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Invoice Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides invoice detail by ID.
|
||||||
|
@riverpod
|
||||||
|
Future<Invoice> invoiceDetail(Ref ref, String name) async {
|
||||||
|
final repository = await ref.watch(invoiceRepositoryProvider.future);
|
||||||
|
return await repository.getInvoiceDetail(name);
|
||||||
|
}
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'invoices_provider.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// ignore_for_file: type=lint, type=warning
|
||||||
|
/// Invoice Repository Provider
|
||||||
|
|
||||||
|
@ProviderFor(invoiceRepository)
|
||||||
|
const invoiceRepositoryProvider = InvoiceRepositoryProvider._();
|
||||||
|
|
||||||
|
/// Invoice Repository Provider
|
||||||
|
|
||||||
|
final class InvoiceRepositoryProvider
|
||||||
|
extends
|
||||||
|
$FunctionalProvider<
|
||||||
|
AsyncValue<InvoiceRepository>,
|
||||||
|
InvoiceRepository,
|
||||||
|
FutureOr<InvoiceRepository>
|
||||||
|
>
|
||||||
|
with
|
||||||
|
$FutureModifier<InvoiceRepository>,
|
||||||
|
$FutureProvider<InvoiceRepository> {
|
||||||
|
/// Invoice Repository Provider
|
||||||
|
const InvoiceRepositoryProvider._()
|
||||||
|
: super(
|
||||||
|
from: null,
|
||||||
|
argument: null,
|
||||||
|
retry: null,
|
||||||
|
name: r'invoiceRepositoryProvider',
|
||||||
|
isAutoDispose: true,
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String debugGetCreateSourceHash() => _$invoiceRepositoryHash();
|
||||||
|
|
||||||
|
@$internal
|
||||||
|
@override
|
||||||
|
$FutureProviderElement<InvoiceRepository> $createElement(
|
||||||
|
$ProviderPointer pointer,
|
||||||
|
) => $FutureProviderElement(pointer);
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<InvoiceRepository> create(Ref ref) {
|
||||||
|
return invoiceRepository(ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$invoiceRepositoryHash() => r'16ac0418e4a5522544346b8af22d3fcf33071016';
|
||||||
|
|
||||||
|
/// Invoices Provider
|
||||||
|
///
|
||||||
|
/// Provides list of all invoices from repository.
|
||||||
|
|
||||||
|
@ProviderFor(Invoices)
|
||||||
|
const invoicesProvider = InvoicesProvider._();
|
||||||
|
|
||||||
|
/// Invoices Provider
|
||||||
|
///
|
||||||
|
/// Provides list of all invoices from repository.
|
||||||
|
final class InvoicesProvider
|
||||||
|
extends $AsyncNotifierProvider<Invoices, List<Invoice>> {
|
||||||
|
/// Invoices Provider
|
||||||
|
///
|
||||||
|
/// Provides list of all invoices from repository.
|
||||||
|
const InvoicesProvider._()
|
||||||
|
: super(
|
||||||
|
from: null,
|
||||||
|
argument: null,
|
||||||
|
retry: null,
|
||||||
|
name: r'invoicesProvider',
|
||||||
|
isAutoDispose: true,
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String debugGetCreateSourceHash() => _$invoicesHash();
|
||||||
|
|
||||||
|
@$internal
|
||||||
|
@override
|
||||||
|
Invoices create() => Invoices();
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$invoicesHash() => r'fa724059f84f945c52bb7b8508e768d1980e8fe3';
|
||||||
|
|
||||||
|
/// Invoices Provider
|
||||||
|
///
|
||||||
|
/// Provides list of all invoices from repository.
|
||||||
|
|
||||||
|
abstract class _$Invoices extends $AsyncNotifier<List<Invoice>> {
|
||||||
|
FutureOr<List<Invoice>> build();
|
||||||
|
@$mustCallSuper
|
||||||
|
@override
|
||||||
|
void runBuild() {
|
||||||
|
final created = build();
|
||||||
|
final ref = this.ref as $Ref<AsyncValue<List<Invoice>>, List<Invoice>>;
|
||||||
|
final element =
|
||||||
|
ref.element
|
||||||
|
as $ClassProviderElement<
|
||||||
|
AnyNotifier<AsyncValue<List<Invoice>>, List<Invoice>>,
|
||||||
|
AsyncValue<List<Invoice>>,
|
||||||
|
Object?,
|
||||||
|
Object?
|
||||||
|
>;
|
||||||
|
element.handleValue(ref, created);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Invoice Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides invoice detail by ID.
|
||||||
|
|
||||||
|
@ProviderFor(invoiceDetail)
|
||||||
|
const invoiceDetailProvider = InvoiceDetailFamily._();
|
||||||
|
|
||||||
|
/// Invoice Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides invoice detail by ID.
|
||||||
|
|
||||||
|
final class InvoiceDetailProvider
|
||||||
|
extends $FunctionalProvider<AsyncValue<Invoice>, Invoice, FutureOr<Invoice>>
|
||||||
|
with $FutureModifier<Invoice>, $FutureProvider<Invoice> {
|
||||||
|
/// Invoice Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides invoice detail by ID.
|
||||||
|
const InvoiceDetailProvider._({
|
||||||
|
required InvoiceDetailFamily super.from,
|
||||||
|
required String super.argument,
|
||||||
|
}) : super(
|
||||||
|
retry: null,
|
||||||
|
name: r'invoiceDetailProvider',
|
||||||
|
isAutoDispose: true,
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String debugGetCreateSourceHash() => _$invoiceDetailHash();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return r'invoiceDetailProvider'
|
||||||
|
''
|
||||||
|
'($argument)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@$internal
|
||||||
|
@override
|
||||||
|
$FutureProviderElement<Invoice> $createElement($ProviderPointer pointer) =>
|
||||||
|
$FutureProviderElement(pointer);
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<Invoice> create(Ref ref) {
|
||||||
|
final argument = this.argument as String;
|
||||||
|
return invoiceDetail(ref, argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is InvoiceDetailProvider && other.argument == argument;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
return argument.hashCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$invoiceDetailHash() => r'ca2993098ab182836a9c0272ae785eba87b83c83';
|
||||||
|
|
||||||
|
/// Invoice Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides invoice detail by ID.
|
||||||
|
|
||||||
|
final class InvoiceDetailFamily extends $Family
|
||||||
|
with $FunctionalFamilyOverride<FutureOr<Invoice>, String> {
|
||||||
|
const InvoiceDetailFamily._()
|
||||||
|
: super(
|
||||||
|
retry: null,
|
||||||
|
name: r'invoiceDetailProvider',
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
isAutoDispose: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Invoice Detail Provider
|
||||||
|
///
|
||||||
|
/// Provides invoice detail by ID.
|
||||||
|
|
||||||
|
InvoiceDetailProvider call(String name) =>
|
||||||
|
InvoiceDetailProvider._(argument: name, from: this);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => r'invoiceDetailProvider';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user