<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class BancoTrans extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        //reconversion 2021.10
        if($this->dateT < '2021-10-01'){
            $montoDT = round($this->montoDT/10000)/100;
        }else{
            $montoDT = $this->montoDT;
        }

        return [
            "idE"           => strval($this->idE),
            "idDT"          => strval($this->idDT),
            "ctaT"          => $this->ctaT,
            "dateT"         => date("d/m/Y",strtotime($this->dateT)),
            "nameTypeT"     => $this->nameTypeT,
            "refT"          => $this->refT,
            "descT"         => $this->descT,
            "ctaDT"         => $this->ctaDT,
            "descripcionDT" => $this->descripcionDT,
            "typeDT"        => $this->typeDT,
            "idMoneda"      => $this->idMoneda,
 
            "codESuper"     => is_null($this->codESuper)?'':$this->codESuper,
            "codE"          => $this->codE,
            "montoDT_abono" => ($this->dhDT==0)?number_format($montoDT, 2, ',', '.'):'',
            "montoDT_cargo" => ($this->dhDT==1)?number_format($montoDT, 2, ',', '.'):'',

            "countTcBase"   => $this->countTcBase,

            "info"          => '',
//            "periodo"       => $this->getPeriodo(),
        ];

    }
}
