Forum

Ask, reply and learn. Join the community of Akaunting.

New Discussion

Can't add invoice in second company

Michael Gschwandtner   ( User )

Commented 5 years ago

 If we create a new company we can't add invoices, payments or expenses for that company.


Steps to reproduce:


* Go to "Manage companies" and create a new company
* Switch to the new company
* Got to Invoices and create a new invoice
* Upon clicking save the system shows the error  "Whoops, looks like something went wrong." but the invoice is saved as a draft.


The same thing happens when we try to add Expenses -> Bills and Expenses -> Payments


 


Tested on:


* Akaunting 1.3.15
* Akaunting 1.3.16


 


 

Michael Gschwandtner   ( User )

Commented 5 years ago

Here is a stacktrace for /expenses/payments/create


 








































































































































































































































































































(1/1) ErrorException


Invalid argument supplied for foreach()


in Modules.php line 44
at HandleExceptions->handleError(2, 'Invalid argument supplied for foreach()', '/var/www/html/app/Utilities/Modules.php', 44, array('type' => null, 'company_id' => 2, 'cache_admin' => 'payment_methods.2.admin', 'cache_customer' => 'payment_methods.2.customer', 'payment_methods' => null, 'customer' => null, 'gateways' => null, 'methods' => array(), 'results' => array(null, array(array('code' => 'paypalstandard')))))in Modules.php line 44
at Modules::getPaymentMethods()in Payments.php line 70
at Payments->create()
at call_user_func_array(array(object(Payments), 'create'), array())in Controller.php line 55
at Controller->callAction('create', array())in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(Payments), 'create')in Route.php line 203
at Route->runController()in Route.php line 160
at Route->run()in Router.php line 572
at Router->Illuminate\Routing\{closure}(object(Request))in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request))in LaratrustPermission.php line 56
at LaratrustPermission->handle(object(Request), object(Closure), array('create-expenses-payments'))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in Money.php line 77
at Money->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in DateFormat.php line 35
at DateFormat->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in LaratrustPermission.php line 56
at LaratrustPermission->handle(object(Request), object(Closure), array('read-admin-panel'))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in AdminMenu.php line 209
at AdminMenu->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in SetLocale.php line 93
at SetLocale->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in RedirectIfWizardCompleted.php line 20
at RedirectIfWizardCompleted->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in LoadCurrencies.php line 27
at LoadCurrencies->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in LoadSettings.php line 27
at LoadSettings->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in AddXHeader.php line 18
at AddXHeader->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in RedirectIfNotInstalled.php line 21
at RedirectIfNotInstalled->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in Authenticate.php line 43
at Authenticate->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in Pipeline.php line 102
at Pipeline->then(object(Closure))in Router.php line 574
at Router->runRouteWithinStack(object(Route), object(Request))in Router.php line 533
at Router->dispatchToRoute(object(Request))in Router.php line 511
at Router->dispatch(object(Request))in Kernel.php line 176
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request))in Debugbar.php line 51
at Debugbar->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in TrustProxies.php line 56
at TrustProxies->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in ValidatePostSize.php line 27
at ValidatePostSize->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in Request.php line 111
at Request->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in Pipeline.php line 102
at Pipeline->then(object(Closure))in Kernel.php line 151
at Kernel->sendRequestThroughRouter(object(Request))in Kernel.php line 116
at Kernel->handle(object(Request))in index.php line 27

 

Mpho Molefi   ( User )

Commented 5 years ago

I have the exact proplem

Michael Gschwandtner   ( User )

Commented 5 years ago

I found a partial solution for this problem.

This only happens if there are no offline payment methods configured, which is the case when a new company is created.

However, creating a new offline payment method via Settings -> Offline Payments does not work either if the list of offline payments is empty.

A workaround is to add the offline payments directly in the database via:


insert into hdu_settings ( `company_id`, `key`, `value` ) VALUES ( 2 , 'offlinepayment.methods', '[{"code":"offlinepayment.cash.1","name":"Cash","order":"1","description":null},{"code":"offlinepayment.bank_transfer.2","name":"Bank Transfer","order":"2","description":null}]' );


Where hdu_settings is the name of the settings table in your database (the first three letters seem to be randomly generated at the time of the installation)


 


 


 


 

Michael Gschwandtner   ( User )

Commented 5 years ago

The database hack was meant as a temporary fix, but in the meantime I realized that there are at least two separate problems that contribute to this issue.


1. When creating a new company, many of the settings are not created in the database (not just the offlinepayment.methods). When they are accessed later on the site gives the Whoops error.  Some of the settings are set in the wizard but many are not.


2. The wizard that opens up the first time a newly created company gets opened is only called for the second company, for all subsequent companies the wizard is not called and many things don't get set up correctly.


I will make a github issue when I have a clearer picture on how to resolve the problem.


 


 

Please login or register to leave a response.

Showing 1 to 5 of 5 discussions