<?php

namespace POPxPMPro\Providers;

defined( 'ABSPATH' ) || die( 'Not allowed.' );

class RefundOrderItem extends OrderItem {

    public function get_total() {
        return -1 * abs( parent::get_total() );
    }

    public function get_total_tax() {
        return -1 * abs( parent::get_total_tax() );
    }

    public function get_data() {
        $data = parent::get_data();

        $data['subtotal']     = -1 * abs( (float) $data['subtotal'] );
        $data['subtotal_tax'] = -1 * abs( (float) $data['subtotal_tax'] );
        $data['total']        = -1 * abs( (float) $data['total'] );
        $data['total_tax']    = -1 * abs( (float) $data['total_tax'] );
        $data['taxes']        = [
            'subtotal' => [ 1 => $data['subtotal_tax'] ],
            'total'    => [ 1 => $data['total_tax'] ],
        ];

        return $data;
    }
}
