feat: 完成進貨單自動拋轉應付帳款流程與AP介面優化
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 1m8s
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 1m8s
1. 新增 AccountPayable (應付帳款) 模組,包含 Migration、Model、Service 與 Controller 2. 修改 GoodsReceipt (進貨單) 流程,在確認進貨時自動產生對應的應付帳款單 (AP-YYYYMMDD-XX) 3. 實作應付帳款詳細頁面 (Show.tsx),包含發票登記與標記付款功能 4. 修正應付帳款 Show 頁面的排版,將發票資訊套用標準的綠色背景區塊,並調整按鈕位置 5. 更新相關的 Service Provider 與 Routes
This commit is contained in:
24
fix_ap.php
Normal file
24
fix_ap.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
use App\Modules\Finance\Models\AccountPayable;
|
||||
use App\Modules\Inventory\Models\GoodsReceiptItem;
|
||||
|
||||
$ap = AccountPayable::latest()->first();
|
||||
if ($ap) {
|
||||
if (!$ap->total_amount || $ap->total_amount == 0) {
|
||||
$sum = GoodsReceiptItem::where('goods_receipt_id', $ap->source_document_id)->sum('total_amount');
|
||||
if ($sum == 0) {
|
||||
// fallback: check if unit_price * quantity_received works
|
||||
$items = GoodsReceiptItem::where('goods_receipt_id', $ap->source_document_id)->get();
|
||||
foreach($items as $item) {
|
||||
$sum += ($item->quantity_received * $item->unit_price);
|
||||
}
|
||||
}
|
||||
$ap->total_amount = $sum;
|
||||
$ap->save();
|
||||
echo "Fixed AP {$ap->document_number} total_amount to {$sum}\n";
|
||||
} else {
|
||||
echo "AP total_amount is already set: {$ap->total_amount}\n";
|
||||
}
|
||||
} else {
|
||||
echo "No AP found\n";
|
||||
}
|
||||
Reference in New Issue
Block a user