@php use App\Models\Setting; use App\Support\AddressFormatter; use App\Support\AmountInWords; $company = [ 'name' => Setting::get('company_name', config('app.name')), 'address' => Setting::get('company_address', ''), 'pincode' => Setting::get('company_pincode', ''), 'gstin' => Setting::get('company_gstin', ''), 'owner' => Setting::get('company_owner', ''), ]; $companyAddress = AddressFormatter::flow($company['address']); if ($company['pincode']) { $companyAddress = trim($companyAddress.' - '.$company['pincode'], ' -'); } // The same bank details the invoices print (Settings), so online payment goes to the right account. $bank = [ 'name' => Setting::get('bank_name', ''), 'account' => Setting::get('bank_account_number', ''), 'ifsc' => Setting::get('bank_ifsc', ''), 'branch' => Setting::get('bank_branch', ''), 'swift' => Setting::get('bank_swift', ''), ]; $hasBank = collect($bank)->filter()->isNotEmpty(); // A one-time agreement may leave the retailer's details empty: they print as lines to write on. $blank = '____________________________'; $customerAddress = trim(collect([AddressFormatter::flow($customer->address), $customer->city, $customer->state, $customer->pincode])->filter()->implode(', ')); // 12500 -> "12,500", 12500.5 -> "12,500.50": Indian digit grouping is not needed on a short agreement. $money = fn (float $n) => 'Rs. '.number_format($n, $n == floor($n) ? 0 : 2); $percent = fn (float $n) => rtrim(rtrim(number_format($n, 2), '0'), '.').'%'; $months = fn (int $n) => $n === 1 ? 'one (1) month' : "{$n} months"; $bills = fn (int $n) => $n === 1 ? 'first bill' : "first {$n} bills"; $cn = e($company['name']); $securityWords = e(AmountInWords::rupees($securityAmount, 'Rupees')); // [title, text, extra html shown under the text] $clauses = []; if ($discount > 0) { $clauses[] = [ 'Trade discount', "The Retailer shall be entitled to a flat discount of {$percent($discount)} on the MRP (inclusive of GST) of every product purchased from {$cn}. GST, as applicable, is shown on each invoice.", null, ]; } if ($baAmount > 0 && $baTarget > 0) { $capText = $baCap ? "Once the monthly billing reaches {$money($baTarget)}, the BA salary stays fixed at {$money($baAmount)} for that month." : 'Above that billing the BA salary continues to grow at the same rate.'; $clauses[] = [ 'BA (Beauty Advisor) salary', "On a monthly billing of {$money($baTarget)} to {$cn}, a BA salary of {$money($baAmount)} per month shall be provided for the Retailer's counter. Billing is counted net of sales returns. If the monthly billing is below {$money($baTarget)}, the BA salary is reduced in the same proportion. {$capText}", null, ]; } $clauses[] = [ 'Credit terms', "The {$bills($creditBills)} shall be on credit. Before the next bill is raised, the payment of the previous bill must be cleared in full.", null, ]; $clauses[] = [ 'Replacement of stock', "Non-moving stock can be replaced with other products of the same MRP, provided the Retailer asks for the replacement at least {$months($replaceMonths)} before the expiry date of that stock. Unattended stock that has passed its expiry date is not eligible for return or replacement.", null, ]; if ($securityAmount > 0) { $clauses[] = [ 'Security', "The Retailer shall provide a cheque of {$money($securityAmount)} ({$securityWords}) in favour of {$cn} as security.".($chequeNumber || $chequeBank ? ' Cheque no. '.e($chequeNumber ?: '—').', drawn on '.e($chequeBank ?: '—').'.' : ''), null, ]; } $clauses[] = [ 'Documents required', 'The Retailer shall provide copies of the following documents along with this agreement:', '
[   ] Aadhaar card      [   ] PAN card
', ]; if ($hasBank) { $rows = collect([ ["A/c Holder's Name", $company['name']], ['Bank Name', $bank['name']], ['A/c No.', $bank['account']], ['Branch & IFS Code', collect([$bank['branch'], $bank['ifsc']])->filter()->implode(' & ')], ['SWIFT Code', $bank['swift']], ])->filter(fn ($r) => $r[1] !== '' && $r[1] !== null); $table = ''.$rows->map(fn ($r) => '')->implode('').'
'.e($r[0]).''.e($r[1]).'
'; $clauses[] = [ 'Payments', "Online payment to {$cn} can be made using the bank details below:", $table, ]; } @endphp
{{ $company['name'] }}
@if ($companyAddress)
{{ $companyAddress }}
@endif @if ($company['gstin'])
GSTIN/UIN: {{ $company['gstin'] }}
@endif

RETAILER AGREEMENT

Dated {{ $agreementDate->format('d F Y') }}@if ($place) · {{ $place }}@endif

This agreement is made between the following parties and sets out the terms on which the Retailer buys from {{ $company['name'] }}.

{{ $company['name'] }}
@if ($company['owner']){{ $company['owner'] }}
@endif @if ($companyAddress){{ $companyAddress }}
@endif @if ($company['gstin'])GSTIN/UIN: {{ $company['gstin'] }}@endif
(the "Company")
@if ($customer->exists || filled($customer->name)) {{ $customer->name }}
@if ($customer->contact_person){{ $customer->contact_person }}
@endif @if ($customerAddress){{ $customerAddress }}
@endif @if ($customer->gstin)GSTIN/UIN: {{ $customer->gstin }}
@endif @if ($customer->phone)Phone: {{ $customer->phone }}@endif @else {{ $blank }}
Address: {{ $blank }}
GSTIN/UIN: {{ $blank }}
Phone: {{ $blank }} @endif
(the "Retailer")
    @foreach ($clauses as [$title, $text, $extra])
  1. {{ $title }}. {!! $text !!}@if ($extra){!! $extra !!}@endif
  2. @endforeach

Both parties have read and understood the terms above and agree to them.

For {{ $company['name'] }}
Authorised signatory
For {{ filled($customer->name) ? $customer->name : 'the Retailer' }}
Retailer{{ $customer->contact_person ? ' · '.$customer->contact_person : '' }}