mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Merge pull request #6893 from turbo124/v5-develop
Minor fixes for Gateway Types
This commit is contained in:
commit
1462c9ef57
@ -52,6 +52,7 @@ class Handler extends ExceptionHandler
|
||||
MaxAttemptsExceededException::class,
|
||||
CommandNotFoundException::class,
|
||||
ValidationException::class,
|
||||
ModelNotFoundException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -81,8 +81,8 @@ class ContactLoginController extends Controller
|
||||
{
|
||||
Auth::shouldUse('contact');
|
||||
|
||||
if(Ninja::isHosted() && $request->has('db'))
|
||||
MultiDB::setDb($request->input('db'));
|
||||
if(Ninja::isHosted() && $request->has('company_key'))
|
||||
MultiDB::findAndSetDbByCompanyKey($request->input('company_key'));
|
||||
|
||||
$this->validateLogin($request);
|
||||
// If the class is using the ThrottlesLogins trait, we can automatically throttle
|
||||
|
@ -27,7 +27,7 @@ class SwitchCompanyController extends Controller
|
||||
->where('id', $this->transformKeys($contact))
|
||||
->first();
|
||||
|
||||
auth()->guard('contact')->user()->login($client_contact, true);
|
||||
auth()->guard('contact')->login($client_contact, true);
|
||||
|
||||
return redirect('/client/dashboard');
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ class StoreRecurringExpenseRequest extends Request
|
||||
$rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
||||
|
||||
$rules['frequency_id'] = 'required|integer|digits_between:1,12';
|
||||
$rules['tax_amount1'] = 'numeric';
|
||||
$rules['tax_amount2'] = 'numeric';
|
||||
$rules['tax_amount3'] = 'numeric';
|
||||
|
||||
return $this->globalRules($rules);
|
||||
}
|
||||
|
@ -43,6 +43,10 @@ class UpdateRecurringExpenseRequest extends Request
|
||||
$rules['number'] = Rule::unique('recurring_expenses')->where('company_id', auth()->user()->company()->id)->ignore($this->recurring_expense->id);
|
||||
}
|
||||
|
||||
$rules['tax_amount1'] = 'numeric';
|
||||
$rules['tax_amount2'] = 'numeric';
|
||||
$rules['tax_amount3'] = 'numeric';
|
||||
|
||||
return $this->globalRules($rules);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ class ClientContact extends Authenticatable implements HasLocalePreference
|
||||
'custom_value4',
|
||||
'email',
|
||||
'is_primary',
|
||||
// 'client_id',
|
||||
'send_email',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ class GatewayType extends StaticModel
|
||||
case self::EPS:
|
||||
return ctrans('texts.eps');
|
||||
case self::BECS:
|
||||
return ctrans('tets.becs');
|
||||
return ctrans('texts.becs');
|
||||
case self::ACSS:
|
||||
return ctrans('texts.acss');
|
||||
case self::DIRECT_DEBIT:
|
||||
|
@ -185,7 +185,7 @@ class WePayPaymentDriver extends BaseDriver
|
||||
}
|
||||
|
||||
if (! isset($objectType)) {
|
||||
throw new Exception('Could not find object id parameter');
|
||||
throw new \Exception('Could not find object id parameter');
|
||||
}
|
||||
|
||||
if ($objectType == 'credit_card') {
|
||||
|
@ -113,25 +113,26 @@ class BaseRepository
|
||||
* @param $action
|
||||
*
|
||||
* @return int
|
||||
* @deprecated - this doesn't appear to be used anywhere?
|
||||
*/
|
||||
public function bulk($ids, $action)
|
||||
{
|
||||
if (! $ids) {
|
||||
return 0;
|
||||
}
|
||||
// public function bulk($ids, $action)
|
||||
// {
|
||||
// if (! $ids) {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
$ids = $this->transformKeys($ids);
|
||||
// $ids = $this->transformKeys($ids);
|
||||
|
||||
$entities = $this->findByPublicIdsWithTrashed($ids);
|
||||
// $entities = $this->findByPublicIdsWithTrashed($ids);
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
if (auth()->user()->can('edit', $entity)) {
|
||||
$this->$action($entity);
|
||||
}
|
||||
}
|
||||
// foreach ($entities as $entity) {
|
||||
// if (auth()->user()->can('edit', $entity)) {
|
||||
// $this->$action($entity);
|
||||
// }
|
||||
// }
|
||||
|
||||
return count($entities);
|
||||
}
|
||||
// return count($entities);
|
||||
// }
|
||||
|
||||
/* Returns an invoice if defined as a key in the $resource array*/
|
||||
public function getInvitation($invitation, $resource)
|
||||
|
@ -134,9 +134,9 @@ class InvoiceService
|
||||
*
|
||||
* @return InvoiceService Parent class object
|
||||
*/
|
||||
public function updateBalance($balance_adjustment)
|
||||
public function updateBalance($balance_adjustment, bool $is_draft = false)
|
||||
{
|
||||
$this->invoice = (new UpdateBalance($this->invoice, $balance_adjustment))->run();
|
||||
$this->invoice = (new UpdateBalance($this->invoice, $balance_adjustment, $is_draft))->run();
|
||||
|
||||
if ((int)$this->invoice->balance == 0) {
|
||||
$this->invoice->next_send_date = null;
|
||||
@ -339,6 +339,10 @@ class InvoiceService
|
||||
|
||||
public function removeUnpaidGatewayFees()
|
||||
{
|
||||
//return early if type three does not exist.
|
||||
if(!collect($this->invoice->line_items)->contains('type_id', 3))
|
||||
return $this;
|
||||
|
||||
$this->invoice->line_items = collect($this->invoice->line_items)
|
||||
->reject(function ($item) {
|
||||
return $item->type_id == '3';
|
||||
|
@ -47,7 +47,7 @@ class MarkSent extends AbstractService
|
||||
->service()
|
||||
->applyNumber()
|
||||
->setDueDate()
|
||||
->updateBalance($this->invoice->amount)
|
||||
->updateBalance($this->invoice->amount, true)
|
||||
->deletePdf()
|
||||
->setReminder()
|
||||
->save();
|
||||
|
@ -20,10 +20,13 @@ class UpdateBalance extends AbstractService
|
||||
|
||||
public $balance_adjustment;
|
||||
|
||||
public function __construct($invoice, $balance_adjustment)
|
||||
private $is_draft;
|
||||
|
||||
public function __construct($invoice, $balance_adjustment, bool $is_draft)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
$this->balance_adjustment = $balance_adjustment;
|
||||
$this->is_draft = $is_draft;
|
||||
}
|
||||
|
||||
public function run()
|
||||
@ -34,7 +37,7 @@ class UpdateBalance extends AbstractService
|
||||
|
||||
$this->invoice->balance += floatval($this->balance_adjustment);
|
||||
|
||||
if ($this->invoice->balance == 0) {
|
||||
if ($this->invoice->balance == 0 && !$this->is_draft) {
|
||||
$this->invoice->status_id = Invoice::STATUS_PAID;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
</label>
|
||||
<div id="mandate-acceptance">
|
||||
<input type="checkbox" id="becs-mandate-acceptance" class="input mr-4">
|
||||
<label for="becs-mandate-acceptance">{{ctrans('texts.becs_mandat')}}</label>
|
||||
<label for="becs-mandate-acceptance">{{ctrans('texts.becs_mandate')}}</label>
|
||||
</div>
|
||||
</form>
|
||||
@endcomponent
|
||||
|
@ -32,6 +32,10 @@ class DownloadHistoricalInvoiceTest extends TestCase
|
||||
parent::setUp();
|
||||
|
||||
$this->makeTestData();
|
||||
|
||||
if (config('ninja.testvars.travis') !== false) {
|
||||
$this->markTestSkipped('Skip test for Travis');
|
||||
}
|
||||
}
|
||||
|
||||
private function mockActivity()
|
||||
|
@ -10,6 +10,7 @@
|
||||
*/
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Factory\InvoiceItemFactory;
|
||||
use App\Utils\Traits\UserSessionAttributes;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Tests\TestCase;
|
||||
@ -19,13 +20,10 @@ use Tests\TestCase;
|
||||
*/
|
||||
class CollectionMergingTest extends TestCase
|
||||
{
|
||||
use UserSessionAttributes;
|
||||
|
||||
public function setUp() :void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Session::start();
|
||||
}
|
||||
|
||||
public function testUniqueValues()
|
||||
@ -62,4 +60,21 @@ class CollectionMergingTest extends TestCase
|
||||
$intersect = $collection->intersectByKeys($collection->flatten(1)->unique());
|
||||
$this->assertEquals(11, $intersect->count());
|
||||
}
|
||||
|
||||
public function testExistenceInCollection()
|
||||
{
|
||||
|
||||
$items = InvoiceItemFactory::generate(5);
|
||||
|
||||
$this->assertFalse(collect($items)->contains('type_id', "3"));
|
||||
$this->assertFalse(collect($items)->contains('type_id', 3));
|
||||
|
||||
$item = InvoiceItemFactory::create();
|
||||
$item->type_id = "3";
|
||||
$items[] = $item;
|
||||
|
||||
$this->assertTrue(collect($items)->contains('type_id', "3"));
|
||||
$this->assertTrue(collect($items)->contains('type_id', 3));
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user