<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class SubpedidoResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'nombre' => $this->nombre,
            'subtotal_productos' => number_format($this->totalSinBonos(),0),
            'subtotal_bonos' => number_format($this->getSubtotalBonos(),0),
            'bonos_de_transporte' => $this->cantidadBDT(),
            'subtotal_bonos_de_transporte' => number_format($this->getSubtotalBDT(),0),
            'total' => number_format($this->getTotal(),0),
            'total_menos_devoluciones' => number_format($this->getTotalMenosDevoluciones(),0),
            'grupo_de_compra' => $this->grupoDeCompra,
            'productos' => $this->productos,
            'aprobado' => (bool) $this->aprobado,
            'devoluciones_total' => (double) $this->devoluciones_total,
            'devoluciones_notas' => $this->devoluciones_notas
        ];
    }
}