<?php

use App\Modules\Invoice\Actions\GenerateInvoiceExcell;
use App\Modules\Invoice\Data\InvoiceExcellData;
use App\Modules\Invoice\Data\InvoiceItem;
use Carbon\Carbon;

GenerateInvoiceExcell::make()
    ->setTemplateFile(app_path('Modules/Invoice/Resources/Docs/invoice.xls'))
    ->setData(new InvoiceExcellData(
        number: random_int(1, 99),
        date: new Carbon('2024-11-08'),
        seller_firm_type: 'Telekeçi',
        seller_firm_name: 'Nurmuhammet Allanov Parahatowiç',
        seller_ssb: '201126532321',
        seller_bank_name: 'Türkmenistanyň „Halkbank“ paýdarlar täjirçilik banky',
        seller_bank_hb_1: '23206934160169902250000',
        seller_bank_hb_2: '21101934110100700005000',
        seller_bank_city: 'Aşgabat',
        seller_bank_bab: '390101601',

        buyer: 'Türkmenistanyň „Türkmenbaşy“ paýdarlar täjirçilik banky',
        buyer_address: '744000 Aşgabat ş., Çandebil şaýoly köç., 121,',
        buyer_bank: 'Türkmenistanyň Merkezi Banky',
        buyer_bank_address: 'Aşgabat ş.',
        buyer_bank_data: sprintf('şahsy salgyt belgisi %s, MFO %s, Hasap № %s', '101301000408', '390101304', '21101934110100300007000'),

        items: [
            new InvoiceItem(
                name: 'Programma üpjünçiligini hyzmat etmek barada',
                unit: 'ay',
                quantity: 2,
                unit_price: 100000,
                vat: null,
                vat_excluded: null,
                vat_percentage: null,
                vat_tmt: null,
                total: 200000,
            ),
            new InvoiceItem(
                name: 'Programma üpjünçiligini hyzmat etmek barada',
                unit: 'ay',
                quantity: 2,
                unit_price: 100000,
                vat: null,
                vat_excluded: null,
                vat_percentage: null,
                vat_tmt: null,
                total: 200000,
            ),
            new InvoiceItem(
                name: 'Programma üpjünçiligini hyzmat etmek barada',
                unit: 'ay',
                quantity: 2,
                unit_price: 100000,
                vat: null,
                vat_excluded: null,
                vat_percentage: null,
                vat_tmt: null,
                total: 200000,
            ),
            new InvoiceItem(
                name: 'Programma üpjünçiligini işläp taýýarlamak barada',
                unit: 'ay',
                quantity: 2,
                unit_price: 100000,
                vat: null,
                vat_excluded: null,
                vat_percentage: null,
                vat_tmt: null,
                total: 200000,
            ),
        ]
    ))
    ->handle()
    ->save();
