@extends('admin.layout.master') @section('title') @Lang('admin.tax_return') @stop @section('page-breadcrumb') @include('admin.layout.breadcrumb_view') @stop @section('page-actions') @include('admin.report_vat.parts.buttons') @stop @section('page-content')

@Lang('admin.tax_return')


{{ csrf_field() }}
@if($results)
@if ($start_date || $end_date) @endif @php $total_p1 = 0; $total_n1 = 0; $total_s11 = 0; $total_sale_amount = 0; $final_p_row = 0; $saleTotalsPrinted = false; // Helper (من غير دوال خارجية) $get = fn($arr, $key) => (float) ($arr[$key] ?? 0); @endphp @foreach ($tax_returns as $item) @php $taxId = $item->tax_id; $taxRate = (float) ($item->tax->value ?? 0); // مثال: 0.15 $taxDiv = (1 + $taxRate); // (1 + tax) @endphp @if($item->tax_type == 1) @php $total_sales = $get($total_sale_invoice, $taxId); $total_return_sales = $get($total_sale_return_invoice, $taxId); $total_notice_credit = $get($total_notice_creditor_invoice, $taxId); $total_notice_debit = $get($total_notice_debit_invoice, $taxId); $total_s = ($total_sales - $total_return_sales); $total_n = ($total_notice_debit - $total_notice_credit); // VAT = Net / (1+rate) * rate $final_sale_row = ($taxDiv > 0) ? (($total_s + $total_n) / $taxDiv * $taxRate) : 0; $total_s11 += $total_s; $total_n1 += $total_n; $total_sale_amount += $final_sale_row; @endphp @else @if(!$saleTotalsPrinted) @php $saleTotalsPrinted = true; @endphp @endif @php $total_purchase = $get($total_purshase_invoice, $taxId); $total_purchase_return = $get($total_purshase_return_invoice, $taxId); $total_p = ($total_purchase - $total_purchase_return); $total_p12 = ($taxDiv > 0) ? ($total_p / $taxDiv * $taxRate) : 0; $total_p1 += $total_p; $final_p_row += $total_p12; @endphp @endif @endforeach @php $netVat = $total_sale_amount - $final_p_row; @endphp
@Lang('admin.start_date'):{{ $start_date }} - @Lang('admin.end_date') :{{ $end_date }}
Tax Description Tax Code Amount (SAR) Adjustments (SAR) VAT Amount (SAR)
{{ $item->name }} {{ $item->tax->name }} {{ $total_s }} {{ $total_n }} {{ $final_sale_row }}
Total Sales - {{ $total_s11 }} {{ $total_n1 }} {{ $total_sale_amount }}
{{ $item->name }} {{ $item->tax->name }} {{ $total_p }} {{ $total_p12 }}
Total Purchases - {{ $total_p1 }} - {{ $final_p_row }}
Total VAT due for current period {{ $netVat }}
Corrections from previous period (between SAR +/- 15,000)
VAT credit carried forward from previous period
Net VAT due (or reclaimed) {{ $netVat }}
@endif @stop @section('css') @stop @section('js')