Merge pull request #8518 from turbo124/v5-develop

Update documents
This commit is contained in:
David Bomba 2023-05-24 21:14:07 +10:00 committed by GitHub
commit 52bfd78106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 5 deletions

View File

@ -412,7 +412,8 @@ class CompanyController extends BaseController
$company = $this->company_repo->save($request->all(), $company); $company = $this->company_repo->save($request->all(), $company);
$company->saveSettings($request->input('settings'), $company); /** We save the settings in the repository - this is duplicated */
// $company->saveSettings($request->input('settings'), $company);
if ($request->has('documents')) { if ($request->has('documents')) {
$this->saveDocuments($request->input('documents'), $company, false); $this->saveDocuments($request->input('documents'), $company, false);

View File

@ -23,15 +23,18 @@ class UpdateDocumentRequest extends Request
* *
* @return bool * @return bool
*/ */
public function authorize() : bool public function authorize(): bool
{ {
return auth()->user()->can('edit', $this->document); /** @var \App\Models\User $user */
$user = auth()->user();
return $user->can('edit', $this->document);
} }
public function rules() public function rules()
{ {
return [ return [
'name' => 'sometimes|alpha_num' 'name' => 'sometimes'
]; ];
} }

View File

@ -73,7 +73,6 @@ class RecurringInvoicesCron
/* Special check if we should generate another invoice is the previous one is yet to be paid */ /* Special check if we should generate another invoice is the previous one is yet to be paid */
if ($recurring_invoice->company->stop_on_unpaid_recurring && $recurring_invoice->invoices()->whereIn('status_id', [2, 3])->where('is_deleted', 0)->where('balance', '>', 0)->exists()) { if ($recurring_invoice->company->stop_on_unpaid_recurring && $recurring_invoice->invoices()->whereIn('status_id', [2, 3])->where('is_deleted', 0)->where('balance', '>', 0)->exists()) {
nlog('Existing invoice exists, skipping'); nlog('Existing invoice exists, skipping');
return; return;
} }

View File

@ -77,6 +77,18 @@ trait CompanySettingsSaver
$entity->settings = $company_settings; $entity->settings = $company_settings;
if(array_key_exists('settings', $entity->getDirty()))
{
$old_settings = $entity->getOriginal()['settings'];
if($settings->name != $old_settings->name) {
nlog("name change {$old_settings->name} -> {$settings->name} ");
}
}
$entity->save(); $entity->save();
} }