invoice items so far getting better
This commit is contained in:
@@ -33,16 +33,49 @@ class HomeController extends Controller
|
||||
|
||||
items: [
|
||||
new InvoiceItem(
|
||||
name: 'Programma üpjünçiligini işläp taýýarlamak barada',
|
||||
name: 'Programma üpjünçiligini hyzmat etmek barada',
|
||||
unit: 'ay',
|
||||
quantity: 1,
|
||||
unit_price: 25000,
|
||||
quantity: 2,
|
||||
unit_price: 100000,
|
||||
vat: null,
|
||||
excludingVat: null,
|
||||
vat_excluded: null,
|
||||
vat_percentage: null,
|
||||
vat_tmt: null,
|
||||
total: 25000,
|
||||
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şäň taýýarlamak barada',
|
||||
unit: 'ay',
|
||||
quantity: 2,
|
||||
unit_price: 100000,
|
||||
vat: null,
|
||||
vat_excluded: null,
|
||||
vat_percentage: null,
|
||||
vat_tmt: null,
|
||||
total: 200000,
|
||||
)
|
||||
]
|
||||
))
|
||||
->handle()
|
||||
|
||||
BIN
app/Modules/Invoice/.DS_Store
vendored
BIN
app/Modules/Invoice/.DS_Store
vendored
Binary file not shown.
@@ -3,11 +3,14 @@
|
||||
namespace App\Modules\Invoice\Actions;
|
||||
|
||||
use App\Modules\Invoice\Data\InvoiceExcellData;
|
||||
use App\Modules\Invoice\Data\InvoiceItem;
|
||||
use App\Modules\Makeable;
|
||||
use Illuminate\Support\Carbon;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Font;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
@@ -120,6 +123,72 @@ class GenerateInvoiceExcell
|
||||
foreach ($data as $cell => $value) {
|
||||
$this->worksheet->getCell($cell)->setValue($value);
|
||||
}
|
||||
|
||||
$items = collect($this->data->items);
|
||||
|
||||
$itemCellNumber = 25;
|
||||
$numberFormat = $this->worksheet->getStyle('E' . 25)->getNumberFormat()->getFormatCode();
|
||||
$items->each(function (InvoiceItem $item, int $index) use (&$itemCellNumber, $numberFormat) {
|
||||
$this->worksheet->getCell('A' . $itemCellNumber)->setValue($index + 1);
|
||||
$this->worksheet->getCell('B' . $itemCellNumber)->setValue($item->name);
|
||||
$this->worksheet->getCell('C' . $itemCellNumber)->setValue($item->unit);
|
||||
$this->worksheet->getCell('D' . $itemCellNumber)->setValue($item->quantity);
|
||||
$this->worksheet->getCell('E' . $itemCellNumber)->setValue($item->unit_price);
|
||||
$this->worksheet->getCell('F' . $itemCellNumber)->setValue($item->vat);
|
||||
$this->worksheet->getCell('G' . $itemCellNumber)->setValue($item->vat_excluded);
|
||||
$this->worksheet->getCell('H' . $itemCellNumber)->setValue($item->vat_percentage);
|
||||
$this->worksheet->getCell('I' . $itemCellNumber)->setValue($item->vat_tmt);
|
||||
$this->worksheet->getCell('J' . $itemCellNumber)->setValue($item->total);
|
||||
|
||||
// Set font-family, alingment, and borders for all of them...
|
||||
$this->worksheet->getStyle('A' . $itemCellNumber . ':J' . $itemCellNumber)->applyFromArray([
|
||||
'font' => [
|
||||
'bold' => false,
|
||||
'size' => 10,
|
||||
'name' => 'Times New Roman'
|
||||
],
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => Alignment::VERTICAL_CENTER,
|
||||
],
|
||||
'borders' => [
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// Invoice Name...
|
||||
$this->worksheet->getCell('B' . $itemCellNumber)->getStyle()->applyFromArray([
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_LEFT,
|
||||
'vertical' => Alignment::VERTICAL_CENTER,
|
||||
]
|
||||
]);
|
||||
|
||||
$this->worksheet->getCell('D' . $itemCellNumber)->getStyle()->applyFromArray([
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->worksheet->getCell('E' . $itemCellNumber)->getStyle()->applyFromArray([
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
]);
|
||||
$this->worksheet->getCell('J' . $itemCellNumber)->getStyle()->applyFromArray([
|
||||
'font' => [
|
||||
'bold' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
// Invoice number format...
|
||||
$this->worksheet->getStyle('E' . $itemCellNumber)->getNumberFormat()->setFormatCode($numberFormat);
|
||||
$this->worksheet->getStyle('J' . $itemCellNumber)->getNumberFormat()->setFormatCode($numberFormat);
|
||||
|
||||
$itemCellNumber++;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,12 +9,15 @@ class InvoiceItem
|
||||
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 null|int|float|string $vat,
|
||||
public null|int|float|string $vat_excluded,
|
||||
public null|int|float|string $vat_percentage,
|
||||
public null|int|float|string $vat_tmt,
|
||||
public int|float|string $total,
|
||||
) {
|
||||
// ...
|
||||
$this->vat = $vat ?: 'x';
|
||||
$this->vat_excluded = $vat_excluded ?: 'x';
|
||||
$this->vat_percentage = $vat_percentage ?: 'x';
|
||||
$this->vat_tmt = $vat_tmt ?: 'x';
|
||||
}
|
||||
}
|
||||
|
||||
BIN
app/Modules/Invoice/Resources/Docs/invoice-original.xls
Executable file
BIN
app/Modules/Invoice/Resources/Docs/invoice-original.xls
Executable file
Binary file not shown.
Binary file not shown.
BIN
public/write.xls
BIN
public/write.xls
Binary file not shown.
Reference in New Issue
Block a user