GithubHelp home page GithubHelp logo

Comments (10)

marayshi avatar marayshi commented on July 17, 2024 10

Hi

For any one face this issue
You just need to clear caches, view etc

php artisan config:clear
php artisan cache:clear
php artisan view:clear
php artisan clear-compiled
php artisan config:cache

from laravel-invoices.

PovilasKorop avatar PovilasKorop commented on July 17, 2024

@herrtxbias why do you implement that inside of routes/web.php file, and not in a Controller? Probably some class isn't found because of namespaces. Routes file isn't a class, so it's not the best place to write any such code.

from laravel-invoices.

herrtxbias avatar herrtxbias commented on July 17, 2024

I've putted it now in a Controller, but there i got the same problem.

from laravel-invoices.

PovilasKorop avatar PovilasKorop commented on July 17, 2024

@herrtxbias please post full code of the controller, and I will try to reproduce

from laravel-invoices.

herrtxbias avatar herrtxbias commented on July 17, 2024

`<?php

namespace App\Http\Controllers;

use App\Blocking;
use App\Booking;
use App\Customer;
use App\Price;
use App\Room;
use DateTime;
use Illuminate\Http\Request;
use LaravelDaily\Invoices\Classes\InvoiceItem;
use LaravelDaily\Invoices\Classes\Party;
use LaravelDaily\Invoices\Invoice;

class InvoiceController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}

/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 * @throws \Exception
 */
public function index($id)
{
    $booking = Booking::find($id);
    $customer = Customer::find($booking->customer);
    $diff = date_diff(new DateTime(date('d.m.Y', strtotime($booking->end))), new DateTime(date('d.m.Y', strtotime($booking->start))))->format('%a');
    $price = Price::find(Room::find($booking->room)->price);
    $room = Room::find($booking->room);

    $rabatt_ab = 0;
    $rabatt_wert = 0;
    $rabatte = explode(";", setting('preise.discounts'));

    $added = false;
    foreach ($rabatte as $r){
        $rab = explode(":", $r);
        if(!$added && $diff >= intval($rab[0])){
            $rabatt_ab = intval($rab[0]);
            $rabatt_wert = intval($rab[1]);
            $added = true;
        }
    }

    $client = new Party([
        'name'          => $customer->name,
        //'phone'         => '(520) 318-9486',
        //'custom_fields' => [
        //    'note'        => 'IDDQD',
        //    'business id' => '365#GG',
        //],
    ]);

    $customer = new Party([
        'name'          => setting('site.title'),
        //'address'       => 'The Green Street 12',
        //'code'          => '#22663214',
        //'custom_fields' => [
        //    'order number' => '> 654321 <',
        //],
    ]);

    $item = (new InvoiceItem())->title('Raumbuchung: '.$room->descr)->pricePerUnit($price->per_night)->quantity($diff);

    if($added){
        $item->discount($diff * $price->per_night * ($rabatt_wert/100));
    }

    $items = [
        $item,
        (new InvoiceItem())->title('ab '.$rabatt_ab.' Nächte Rabatt ('.$rabatt_wert.'%)'),
    ];

    $notes = [
        'your multiline',
        'additional notes',
        'in regards of delivery or something else',
    ];
    $notes = implode("<br>", $notes);

    $invoice = Invoice::make('receipt')
        ->series('BIG')
        ->sequence($booking->id)
        ->serialNumberFormat('{SEQUENCE}/{SERIES}')
        ->seller($client)
        ->buyer($customer)
        ->date(now()->subWeeks(3))
        ->dateFormat('d.m.Y')
        ->payUntilDays(14)
        ->currencySymbol('€')
        ->currencyCode('EUR')
        ->currencyFormat('{SYMBOL}{VALUE}')
        ->currencyThousandsSeparator('.')
        ->currencyDecimalPoint(',')
        ->filename($client->name . ' ' . $customer->name)
        ->addItems($items)
        //->notes($notes)
        ->logo(public_path('vendor/invoices/sample-logo.png'))
        // You can additionally save generated invoice to configured disk
        ->save('public');

    $link = $invoice->url();
    // Then send email to party with link

    // And return invoice itself to browser or have a different view
    return $invoice->stream();
}

}`

from laravel-invoices.

PovilasKorop avatar PovilasKorop commented on July 17, 2024

@herrtxbias unfortunately can't reproduce it in full because I don't have any other of your classes and models, but tried to play around hardcoding some values instead of your variables, and it works well for me.
Screen Shot 2020-02-25 at 9 40 30 PM

So maybe you can create Github project separately in full and assign me as a collaborator, then I could fully debug if I install full project locally. Otherwise I can't reproduce, sorry.

from laravel-invoices.

ivofrancisco avatar ivofrancisco commented on July 17, 2024

Thank you very much Marayshi.
It worked for me.

from laravel-invoices.

matthaselip avatar matthaselip commented on July 17, 2024

this is because the config file is not loaded as soon as you install the package. so soon as you have installed it, run php artisan config:cache so that the system can see the config/invoice.php file.

would help if the instructions were updated to accommodate this.

from laravel-invoices.

ivofrancisco avatar ivofrancisco commented on July 17, 2024

from laravel-invoices.

MedAmineBenaicha avatar MedAmineBenaicha commented on July 17, 2024

Thank you very much Marayshi.

from laravel-invoices.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.