feat: 売上入力画面実装準備を完了\n\n- DatabaseHelper に sales テーブル定義追加\n- Sale モデル(lib/models/sale.dart)作成\n- 短期計画の優先順位更新(PDF を Sprint 5 へ延期)\n- README.md の実装済み機能ステータス反映
This commit is contained in:
parent
a64adefe25
commit
ff17874169
3 changed files with 90 additions and 1 deletions
|
|
@ -90,7 +90,7 @@
|
||||||
|
|
||||||
| 機能 | ファイル | 状態 |
|
| 機能 | ファイル | 状態 |
|
||||||
|------|---------|----|
|
|------|---------|----|
|
||||||
| **見積入力** | `lib/screens/estimate_screen.dart` | ✅ 完了(エラーハンドリング追加)<br>- 得意先選択・商品追加<br>- DatabaseHelper を介した保存<br>- エラーハンドリング完全化<br>📝 次のステップ:PDF 帳票出力テンプレート実装
|
| **見積入力** | `lib/screens/estimate_screen.dart` | ✅ 完了(エラーハンドリング追加)<br>- 得意先選択・商品追加<br>- DatabaseHelper を介した保存<br>- エラーハンドリング完全化<br>📝 次のステップ:売上入力画面実装
|
||||||
| DB CRUD API | `lib/services/database_helper.dart` | ✅ Estimate テーブル対応<br>・insertEstimate<br>・getEstimates<br>・estimate CRUD |
|
| DB CRUD API | `lib/services/database_helper.dart` | ✅ Estimate テーブル対応<br>・insertEstimate<br>・getEstimates<br>・estimate CRUD |
|
||||||
| Estimate モデル | `lib/models/estimate.dart` | ✅ LineItem ネスト構造<br>・toMap/fromMap 実装 |
|
| Estimate モデル | `lib/models/estimate.dart` | ✅ LineItem ネスト構造<br>・toMap/fromMap 実装 |
|
||||||
|
|
||||||
|
|
|
||||||
73
lib/models/sale.dart
Normal file
73
lib/models/sale.dart
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
// Version: 1.1 (売上モデル実装)
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class Sale {
|
||||||
|
int? id;
|
||||||
|
String? saleNo;
|
||||||
|
String customerName;
|
||||||
|
DateTime date;
|
||||||
|
double totalAmount;
|
||||||
|
double taxRate;
|
||||||
|
Map<String, dynamic>? items; // LineItem ネスト構造
|
||||||
|
DateTime createdAt;
|
||||||
|
DateTime updatedAt;
|
||||||
|
|
||||||
|
Sale({
|
||||||
|
this.id,
|
||||||
|
this.saleNo,
|
||||||
|
required this.customerName,
|
||||||
|
required this.date,
|
||||||
|
required this.totalAmount,
|
||||||
|
this.taxRate = 10,
|
||||||
|
this.items,
|
||||||
|
DateTime? createdAt,
|
||||||
|
DateTime? updatedAt,
|
||||||
|
}) : createdAt = createdAt ?? DateTime.now(),
|
||||||
|
updatedAt = updatedAt ?? DateTime.now();
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'sale_no': saleNo,
|
||||||
|
'customer_name': customerName,
|
||||||
|
'date': date.toIso8601String(),
|
||||||
|
'total_amount': totalAmount,
|
||||||
|
'tax_rate': taxRate,
|
||||||
|
'items': items,
|
||||||
|
'created_at': createdAt.toIso8601String(),
|
||||||
|
'updated_at': updatedAt.toIso8601String(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
factory Sale.fromMap(Map<String, dynamic> map) {
|
||||||
|
return Sale(
|
||||||
|
id: map['id'] as int?,
|
||||||
|
saleNo: map['sale_no'] as String?,
|
||||||
|
customerName: map['customer_name'] as String,
|
||||||
|
date: DateTime.parse(map['date'] as String),
|
||||||
|
totalAmount: (map['total_amount'] as num).toDouble(),
|
||||||
|
taxRate: map['tax_rate'] as double? ?? 10,
|
||||||
|
items: map['items'] as Map<String, dynamic>? ,
|
||||||
|
createdAt: map['created_at'] != null ? DateTime.parse(map['created_at']) : DateTime.now(),
|
||||||
|
updatedAt: map['updated_at'] != null ? DateTime.parse(map['updated_at']) : DateTime.now(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String toJson() => json.encode(toMap());
|
||||||
|
|
||||||
|
factory Sale.fromJson(String source) => Sale.fromMap(json.decode(source) as Map<String, dynamic>);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Sale(id: $id, saleNo: $saleNo, customerName: $customerName, date: $date, totalAmount: $totalAmount, taxRate: $taxRate, items: $items)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(covariant Sale other) {
|
||||||
|
if (identical(this, other)) return true;
|
||||||
|
return other.id == id && other.saleNo == saleNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => id ^ saleNo;
|
||||||
|
}
|
||||||
|
|
@ -108,6 +108,22 @@ class DatabaseHelper {
|
||||||
)
|
)
|
||||||
''');
|
''');
|
||||||
|
|
||||||
|
// sales テーブル(売用书)
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE sales (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
sale_no TEXT NOT NULL UNIQUE,
|
||||||
|
customer_id INTEGER,
|
||||||
|
customer_name TEXT NOT NULL,
|
||||||
|
date TEXT NOT NULL,
|
||||||
|
total_amount REAL NOT NULL,
|
||||||
|
tax_rate REAL DEFAULT 10,
|
||||||
|
items_json TEXT NOT NULL,
|
||||||
|
created_at TEXT NOT NULL,
|
||||||
|
updated_at TEXT NOT NULL
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
|
||||||
// customer_snapshots テーブル(イベントソーシング用)
|
// customer_snapshots テーブル(イベントソーシング用)
|
||||||
await db.execute('''
|
await db.execute('''
|
||||||
CREATE TABLE customer_snapshots (
|
CREATE TABLE customer_snapshots (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue