<?php

namespace Bixo\Payment\Policies;

use Bixo\Payment\Models\Invoice;
use Illuminate\Foundation\Auth\User as Authenticatable;

trait InvoiceWorkflow
{

    /**
     * Determine if the given user can approve the given invoice.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function approve(Authenticatable $user, Invoice $invoice)
    {
        if ($user->canDo('payment.invoice.approve')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given invoice.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function submit(Authenticatable $user, Invoice $invoice)
    {
        if ($user->canDo('payment.invoice.submit')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given invoice.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function publish(Authenticatable $user, Invoice $invoice)
    {
        if ($user->canDo('payment.invoice.publish')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given invoice.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function unpublish(Authenticatable $user, Invoice $invoice)
    {
        if ($user->canDo('payment.invoice.unpublish')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given invoice.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function archive(Authenticatable $user, Invoice $invoice)
    {
        if ($user->canDo('payment.invoice.archive')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given invoice.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function unarchive(Authenticatable $user, Invoice $invoice)
    {
        if ($user->canDo('payment.invoice.unarchive')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given invoice.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function reject(Authenticatable $user, Invoice $invoice)
    {
        if ($user->canDo('payment.invoice.reject')) {
            return true;
        }

        return false;
    }

}