Files
Verde-Web/app/Models/StoreSale.php
admin 989f4b87b9 feat(backend): complete Module 12 (partner stores)
partner_stores, store_inventories, store_purchases, store_sales tables.
Promotes qr_code_batches.target_store_id and qr_codes.assigned_to_store_id
to real FKs. StoreOperations service handles wholesale issuance
(generates fresh batch -> codes go allocated to store -> inventory tops
up -> StorePurchase recorded) and resident sales (codes flip allocated
-> active to a household, commission computed at the store's rate).
Admin endpoints: store CRUD, issue-inventory, record-sale.

160 feature tests passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 02:55:29 +08:00

39 lines
883 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class StoreSale extends Model
{
use HasFactory;
protected $fillable = [
'store_id', 'household_id', 'quantity',
'retail_price_centavos', 'commission_centavos',
'payment_id', 'sold_at',
];
protected function casts(): array
{
return [
'sold_at' => 'datetime',
'quantity' => 'integer',
'retail_price_centavos' => 'integer',
'commission_centavos' => 'integer',
];
}
public function store(): BelongsTo
{
return $this->belongsTo(PartnerStore::class, 'store_id');
}
public function household(): BelongsTo
{
return $this->belongsTo(Household::class);
}
}