@php use App\Http\Controllers\StatementsController; @endphp @extends('layouts.nav') @section('title') Tax Report @endsection @section('content')

Tax Report

Tax Report
@if (session('success'))
{{ session('success') }}
@endif @if ($errors->any())
@foreach ($errors->all() as $error)
{{ $error }}
@endforeach
@endif
@csrf
Tax Description
From Period
To Period
Select Currency
From
To

{{$name}} Statement

Date

@php use Carbon\Carbon; $todayLongDate = Carbon::now()->format(' F j, Y'); @endphp

{{$todayLongDate}}

Account

{{$code}}

Currency: {{$currnames}}

From: {{$from}} To: {{$to}}

@php use Illuminate\Support\Str; $outputTrans = collect($trans)->filter(function ($tran) { return strtolower($tran->Source) === 'customer' || strtolower($tran->Source) === 'tenant'; }); $inputTrans = collect($trans)->filter(function ($tran) { return strtolower($tran->Source) === 'supplier'; }); function calculateTotals($transactions) { $totals = [ 'invoice' => 0, 'tax' => 0, 'incl' => 0, 'rate' => 0, ]; foreach ($transactions as $tran) { $invoiceAmount = $tran->Price * $tran->Qnty; $taxAmount = $invoiceAmount * ($tran->Tax / 100); $amountIncl = $invoiceAmount - $taxAmount; $totals['invoice'] += $invoiceAmount; $totals['tax'] += $taxAmount; $totals['incl'] += $amountIncl; $totals['rate'] += $tran->Tax; } return $totals; } $outputTotals = calculateTotals($outputTrans); $inputTotals = calculateTotals($inputTrans); @endphp
Output Tax [Tenants]
@foreach ($outputTrans as $tran) @php $invoiceAmount = $tran->Price * $tran->Qnty; $taxAmount = $invoiceAmount * ($tran->Tax / 100); $amountIncl = $invoiceAmount - $taxAmount; @endphp @endforeach
Date Name Inv No Inv Amount(USD) Tax% Tax Amount(USD) Total(incl)
{{ $tran->EntryDate }} {{ \App\Http\Controllers\StatementsController::getAccountName($tran->Source, $tran->AccSubCode) }} {{ $tran->Batch }} {{ number_format($invoiceAmount, 2) }} {{ $tran->Tax }} {{ number_format($taxAmount, 2) }} {{ number_format($amountIncl, 2) }}
Total Output Tax {{ number_format($outputTotals['invoice'], 2) }} {{ number_format($outputTotals['tax'], 2) }} {{ number_format($outputTotals['incl'], 2) }}
Input Tax [Suppliers]
@foreach ($inputTrans as $tran) @php $invoiceAmount = $tran->Price * $tran->Qnty; $taxAmount = $invoiceAmount * ($tran->Tax / 100); $amountIncl = $invoiceAmount - $taxAmount; @endphp @endforeach `
Date Name Inv No Inv Amount(USD) Tax% Tax Amount(USD) Total(incl)
{{ $tran->EntryDate }} {{ \App\Http\Controllers\StatementsController::getAccountName($tran->Source, $tran->AccSubCode) }} {{ $tran->Batch }} {{ number_format($invoiceAmount, 2) }} {{ $tran->Tax }} {{ number_format($taxAmount, 2) }} {{ number_format($amountIncl, 2) }}
Total Input Tax {{ number_format($inputTotals['invoice'], 2) }} {{ number_format($inputTotals['tax'], 2) }} {{ number_format($inputTotals['incl'], 2) }}
Net Tax USD{{ number_format($outputTotals['invoice'] - $inputTotals['invoice'], 2) }} USD{{ number_format($outputTotals['tax'] - $inputTotals['tax'], 2) }} USD{{ number_format($outputTotals['incl'] - $inputTotals['incl'], 2) }}
@endsection