Changeset View
Changeset View
Standalone View
Standalone View
src/app/Documents/Receipt.php
<?php | <?php | ||||
namespace App\Documents; | namespace App\Documents; | ||||
use App\Payment; | use App\Payment; | ||||
use App\Providers\PaymentProvider; | |||||
use App\User; | use App\User; | ||||
use App\Wallet; | use App\Wallet; | ||||
use Barryvdh\DomPDF\Facade\Pdf; | use Barryvdh\DomPDF\Facade\Pdf; | ||||
use Carbon\Carbon; | use Carbon\Carbon; | ||||
class Receipt | class Receipt | ||||
{ | { | ||||
/** @var \App\Wallet The wallet */ | /** @var \App\Wallet The wallet */ | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | protected function build() | ||||
$payment->vatRate = new \App\VatRate(); | $payment->vatRate = new \App\VatRate(); | ||||
$payment->vatRate->rate = 7.7; | $payment->vatRate->rate = 7.7; | ||||
$payment->credit_amount = $payment->amount + round($payment->amount * $payment->vatRate->rate / 100); | $payment->credit_amount = $payment->amount + round($payment->amount * $payment->vatRate->rate / 100); | ||||
return $payment; | return $payment; | ||||
}); | }); | ||||
} else { | } else { | ||||
$customer = $this->customerData(); | $customer = $this->customerData(); | ||||
$items = $this->wallet->payments() | $items = $this->wallet->payments() | ||||
->where('status', PaymentProvider::STATUS_PAID) | ->where('status', Payment::STATUS_PAID) | ||||
->where('updated_at', '>=', $start) | ->where('updated_at', '>=', $start) | ||||
->where('updated_at', '<', $end) | ->where('updated_at', '<', $end) | ||||
->where('amount', '<>', 0) | ->where('amount', '<>', 0) | ||||
->orderBy('updated_at') | ->orderBy('updated_at') | ||||
->get(); | ->get(); | ||||
} | } | ||||
$vatRate = 0; | $vatRate = 0; | ||||
Show All 9 Lines | protected function build() | ||||
$totalVat += $vat; | $totalVat += $vat; | ||||
$vatRate = $item->vatRate->rate; // TODO: Multiple rates | $vatRate = $item->vatRate->rate; // TODO: Multiple rates | ||||
} | } | ||||
$total += $amount; | $total += $amount; | ||||
$type = $item->type ?? null; | $type = $item->type ?? null; | ||||
if ($type == PaymentProvider::TYPE_REFUND) { | if ($type == Payment::TYPE_REFUND) { | ||||
$description = \trans('documents.receipt-refund'); | $description = \trans('documents.receipt-refund'); | ||||
} elseif ($type == PaymentProvider::TYPE_CHARGEBACK) { | } elseif ($type == Payment::TYPE_CHARGEBACK) { | ||||
$description = \trans('documents.receipt-chargeback'); | $description = \trans('documents.receipt-chargeback'); | ||||
} else { | } else { | ||||
$description = \trans('documents.receipt-item-desc', ['site' => $appName]); | $description = \trans('documents.receipt-item-desc', ['site' => $appName]); | ||||
} | } | ||||
return [ | return [ | ||||
'amount' => $this->wallet->money($amount), | 'amount' => $this->wallet->money($amount), | ||||
'description' => $description, | 'description' => $description, | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |