1 | <?php |
2 | |
3 | require_once __DIR__ . "/../../lib/php/ProblemDetails.php"; |
4 | require_once __DIR__ . "/DetalleDeVenta.php"; |
5 | |
6 | class Venta |
7 | { |
8 | |
9 | public int $id; |
10 | public bool $enCaptura; |
11 | |
12 | public array $detalles; |
13 | |
14 | public function __construct( |
15 | bool $enCaptura = false, |
16 | array $detalles = [], |
17 | int $id = 0 |
18 | ) { |
19 | $this->id = $id; |
20 | $this->enCaptura = $enCaptura; |
21 | $this->detalles = $detalles; |
22 | } |
23 | |
24 | public function valida() |
25 | { |
26 | foreach ($this->detalles as $detalle) { |
27 | if (!($detalle instanceof DetalleDeVenta)) |
28 | throw new ProblemDetails( |
29 | status: ProblemDetails::BadRequest, |
30 | type: "/error/detalledeventaincorrecto.html", |
31 | title: "Tipo incorrecto para un etalle de venta.", |
32 | ); |
33 | $detalle->valida(); |
34 | } |
35 | } |
36 | } |
37 | |