mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fixes for invoice status with partial payment (#3472)
* Fixes for UserPolicy * Improve notifications * Company quantities * Fixes for invoice status with partial payments
This commit is contained in:
parent
1017a22bca
commit
70a560c474
@ -45,7 +45,7 @@ class InvitationController extends Controller
|
|||||||
auth()->guard('contact')->login($invitation->contact, false);
|
auth()->guard('contact')->login($invitation->contact, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!request()->has('is_admin')){
|
if(!request()->has('silent')){
|
||||||
|
|
||||||
$invitation->markViewed();
|
$invitation->markViewed();
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ namespace App\Http\Requests\Company;
|
|||||||
|
|
||||||
use App\DataMapper\CompanySettings;
|
use App\DataMapper\CompanySettings;
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
use App\Http\ValidationRules\Company\ValidCompanyQuantity;
|
||||||
use App\Http\ValidationRules\ValidSettingsRule;
|
use App\Http\ValidationRules\ValidSettingsRule;
|
||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
@ -36,7 +37,7 @@ class StoreCompanyRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
//$rules['name'] = 'required';
|
$rules['name'] = new ValidCompanyQuantity();
|
||||||
$rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb
|
$rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb
|
||||||
$rules['settings'] = new ValidSettingsRule();
|
$rules['settings'] = new ValidSettingsRule();
|
||||||
|
|
||||||
|
44
app/Http/ValidationRules/Company/ValidCompanyQuantity.php
Normal file
44
app/Http/ValidationRules/Company/ValidCompanyQuantity.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\ValidationRules\Company;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ValidCompanyQuantity
|
||||||
|
* @package App\Http\ValidationRules\Company
|
||||||
|
*/
|
||||||
|
class ValidCompanyQuantity implements Rule
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function passes($attribute, $value)
|
||||||
|
{
|
||||||
|
|
||||||
|
return auth()->user()->company()->account->companies->count() <= 10;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function message()
|
||||||
|
{
|
||||||
|
return "Limit of 10 companies per account.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -49,7 +49,7 @@ class InvitationViewedListener implements ShouldQueue
|
|||||||
/*** Check for Mail notifications***/
|
/*** Check for Mail notifications***/
|
||||||
$all_user_notifications = '';
|
$all_user_notifications = '';
|
||||||
|
|
||||||
if($event->entity->user_id == $company_user->user_id || $event->entity->assigned_user_id == $company_user->user_id)
|
if($invitation->{$entity_name}->user_id == $company_user->user_id || $invitation->{$entity_name}->assigned_user_id == $company_user->user_id)
|
||||||
$all_user_notifications = "all_user_notifications";
|
$all_user_notifications = "all_user_notifications";
|
||||||
|
|
||||||
$possible_permissions = [$entity_viewed, "all_notifications", $all_user_notifications];
|
$possible_permissions = [$entity_viewed, "all_notifications", $all_user_notifications];
|
||||||
|
@ -43,7 +43,7 @@ class EntityViewedNotification extends Notification implements ShouldQueue
|
|||||||
$this->settings = $this->entity->client->getMergedSettings();
|
$this->settings = $this->entity->client->getMergedSettings();
|
||||||
$this->is_system = $is_system;
|
$this->is_system = $is_system;
|
||||||
$this->invitation = $invitation;
|
$this->invitation = $invitation;
|
||||||
|
$this->method = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +55,7 @@ class EntityViewedNotification extends Notification implements ShouldQueue
|
|||||||
public function via($notifiable)
|
public function via($notifiable)
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->method;
|
return $this->method ?: [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ class EntityViewedNotification extends Notification implements ShouldQueue
|
|||||||
'client' => $this->contact->present()->name(),
|
'client' => $this->contact->present()->name(),
|
||||||
$this->entity_name => $this->entity->number,
|
$this->entity_name => $this->entity->number,
|
||||||
]),
|
]),
|
||||||
'url' => config('ninja.site_url') . "/{$this->entity_name}s/" . $this->entity->hashed_id,
|
'url' => config('ninja.site_url') . "/client/{$this->entity_name}/" . $this->invitation->key . "?silent=true",
|
||||||
'button' => ctrans("texts.view_{$this->entity_name}"),
|
'button' => ctrans("texts.view_{$this->entity_name}"),
|
||||||
'signature' => $this->settings->email_signature,
|
'signature' => $this->settings->email_signature,
|
||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
|
@ -41,7 +41,7 @@ class UserPolicy extends EntityPolicy
|
|||||||
*/
|
*/
|
||||||
public function edit(User $user, $user_entity) : bool
|
public function edit(User $user, $user_entity) : bool
|
||||||
{
|
{
|
||||||
$company_user = CompanyUser::whereUserId($user_entity->id)->company()->first();
|
$company_user = CompanyUser::whereUserId($user->id)->company()->first();
|
||||||
|
|
||||||
return ($user->isAdmin() && $company_user);
|
return ($user->isAdmin() && $company_user);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class ApplyPayment extends AbstractService
|
|||||||
} elseif ($this->payment_amount == $this->invoice->balance) { //total invoice paid.
|
} elseif ($this->payment_amount == $this->invoice->balance) { //total invoice paid.
|
||||||
$this->invoice->service()->clearPartial()->setStatus(Invoice::STATUS_PAID)->updateBalance($this->payment_amount*-1);
|
$this->invoice->service()->clearPartial()->setStatus(Invoice::STATUS_PAID)->updateBalance($this->payment_amount*-1);
|
||||||
} elseif($this->payment_amount < $this->invoice->balance) { //partial invoice payment made
|
} elseif($this->payment_amount < $this->invoice->balance) { //partial invoice payment made
|
||||||
$this->invoice->service()->clearPartial()->updateBalance($this->payment_amount*-1);
|
$this->invoice->service()->clearPartial()->setStatus(Invoice::STATUS_PARTIAL)->updateBalance($this->payment_amount*-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
|
@ -23,15 +23,15 @@ class NotificationService extends AbstractService
|
|||||||
|
|
||||||
const ALL_USER = 'all_user_notifications';
|
const ALL_USER = 'all_user_notifications';
|
||||||
|
|
||||||
const PAYMENT_SUCCESS = 'payment_success';
|
const PAYMENT_SUCCESS = 'payment_success'; //@todo
|
||||||
|
|
||||||
const PAYMENT_FAILURE = 'payment_failure';
|
const PAYMENT_FAILURE = 'payment_failure'; //@todo
|
||||||
|
|
||||||
const INVOICE_SENT = 'invoice_sent';
|
const INVOICE_SENT = 'invoice_sent'; //@todo
|
||||||
|
|
||||||
const QUOTE_SENT = 'quote_sent';
|
const QUOTE_SENT = 'quote_sent'; //@todo
|
||||||
|
|
||||||
const CREDIT_SENT = 'credit_sent';
|
const CREDIT_SENT = 'credit_sent'; //@todo
|
||||||
|
|
||||||
const QUOTE_VIEWED = 'quote_viewed';
|
const QUOTE_VIEWED = 'quote_viewed';
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ class NotificationService extends AbstractService
|
|||||||
|
|
||||||
const CREDIT_VIEWED = 'credit_viewed';
|
const CREDIT_VIEWED = 'credit_viewed';
|
||||||
|
|
||||||
const QUOTE_APPROVED = 'quote_approved';
|
const QUOTE_APPROVED = 'quote_approved'; //@todo
|
||||||
|
|
||||||
public $company;
|
public $company;
|
||||||
|
|
||||||
|
@ -71,6 +71,6 @@ trait Inviteable
|
|||||||
public function getAdminLink() :string
|
public function getAdminLink() :string
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->getLink(). '?is_admin=true';
|
return $this->getLink(). '?silent=true';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ class PaymentTypesSeeder extends Seeder
|
|||||||
Eloquent::unguard();
|
Eloquent::unguard();
|
||||||
|
|
||||||
$paymentTypes = [
|
$paymentTypes = [
|
||||||
['name' => 'Apply Credit'],
|
// ['name' => 'Apply Credit'],
|
||||||
['name' => 'Bank Transfer', 'gateway_type_id' => self::GATEWAY_TYPE_BANK_TRANSFER],
|
['name' => 'Bank Transfer', 'gateway_type_id' => self::GATEWAY_TYPE_BANK_TRANSFER],
|
||||||
['name' => 'Cash'],
|
['name' => 'Cash'],
|
||||||
['name' => 'Debit', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
|
['name' => 'Debit', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user