<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\CuotaCond as CuotaCondResources;

class NotiPago extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'idNP'          => strval($this->idNP),
            'nroNP'         => strval($this->idNP - 100100000000000000),
            'fecha'         => date("d.m.y h:i a",strtotime($this->dateNP)),
            'idE'           => strval($this->idE),
            'codEdif'       => $this->EntidadView->codESuper,
            'nameEdif'      => $this->EntidadView->nameESuper,
            'codApto'       => $this->EntidadView->codE,
            'nameApto'      => $this->EntidadView->nameE,
            'codCliente'    => isset($this->EntidadView->codCliente)?$this->EntidadView->codCliente:'',
            'estadoNP'      => $this->estadoNP,
            'nroErrorNP'    => $this->nroErrorNP,
            'origenNP'      => $this->origenNP,
            'typeNP'        => $this->typeNP,
            'type'          => 'Transferencia',
            'fechaPago'     => date("d.m.Y",strtotime($this->datePagoNP)),
            'datePagoNP'    => date("Y-m-d",strtotime($this->datePagoNP)),
            'bancoNP'       => $this->bancoNP, 
            'banco'         => $this->BancoView->nombreBanco,
//            'banco'         => $this->BancoView->codBanco.' | '.$this->BancoView->nombreBanco,
            'bancoNroCta'   => $this->BancoView->nroCuenta,
            'bancoCta'      => $this->BancoView->codCTA,
            'bancoCtaJSys'  => $this->BancoView->ctaSysOld,
            'bancoOrigen'   => $this->bancoOrigenNP,
            'bancoOrigenTxt'   =>$this->getCodBancoOrigen(), 
            'nroRef'        => $this->nroRefNP,
            'cedula'        => $this->cedulaNP,
            'monto'         => number_format($this->montoNP, 2, ',', '.') .' '. ($this->idMoneda==1001?'Bs':'$'),
            'montoNP'       => $this->montoNP,
            'idMoneda'      => $this->idMoneda,
            'idEUser'       => strval($this->idEUser),
            'cuotasCond'    => CuotaCondResources::collection($this->getCuotasCond()),
            'message'       => 'OK',
        ];
    }
}
