support for items
This commit is contained in:
53
app/Http/Controllers/HomeController.php
Normal file
53
app/Http/Controllers/HomeController.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Modules\Invoice\Actions\GenerateInvoiceExcell;
|
||||||
|
use App\Modules\Invoice\Data\InvoiceExcellData;
|
||||||
|
use App\Modules\Invoice\Data\InvoiceItem;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class HomeController extends Controller
|
||||||
|
{
|
||||||
|
public function index(): string
|
||||||
|
{
|
||||||
|
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 işläp taýýarlamak barada',
|
||||||
|
unit: 'ay',
|
||||||
|
quantity: 1,
|
||||||
|
unit_price: 25000,
|
||||||
|
vat: null,
|
||||||
|
excludingVat: null,
|
||||||
|
vat_percentage: null,
|
||||||
|
vat_tmt: null,
|
||||||
|
total: 25000,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
))
|
||||||
|
->handle()
|
||||||
|
->save();
|
||||||
|
|
||||||
|
return 'F';
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
app/Modules/Invoice/.DS_Store
vendored
BIN
app/Modules/Invoice/.DS_Store
vendored
Binary file not shown.
@@ -255,6 +255,6 @@ class GenerateInvoiceExcell
|
|||||||
*/
|
*/
|
||||||
public function satynAlyjyBankyMaglumatlary(): string
|
public function satynAlyjyBankyMaglumatlary(): string
|
||||||
{
|
{
|
||||||
return 'Satyn alyjynyň ' . $this->data->buyer_bank_data;
|
return 'Satyn alyjynyň '.$this->data->buyer_bank_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,5 +24,8 @@ class InvoiceExcellData
|
|||||||
public string $buyer_bank,
|
public string $buyer_bank,
|
||||||
public string $buyer_bank_address,
|
public string $buyer_bank_address,
|
||||||
public string $buyer_bank_data,
|
public string $buyer_bank_data,
|
||||||
|
|
||||||
|
/** @var array<int, InvoiceItem> */
|
||||||
|
public array $items,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|||||||
20
app/Modules/Invoice/Data/InvoiceItem.php
Normal file
20
app/Modules/Invoice/Data/InvoiceItem.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\Invoice\Data;
|
||||||
|
|
||||||
|
class InvoiceItem
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public string $name,
|
||||||
|
public int|string $unit,
|
||||||
|
public int $quantity,
|
||||||
|
public int|float $unit_price,
|
||||||
|
public null|int|float $vat,
|
||||||
|
public null|int|float $excludingVat,
|
||||||
|
public null|int|float $vat_percentage,
|
||||||
|
public null|int|float $vat_tmt,
|
||||||
|
public int|float|string $total,
|
||||||
|
) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
BIN
public/write.xls
BIN
public/write.xls
Binary file not shown.
@@ -1,35 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Modules\Invoice\Actions\GenerateInvoiceExcell;
|
use App\Http\Controllers\HomeController;
|
||||||
use App\Modules\Invoice\Data\InvoiceExcellData;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
// Route::redirect('/', '/panel');
|
Route::get('/', [HomeController::class, 'index']);
|
||||||
|
|
||||||
Route::get('/', function () {
|
|
||||||
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')
|
|
||||||
))
|
|
||||||
->handle()
|
|
||||||
->save();
|
|
||||||
|
|
||||||
return 'F';
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user