mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-11 05:32:39 +01:00
Merge pull request #7445 from turbo124/v5-develop
Fixes for displaying payment gateways where min_limit is enforced
This commit is contained in:
commit
bd433a4936
@ -83,7 +83,7 @@ class InvoicesTable extends Component
|
||||
|
||||
return render('components.livewire.invoices-table', [
|
||||
'invoices' => $query,
|
||||
'gateway_available' => !empty(auth()->user()->client->service()->getPaymentMethods(0)),
|
||||
'gateway_available' => !empty(auth()->user()->client->service()->getPaymentMethods(-1)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class CreatePaymentMethodRequest extends FormRequest
|
||||
|
||||
$available_methods = [];
|
||||
|
||||
collect($client->service()->getPaymentMethods(1))
|
||||
collect($client->service()->getPaymentMethods(-1))
|
||||
->filter(function ($method) use (&$available_methods) {
|
||||
$available_methods[] = $method['gateway_type_id'];
|
||||
});
|
||||
|
@ -432,7 +432,7 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
public function getCreditCardGateway() :?CompanyGateway
|
||||
{
|
||||
|
||||
$pms = $this->service()->getPaymentMethods(0);
|
||||
$pms = $this->service()->getPaymentMethods(-1);
|
||||
|
||||
foreach($pms as $pm)
|
||||
{
|
||||
@ -462,7 +462,7 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
//todo refactor this - it is only searching for existing tokens
|
||||
public function getBankTransferGateway() :?CompanyGateway
|
||||
{
|
||||
$pms = $this->service()->getPaymentMethods(0);
|
||||
$pms = $this->service()->getPaymentMethods(-1);
|
||||
|
||||
if($this->currency()->code == 'USD' && in_array(GatewayType::BANK_TRANSFER, array_column($pms, 'gateway_type_id'))){
|
||||
|
||||
|
@ -102,6 +102,7 @@ class Company extends BaseModel
|
||||
'markdown_email_enabled',
|
||||
'stop_on_unpaid_recurring',
|
||||
'use_quote_terms_on_conversion',
|
||||
'show_production_description_dropdown',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
@ -132,8 +132,7 @@ class PaymentMethod
|
||||
|
||||
private function getMethods()
|
||||
{
|
||||
// we should prefilter $gateway->driver($this)->gatewayTypes()
|
||||
// and only include the enabled payment methods on the gateway
|
||||
|
||||
$this->payment_methods = [];
|
||||
|
||||
foreach ($this->gateways as $gateway) {
|
||||
@ -148,13 +147,12 @@ class PaymentMethod
|
||||
|
||||
if ($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $this->amount) && $gateway->fees_and_limits->{$type}->is_enabled) {
|
||||
|
||||
// if($type == GatewayType::BANK_TRANSFER);
|
||||
|
||||
$this->payment_methods[] = [$gateway->id => $type];
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
//$this->payment_methods[] = [$gateway->id => $type];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -243,11 +241,11 @@ class PaymentMethod
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((property_exists($fees_and_limits, 'min_limit')) && $fees_and_limits->min_limit !== null && $fees_and_limits->min_limit != -1 && $this->amount < $fees_and_limits->min_limit) {
|
||||
if ((property_exists($fees_and_limits, 'min_limit')) && $fees_and_limits->min_limit !== null && $fees_and_limits->min_limit != -1 && ($this->amount < $fees_and_limits->min_limit && $this->amount != -1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((property_exists($fees_and_limits, 'max_limit')) && $fees_and_limits->max_limit !== null && $fees_and_limits->max_limit != -1 && $this->amount > $fees_and_limits->max_limit) {
|
||||
if ((property_exists($fees_and_limits, 'max_limit')) && $fees_and_limits->max_limit !== null && $fees_and_limits->max_limit != -1 && ($this->amount > $fees_and_limits->max_limit && $this->amount != -1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -453,6 +453,9 @@ class Design extends BaseDesign
|
||||
foreach ($this->invoices as $invoice) {
|
||||
foreach ($invoice->payments as $payment) {
|
||||
|
||||
if($payment->is_deleted)
|
||||
continue;
|
||||
|
||||
$element = ['element' => 'tr', 'elements' => []];
|
||||
|
||||
$element['elements'][] = ['element' => 'td', 'content' => $invoice->number];
|
||||
|
@ -169,6 +169,8 @@ class CompanyTransformer extends EntityTransformer
|
||||
'convert_rate_to_client' => (bool) $company->convert_rate_to_client,
|
||||
'markdown_email_enabled' => (bool) $company->markdown_email_enabled,
|
||||
'stop_on_unpaid_recurring' => (bool) $company->stop_on_unpaid_recurring,
|
||||
'show_production_description_dropdown' => (bool)$company->show_production_description_dropdown,
|
||||
'use_quote_terms_on_conversion' => (bool) $company->use_quote_terms_on_conversion,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ class AddAutoBillTriesToInvoicesTable extends Migration
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->boolean('stop_on_unpaid_recurring')->default(0);
|
||||
$table->boolean('use_quote_terms_on_conversion')->default(0);
|
||||
$table->boolean('show_production_description_dropdown')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user