ultimatepos/Modules/Accounting/Resources/views/holding/consolidation.blade.php

140 lines
8.5 KiB
PHP

@extends('layouts.app')
@section('title', __('accounting::lang.consolidation'))
@section('content')
@include('accounting::layouts.nav')
<section class="content-header"><h1>@lang('accounting::lang.consolidation')</h1></section>
<section class="content">
@if(!empty($readiness))
<div class="box box-{{ $readiness['ready'] ? 'success' : 'warning' }}">
<div class="box-header with-border">
<h3 class="box-title">@lang('accounting::lang.consolidation_readiness')</h3>
</div>
<div class="box-body">
<p>
@lang('accounting::lang.holding_entities'): <strong>{{ $readiness['entities'] }}</strong> |
@lang('accounting::lang.entity_tagging'): <strong>{{ $readiness['tagging']['tagged_pct'] ?? 0 }}%</strong>
({{ $readiness['tagging']['untagged_lines'] ?? 0 }} @lang('accounting::lang.untagged_lines'))
</p>
@if(($readiness['fx']['total_issues'] ?? 0) > 0)
<p class="text-warning">@lang('accounting::lang.stale_fx_warning', ['count' => $readiness['fx']['total_issues']])</p>
@endif
@if(! $readiness['ready'])
<form action="{{ route('accounting.syncEntityTagging') }}" method="POST" style="display:inline">
@csrf
<button class="btn btn-sm btn-warning">@lang('accounting::lang.sync_entity_tagging')</button>
</form>
<a href="{{ route('accounting.syncExchangeRates') }}" class="btn btn-sm btn-default" onclick="event.preventDefault(); document.getElementById('fx-sync-form').submit();">@lang('accounting::lang.sync_exchange_rates_now')</a>
<form id="fx-sync-form" action="{{ route('accounting.syncExchangeRates') }}" method="POST" style="display:none">@csrf</form>
@endif
</div>
</div>
@endif
<div class="box box-primary">
<form action="{{ url('accounting/consolidation') }}" method="POST" class="box-body">
@csrf
<div class="row">
<div class="col-md-3"><input name="period_start" type="date" class="form-control" required></div>
<div class="col-md-3"><input name="period_end" type="date" class="form-control" required></div>
<div class="col-md-3">
<input name="consolidation_currency_code" type="text" value="{{ $defaults['target_currency_code'] ?? 'IRR' }}" class="form-control" maxlength="10" placeholder="@lang('accounting::lang.target_currency_code')">
</div>
<div class="col-md-3">
<select name="rate_mode" class="form-control">
<option value="market">@lang('accounting::lang.rate_mode_market')</option>
<option value="official">@lang('accounting::lang.rate_mode_official')</option>
</select>
</div>
</div>
<div class="row" style="margin-top: 10px;">
<div class="col-md-12">
<small class="text-muted">@lang('accounting::lang.base_currency_code'): {{ $defaults['base_currency_code'] ?? 'IRR' }}</small>
</div>
</div>
<div class="row" style="margin-top: 10px;">
@foreach($entities as $entity)
<div class="col-md-6" style="margin-bottom: 8px;">
<label>{{ $entity->name }} ({{ data_get($entity->meta, 'currency_code', 'IRR') }})</label>
<div class="row">
<div class="col-xs-6">
<input name="entity_rate[{{ $entity->id }}]" type="number" step="0.000001" min="0.000001" value="{{ $defaults['entity_rates'][$entity->id] ?? 1 }}" class="form-control" placeholder="@lang('accounting::lang.market_rate')">
</div>
<div class="col-xs-6">
<input name="entity_official_rate[{{ $entity->id }}]" type="number" step="0.000001" min="0.000001" value="{{ $defaults['official_entity_rates'][$entity->id] ?? ($defaults['entity_rates'][$entity->id] ?? 1) }}" class="form-control" placeholder="@lang('accounting::lang.official_rate')">
</div>
</div>
</div>
@endforeach
</div>
<div class="row" style="margin-top: 10px;">
<div class="col-md-12">
<a href="{{ route('accounting.exchangeRates') }}" class="btn btn-default btn-sm">@lang('accounting::lang.exchange_rates')</a>
<button class="btn btn-primary">@lang('accounting::lang.run_consolidation')</button>
</div>
</div>
</form>
</div>
@foreach($runs as $run)
<div class="box box-default">
<div class="box-header">
<h4>{{ $run->period_start }} - {{ $run->period_end }} ({{ $run->status }}) - {{ $run->currency_code }} / {{ $run->rate_mode ?? 'market' }}</h4>
@if($run->status === 'draft')
<form action="{{ route('accounting.finalizeConsolidation', $run->id) }}" method="POST" style="display:inline">@csrf
<button class="btn btn-xs btn-success">@lang('accounting::lang.finalize')</button>
</form>
@endif
</div>
<div class="box-body">
<p>@lang('accounting::lang.elimination_amount'): @format_currency($run->elimination_amount)</p>
@if(is_array($run->entity_balances))
<table class="table table-bordered">
<thead>
<tr>
<th>@lang('lang_v1.holding_entity')</th>
<th>@lang('accounting::lang.entity_currency')</th>
<th>@lang('accounting::lang.market_rate')</th>
<th>@lang('accounting::lang.official_rate')</th>
<th>@lang('accounting::lang.net_balance')</th>
<th>@lang('accounting::lang.converted_market_balance')</th>
<th>@lang('accounting::lang.converted_official_balance')</th>
<th>@lang('accounting::lang.rate_variance')</th>
</tr>
</thead>
<tbody>
@foreach($run->entity_balances as $entity)
<tr>
<td>{{ $entity['entity_name'] ?? '-' }}</td>
<td>{{ $entity['entity_currency'] ?? $run->currency_code }}</td>
<td>{{ $entity['market_rate'] ?? ($entity['exchange_rate'] ?? 1) }}</td>
<td>{{ $entity['official_rate'] ?? ($entity['exchange_rate'] ?? 1) }}</td>
<td>@format_currency($entity['net_balance'] ?? 0)</td>
<td>@format_currency($entity['converted_market_balance'] ?? ($entity['converted_net_balance'] ?? 0))</td>
<td>@format_currency($entity['converted_official_balance'] ?? ($entity['converted_net_balance'] ?? 0))</td>
<td>@format_currency($entity['rate_variance'] ?? 0)</td>
</tr>
@endforeach
</tbody>
</table>
@endif
@if(is_array($run->rate_comparison) && count($run->rate_comparison))
<h4>@lang('accounting::lang.rate_comparison_summary')</h4>
<table class="table table-condensed table-bordered">
<thead><tr><th>@lang('lang_v1.holding_entity')</th><th>@lang('accounting::lang.entity_currency')</th><th>@lang('accounting::lang.variance_pct')</th><th>@lang('accounting::lang.balance_variance')</th></tr></thead>
<tbody>
@foreach($run->rate_comparison as $row)
<tr>
<td>{{ $row['entity'] ?? '-' }}</td>
<td>{{ $row['currency'] ?? '-' }}</td>
<td>{{ $row['variance_pct'] ?? '-' }}%</td>
<td>@format_currency($row['balance_variance'] ?? 0)</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</div>
</div>
@endforeach
{{ $runs->links() }}
</section>
@endsection