feat: add total field to purchases and update related logic for payment processing

This commit is contained in:
2026-07-07 10:16:28 -03:00
parent 362e888e46
commit 7b2a741884
9 changed files with 377 additions and 56 deletions

View File

@@ -55,9 +55,11 @@ class PurchaseController extends Controller
{
$compra = $this->resolveScopedPurchase($tenant, $request->user()->id, $compra);
$method = $request->validated('method');
$totalAmount = $compra->calculateCurrentTotalAmount();
$compra->update([
'payment_method' => $method,
'total' => $totalAmount,
]);
if ($method === 'transfer') {
@@ -89,9 +91,9 @@ class PurchaseController extends Controller
$telepagosService->forTenant($tenant->codigo);
try {
Log::info("Generating QR for purchase ID: {$compra->id}, amount: {$compra->getTotalAmount()}");
Log::info("Generating QR for purchase ID: {$compra->id}, amount: {$totalAmount}");
$qrResponse = $telepagosService->generateQr(
$compra->getTotalAmount(),
$totalAmount,
'Compra',
"Compra #{$compra->id}"
);