diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 703c66c..5757770 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -2,12 +2,20 @@ namespace App\Http\Controllers; +use Inertia\Inertia; use App\Models\Customer; use App\Support\ApiDataTransformer; -use Illuminate\Support\Facades\Storage; class CustomerController extends Controller { + + public function show() + { + return Inertia::render('Customers', [ + 'customersData' => $this->index() + ]); + } + public function index() { $customers = Customer::with(['contacts' => function ($query) { diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 5c48483..3834aa9 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -5,10 +5,11 @@ namespace App\Http\Controllers; +use Inertia\Inertia; use App\Models\Invoice; use Barryvdh\DomPDF\Facade\Pdf; use horstoeko\zugferdlaravel\Facades\ZugferdLaravel; -use horstoeko\zugferd\codelists\ZugferdInvoiceType; +// use horstoeko\zugferd\codelists\ZugferdInvoiceType; use horstoeko\zugferd\codelists\ZugferdUnitCodes; use horstoeko\zugferd\codelists\ZugferdVatCategoryCodes; use horstoeko\zugferd\codelists\ZugferdVatTypeCodes; @@ -19,10 +20,53 @@ use App\Support\ApiDataTransformer; use DateTime; use tbQuar\Facades\Quar; -use Illuminate\Support\Facades\Log; class InvoiceController extends Controller { + public function show() + { + return Inertia::render('Invoices', ['invoicesData' => $this->summaryThisYear()] + ); + } + + public function summaryAll() + { + $invoices = Invoice::select() + ->orderBy('invoice_date', 'asc') + ->orderByRaw("CAST(SUBSTRING(nr, 4) AS UNSIGNED) ASC") + ->get(); + + return $invoices->map(function ($invoice) { + return ApiDataTransformer::snakeToCamel($invoice->toArray()); + }); + } + + public function summaryThisYear() + { + $invoices = Invoice::select() + ->where('invoice_date', '>=', new DateTime('first day of january this year')->format('Y-m-d')) + ->orderBy('invoice_date', 'asc') + ->orderByRaw("CAST(SUBSTRING(nr, 4) AS UNSIGNED) ASC") + ->get(); + + return $invoices->map(function ($invoice) { + return ApiDataTransformer::snakeToCamel($invoice->toArray()); + }); + } + + public function summaryBeforeThisYear() + { + $invoices = Invoice::select() + ->where('invoice_date', '<', new DateTime('first day of january this year')->format('Y-m-d')) + ->orderBy('invoice_date', 'asc') + ->orderByRaw("CAST(SUBSTRING(nr, 4) AS UNSIGNED) ASC") + ->get(); + + return $invoices->map(function ($invoice) { + return ApiDataTransformer::snakeToCamel($invoice->toArray()); + }); + } + public function index() { $invoices = Invoice::with([ diff --git a/app/Http/Controllers/LineItemController.php b/app/Http/Controllers/LineItemController.php new file mode 100644 index 0000000..6629216 --- /dev/null +++ b/app/Http/Controllers/LineItemController.php @@ -0,0 +1,21 @@ +where('invoice_id', $invoiceId) + ->orderBy('position', 'desc') + ->get(); + + return $items->map(function ($item) { + return ApiDataTransformer::snakeToCamel($item->toArray()); + }); + } +} diff --git a/resources/js/components/documents/DocumentTable.vue b/resources/js/components/documents/DocumentTable.vue index a990974..4eae226 100644 --- a/resources/js/components/documents/DocumentTable.vue +++ b/resources/js/components/documents/DocumentTable.vue @@ -114,9 +114,9 @@ const calcTaxes = (amount: number) => { Rechnung - Netto - - + Netto + + @@ -135,12 +135,12 @@ const calcTaxes = (amount: number) => { toLocalDate(invoice.invoiceDate) }} - {{ invoice.customer?.companyName }}
+ {{ invoice.billingData?.companyName }}
{{ invoice.title }}
+ {{ invoice.billingData?.companyName }}