feat(purchase,sale,ticket): expose refunded total summary in admin sales and tickets

This commit is contained in:
2026-09-11 16:23:23 -03:00
parent 4bb4f526e4
commit 4f7ede1072
8 changed files with 84 additions and 4 deletions

View File

@@ -541,17 +541,56 @@ class AdminAppTicketControllerTest extends TestCase
$this->createTicket($tenant, $admin)->update(['disabled_at' => now()]);
$this->createTicket($otherTenant, $otherUser)->update(['used_at' => now()]);
$catalogItem = CatalogItem::query()->create([
'tenant_code' => $tenant->codigo,
'slug' => 'refund-summary-item',
'nombre' => 'Entrada',
'precio' => '1000.00',
]);
$purchase = Purchase::query()->create([
'tenant_codigo' => $tenant->codigo,
'status' => Purchase::STATUS_PAID,
'total' => '1000.00',
]);
PurchaseItem::query()->create([
'compra_id' => $purchase->id,
'source_catalog_item_id' => $catalogItem->id,
'nombre' => 'Entrada',
'item_nombre' => 'Entrada',
'cantidad' => 1,
'precio_unitario' => '1000.00',
'total' => '1000.00',
'refunded_amount' => '250.00',
]);
$otherPurchase = Purchase::query()->create([
'tenant_codigo' => $otherTenant->codigo,
'status' => Purchase::STATUS_PAID,
'total' => '2000.00',
]);
PurchaseItem::query()->create([
'compra_id' => $otherPurchase->id,
'source_catalog_item_id' => $catalogItem->id,
'nombre' => 'Otra entrada',
'item_nombre' => 'Otra entrada',
'cantidad' => 1,
'precio_unitario' => '2000.00',
'total' => '2000.00',
'refunded_amount' => '2000.00',
]);
$this->getJson('/api/v1/adminapp/tenant/tickets?q=does-not-match')
->assertOk()
->assertJsonCount(0, 'data')
->assertJsonPath('scanned_tickets', 0)
->assertJsonPath('total_tickets', 0);
->assertJsonPath('total_tickets', 0)
->assertJsonPath('refunded_total', '250.00');
$this->getJson('/api/v1/adminapp/tenant/tickets')
->assertOk()
->assertJsonCount(5, 'data')
->assertJsonPath('scanned_tickets', 1)
->assertJsonPath('total_tickets', 2);
->assertJsonPath('total_tickets', 2)
->assertJsonPath('refunded_total', '250.00');
}
public function test_it_returns_structured_variant_properties(): void