- estimate_screen.dart: /S1. 見積入力 - invoice_screen.dart: /S2. 請求書入力 - order_screen.dart: /S3. 受発注入力 - sales_return_screen.dart: /S5. 売上返品入力 - sales_screen.dart: /S4. 売上入力(レジ) - product_master_screen.dart: /M1. 商品マスタ - customer_master_screen.dart: /M2. 得意先マスタ - supplier_master_screen.dart: /M3. 仕入先マスタ - warehouse_master_screen.dart: /M4. 倉庫マスタ - employee_master_screen.dart: /M5. 担当者マスタ README.md にも画面 ID マッピングを明記
103 lines
No EOL
3.3 KiB
Dart
103 lines
No EOL
3.3 KiB
Dart
// Version: 1.5 - 請求画面(簡易実装)
|
||
import 'package:flutter/material.dart';
|
||
import '../models/customer.dart';
|
||
import '../models/product.dart';
|
||
import '../services/database_helper.dart';
|
||
|
||
/// 請求書作成・管理画面(簡易実装)
|
||
class InvoiceScreen extends StatefulWidget {
|
||
const InvoiceScreen({super.key});
|
||
|
||
@override
|
||
State<InvoiceScreen> createState() => _InvoiceScreenState();
|
||
}
|
||
|
||
class _InvoiceScreenState extends State<InvoiceScreen> {
|
||
final _db = DatabaseHelper.instance;
|
||
|
||
// UI ステート
|
||
Customer? _selectedCustomer;
|
||
List<Customer> _customers = [];
|
||
String _invoiceNumber = '';
|
||
|
||
@override
|
||
void initState() {
|
||
super.initState();
|
||
_loadCustomers();
|
||
_generateInvoiceNumber();
|
||
}
|
||
|
||
/// 得意先一覧をロード
|
||
Future<void> _loadCustomers() async {
|
||
final customers = await DatabaseHelper.instance.getCustomers();
|
||
setState(() => _customers = customers);
|
||
}
|
||
|
||
/// 請求書番号を自動生成(YMM-0001 形式)
|
||
void _generateInvoiceNumber() {
|
||
final now = DateTime.now();
|
||
final yearMonth = '${now.year}${now.month.toString().padLeft(2, '0')}';
|
||
final nextNumber = '0001';
|
||
setState(() => _invoiceNumber = '$yearMonth-$nextNumber');
|
||
}
|
||
|
||
/// 請求書保存処理(簡易)
|
||
Future<void> _saveInvoice(Map<String, dynamic> invoiceData) async {
|
||
if (mounted) {
|
||
ScaffoldMessenger.of(context).showSnackBar(
|
||
const SnackBar(content: Text('請求書保存しました')),
|
||
);
|
||
}
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
appBar: AppBar(title: const Text('/S2. 請求書')),
|
||
body: _selectedCustomer == null
|
||
? const Center(child: Text('得意先を選択してください'))
|
||
: SingleChildScrollView(
|
||
child: Padding(
|
||
padding: const EdgeInsets.all(16),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||
children: [
|
||
// 請求書番号表示
|
||
ListTile(
|
||
contentPadding: EdgeInsets.zero,
|
||
title: const Text('請求書番号'),
|
||
subtitle: Text(_invoiceNumber),
|
||
),
|
||
|
||
const Divider(),
|
||
|
||
// 合計金額表示
|
||
Card(
|
||
child: ListTile(
|
||
contentPadding: EdgeInsets.zero,
|
||
title: const Text('請求書合計'),
|
||
subtitle: const Text('¥0.00'),
|
||
trailing: IconButton(icon: const Icon(Icons.edit), onPressed: () {}),
|
||
),
|
||
),
|
||
|
||
const SizedBox(height: 16),
|
||
|
||
// PDF 帳票出力ボタン(簡易)
|
||
TextButton.icon(
|
||
onPressed: () {
|
||
ScaffoldMessenger.of(context).showSnackBar(
|
||
const SnackBar(content: Text('PDF 帳票生成中...')),
|
||
);
|
||
},
|
||
icon: const Icon(Icons.download),
|
||
label: const Text('PDF をダウンロード'),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
} |