baseline: quarantine generated files and stabilize project
This commit is contained in:
parent
f97d671ec4
commit
1344f1d90b
5 changed files with 1874 additions and 864 deletions
15
.gitignore
vendored
15
.gitignore
vendored
|
|
@ -3,3 +3,18 @@
|
||||||
__pycache__/
|
__pycache__/
|
||||||
sales.db
|
sales.db
|
||||||
__init__.py
|
__init__.py
|
||||||
|
# .gitignore
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
|
||||||
|
# build/cache
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
*.pyc
|
||||||
|
# generated
|
||||||
|
generated_pdfs/
|
||||||
|
audit_export/
|
||||||
|
trash/
|
||||||
|
# experiments
|
||||||
|
apk_test/
|
||||||
|
helloworld/
|
||||||
|
|
|
||||||
27
README.md
27
README.md
|
|
@ -36,14 +36,35 @@ python main.py
|
||||||
Fletを使用してAndroidアプリをビルド:
|
Fletを使用してAndroidアプリをビルド:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python build.py
|
flet build apk .
|
||||||
```
|
```
|
||||||
|
|
||||||
または直接実行:
|
リリースAABを作る場合:
|
||||||
```bash
|
```bash
|
||||||
flet pack main.py --android
|
flet build aab .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## リポジトリ整理の自動化
|
||||||
|
|
||||||
|
SWE実行で生成された試作ファイル/生成物を安全に整理するため、
|
||||||
|
削除ではなく `trash/` へ隔離するスクリプトを用意しています。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash scripts/auto_recover_and_build.sh /home/user/dev/h-1.flet.3
|
||||||
|
```
|
||||||
|
|
||||||
|
このスクリプトで実行される内容:
|
||||||
|
|
||||||
|
- プロジェクト全体のバックアップ作成
|
||||||
|
- 生成物/試作ファイルの `trash/<timestamp>/` への移動
|
||||||
|
- `.gitignore` の整備
|
||||||
|
- Gitベースラインコミット作成(必要時)
|
||||||
|
|
||||||
|
注意:
|
||||||
|
|
||||||
|
- 実行確認 (`python main.py`) と APK ビルド (`flet build apk`) は自動実行しません
|
||||||
|
- 必要に応じて最後に表示されるコマンドを手動実行してください
|
||||||
|
|
||||||
## データベース
|
## データベース
|
||||||
|
|
||||||
アプリケーションはSQLiteデータベース(`sales.db`)を使用してデータを保存します。
|
アプリケーションはSQLiteデータベース(`sales.db`)を使用してデータを保存します。
|
||||||
|
|
|
||||||
118
scripts/auto_recover_and_build.sh
Normal file
118
scripts/auto_recover_and_build.sh
Normal file
|
|
@ -0,0 +1,118 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# bash scripts/auto_recover_and_build.sh [PROJECT_DIR]
|
||||||
|
# Default PROJECT_DIR is current working directory.
|
||||||
|
|
||||||
|
PROJECT_DIR="${1:-$(pwd)}"
|
||||||
|
PROJECT_DIR="$(realpath "$PROJECT_DIR")"
|
||||||
|
TS="$(date +%Y%m%d_%H%M%S)"
|
||||||
|
|
||||||
|
if [[ ! -f "$PROJECT_DIR/main.py" ]]; then
|
||||||
|
echo "ERROR: main.py not found under PROJECT_DIR: $PROJECT_DIR" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BACKUP_DIR="${PROJECT_DIR}.backup_${TS}"
|
||||||
|
TRASH_DIR="$PROJECT_DIR/trash/${TS}"
|
||||||
|
|
||||||
|
printf "[1/7] Backup project -> %s\n" "$BACKUP_DIR"
|
||||||
|
cp -a "$PROJECT_DIR" "$BACKUP_DIR"
|
||||||
|
|
||||||
|
printf "[2/7] Quarantine noisy/generated files -> %s\n" "$TRASH_DIR"
|
||||||
|
mkdir -p "$TRASH_DIR"
|
||||||
|
|
||||||
|
# Candidate directories to quarantine (safe move, no delete)
|
||||||
|
for d in \
|
||||||
|
apk_test \
|
||||||
|
helloworld \
|
||||||
|
build \
|
||||||
|
dist \
|
||||||
|
flutter.参考 \
|
||||||
|
__pycache__ \
|
||||||
|
.pytest_cache \
|
||||||
|
.mypy_cache
|
||||||
|
do
|
||||||
|
if [[ -e "$PROJECT_DIR/$d" ]]; then
|
||||||
|
mv "$PROJECT_DIR/$d" "$TRASH_DIR/"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Candidate files to quarantine (safe move, no delete)
|
||||||
|
shopt -s nullglob
|
||||||
|
for f in \
|
||||||
|
"$PROJECT_DIR"/app_*.py \
|
||||||
|
"$PROJECT_DIR"/test_*.py \
|
||||||
|
"$PROJECT_DIR"/debug_test.py \
|
||||||
|
"$PROJECT_DIR"/run_*.py \
|
||||||
|
"$PROJECT_DIR"/main_simple.py \
|
||||||
|
"$PROJECT_DIR"/minimal.py \
|
||||||
|
"$PROJECT_DIR"/*.spec
|
||||||
|
do
|
||||||
|
if [[ -e "$f" ]]; then
|
||||||
|
mv "$f" "$TRASH_DIR/"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
shopt -u nullglob
|
||||||
|
|
||||||
|
printf "[3/7] Ensure .gitignore has generated-file rules\n"
|
||||||
|
GITIGNORE="$PROJECT_DIR/.gitignore"
|
||||||
|
touch "$GITIGNORE"
|
||||||
|
append_if_missing() {
|
||||||
|
local line="$1"
|
||||||
|
grep -Fqx "$line" "$GITIGNORE" || echo "$line" >> "$GITIGNORE"
|
||||||
|
}
|
||||||
|
|
||||||
|
append_if_missing ""
|
||||||
|
append_if_missing "# build/cache"
|
||||||
|
append_if_missing "build/"
|
||||||
|
append_if_missing "dist/"
|
||||||
|
append_if_missing "__pycache__/"
|
||||||
|
append_if_missing "*.pyc"
|
||||||
|
append_if_missing ""
|
||||||
|
append_if_missing "# generated"
|
||||||
|
append_if_missing "generated_pdfs/"
|
||||||
|
append_if_missing "audit_export/"
|
||||||
|
append_if_missing "trash/"
|
||||||
|
append_if_missing ""
|
||||||
|
append_if_missing "# experiments"
|
||||||
|
append_if_missing "apk_test/"
|
||||||
|
append_if_missing "helloworld/"
|
||||||
|
|
||||||
|
printf "[4/7] Initialize git baseline if needed\n"
|
||||||
|
if [[ ! -d "$PROJECT_DIR/.git" ]]; then
|
||||||
|
git -C "$PROJECT_DIR" init
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "[5/7] Stage core project files\n"
|
||||||
|
# Stage only the likely core set; ignore errors for missing paths.
|
||||||
|
git -C "$PROJECT_DIR" add \
|
||||||
|
.gitignore \
|
||||||
|
README.md \
|
||||||
|
requirements.txt \
|
||||||
|
main.py \
|
||||||
|
models \
|
||||||
|
services \
|
||||||
|
components \
|
||||||
|
sales.db \
|
||||||
|
sales_assist.db \
|
||||||
|
scripts || true
|
||||||
|
|
||||||
|
if ! git -C "$PROJECT_DIR" diff --cached --quiet; then
|
||||||
|
git -C "$PROJECT_DIR" commit -m "baseline: quarantine generated files and stabilize project"
|
||||||
|
else
|
||||||
|
printf "No staged changes to commit.\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "[6/7] Optional runtime check (python main.py)\n"
|
||||||
|
printf "Skipped by default. Run manually if needed:\n"
|
||||||
|
printf " source %s/.venv/bin/activate && python %s/main.py\n" "$PROJECT_DIR" "$PROJECT_DIR"
|
||||||
|
|
||||||
|
printf "[7/7] Optional APK build check\n"
|
||||||
|
printf "Run manually once your Flet build config is ready:\n"
|
||||||
|
printf " source %s/.venv/bin/activate && flet build apk %s\n" "$PROJECT_DIR" "$PROJECT_DIR"
|
||||||
|
|
||||||
|
printf "Done.\n"
|
||||||
|
printf "Backup: %s\n" "$BACKUP_DIR"
|
||||||
|
printf "Quarantine: %s\n" "$TRASH_DIR"
|
||||||
|
|
@ -464,6 +464,7 @@ class InvoiceRepository:
|
||||||
"""DB行をInvoiceオブジェクトに変換"""
|
"""DB行をInvoiceオブジェクトに変換"""
|
||||||
try:
|
try:
|
||||||
invoice_id = row[0]
|
invoice_id = row[0]
|
||||||
|
logging.info(f"変換開始: invoice_id={invoice_id}, row_length={len(row)}")
|
||||||
|
|
||||||
# 明細取得
|
# 明細取得
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
|
|
@ -484,11 +485,11 @@ class InvoiceRepository:
|
||||||
|
|
||||||
# 顧客情報
|
# 顧客情報
|
||||||
customer = Customer(
|
customer = Customer(
|
||||||
id=row[15] or 0, # customer_idフィールド
|
id=row[3] or 0, # customer_idフィールド
|
||||||
name=row[3], # customer_nameフィールド
|
name=row[4], # customer_nameフィールド
|
||||||
formal_name=row[3], # customer_nameフィールド
|
formal_name=row[4], # customer_nameフィールド
|
||||||
address=row[4] or "", # customer_addressフィールド
|
address=row[5] or "", # customer_addressフィールド
|
||||||
phone=row[5] or "" # customer_phoneフィールド
|
phone=row[6] or "" # customer_phoneフィールド
|
||||||
)
|
)
|
||||||
|
|
||||||
# 伝票タイプ
|
# 伝票タイプ
|
||||||
|
|
@ -498,13 +499,18 @@ class InvoiceRepository:
|
||||||
doc_type = dt
|
doc_type = dt
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# 日付変換
|
||||||
|
date_str = row[10] # 正しいdateフィールドのインデックス
|
||||||
|
logging.info(f"日付変換: {date_str}")
|
||||||
|
date_obj = datetime.fromisoformat(date_str)
|
||||||
|
|
||||||
inv = Invoice(
|
inv = Invoice(
|
||||||
customer=customer,
|
customer=customer,
|
||||||
date=datetime.fromisoformat(row[9]), # 正しいdateフィールドのインデックス
|
date=date_obj,
|
||||||
items=items,
|
items=items,
|
||||||
file_path=row[12],
|
file_path=row[13], # 正しいfile_pathフィールドのインデックス
|
||||||
invoice_number=row[10] or "", # 正しいinvoice_numberフィールドのインデックス
|
invoice_number=row[11] or "", # 正しいinvoice_numberフィールドのインデックス
|
||||||
notes=row[11], # 正しいnotesフィールドのインデックス
|
notes=row[12], # 正しいnotesフィールドのインデックス
|
||||||
document_type=doc_type,
|
document_type=doc_type,
|
||||||
uuid=row[1],
|
uuid=row[1],
|
||||||
)
|
)
|
||||||
|
|
@ -522,10 +528,11 @@ class InvoiceRepository:
|
||||||
inv.offset_target_uuid = row[22]
|
inv.offset_target_uuid = row[22]
|
||||||
inv.pdf_generated_at = row[23]
|
inv.pdf_generated_at = row[23]
|
||||||
inv.pdf_sha256 = row[24]
|
inv.pdf_sha256 = row[24]
|
||||||
inv.submitted_to_tax_authority = bool(row[25])
|
inv.submitted_to_tax_authority = bool(row[27])
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
logging.info(f"変換成功: {inv.invoice_number}")
|
||||||
return inv
|
return inv
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue