mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 04:24:36 -04:00
Merge pull request #9149 from turbo124/v5-develop
Add mappings for participant and participant_name
This commit is contained in:
commit
9c6a65c26e
@ -562,6 +562,16 @@ class InvoiceController extends BaseController
|
||||
return response()->json(['message' => $hash_or_response], 200);
|
||||
}
|
||||
|
||||
if($action == 'set_payment_link' && $request->has('subscription_id')) {
|
||||
|
||||
$invoices->each(function ($invoice) use($user, $request){
|
||||
if($user->can('edit', $invoice))
|
||||
$invoice->service()->setPaymentLink($request->subscription_id)->save();
|
||||
});
|
||||
|
||||
return $this->listResponse(Invoice::query()->withTrashed()->whereIn('id', $this->transformKeys($ids))->company());
|
||||
}
|
||||
|
||||
/*
|
||||
* Send the other actions to the switch
|
||||
*/
|
||||
|
@ -424,13 +424,26 @@ class RecurringInvoiceController extends BaseController
|
||||
|
||||
$recurring_invoices = RecurringInvoice::withTrashed()->find($request->ids);
|
||||
|
||||
|
||||
if($request->action == 'set_payment_link' && $request->has('subscription_id')) {
|
||||
|
||||
$recurring_invoices->each(function ($invoice) use ($user, $request) {
|
||||
if($user->can('edit', $invoice)) {
|
||||
$invoice->service()->setPaymentLink($request->subscription_id)->save();
|
||||
}
|
||||
});
|
||||
|
||||
return $this->listResponse(RecurringInvoice::query()->withTrashed()->whereIn('id', $request->ids)->company());
|
||||
}
|
||||
|
||||
$recurring_invoices->each(function ($recurring_invoice, $key) use ($request, $user) {
|
||||
if ($user->can('edit', $recurring_invoice)) {
|
||||
$this->performAction($recurring_invoice, $request->action, true);
|
||||
}
|
||||
});
|
||||
|
||||
return $this->listResponse(RecurringInvoice::withTrashed()->whereIn('id', $request->ids));
|
||||
return $this->listResponse(RecurringInvoice::query()->withTrashed()->whereIn('id', $request->ids)->company());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,8 @@ class BulkInvoiceRequest extends Request
|
||||
'email_type' => 'sometimes|in:reminder1,reminder2,reminder3,reminder_endless,custom1,custom2,custom3,invoice,quote,credit,payment,payment_partial,statement,purchase_order',
|
||||
'template' => 'sometimes|string',
|
||||
'template_id' => 'sometimes|string',
|
||||
'send_email' => 'sometimes|bool'
|
||||
'send_email' => 'sometimes|bool',
|
||||
'subscriptin_id' => 'sometimes|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -31,10 +31,14 @@ class BulkRecurringInvoiceRequest extends Request
|
||||
|
||||
public function rules()
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return [
|
||||
'ids' => ['required','bail','array',Rule::exists('recurring_invoices', 'id')->where('company_id', auth()->user()->company()->id)],
|
||||
'action' => 'in:archive,restore,delete,increase_prices,update_prices,start,stop,send_now',
|
||||
'ids' => ['required','bail','array', Rule::exists('recurring_invoices', 'id')->where('company_id', $user->company()->id)],
|
||||
'action' => 'in:archive,restore,delete,increase_prices,update_prices,start,stop,send_now,set_payment_link',
|
||||
'percentage_increase' => 'required_if:action,increase_prices|numeric|min:0|max:100',
|
||||
'subscription_id' => 'sometimes|string'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@ class BankTransactionMap
|
||||
9 => 'transaction.base_type',
|
||||
10 => 'transaction.payment_type_Credit',
|
||||
11 => 'transaction.payment_type_Debit',
|
||||
12 => 'transaction.participant',
|
||||
13 => 'transaction.participant_name',
|
||||
];
|
||||
}
|
||||
|
||||
@ -46,6 +48,8 @@ class BankTransactionMap
|
||||
9 => 'texts.type',
|
||||
10 => 'transaction.credit',
|
||||
11 => 'transaction.debit',
|
||||
12 => 'transaction.participant',
|
||||
13 => 'transaction.participant_name',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ class BankTransformer extends BaseTransformer
|
||||
'updated_at' => $now,
|
||||
'company_id' => $this->company->id,
|
||||
'user_id' => $this->company->owner()->id,
|
||||
'participant' => $this->getString($transaction, 'transaction.participant'),
|
||||
'participant_name' => $this->getString($transaction, 'transaction.participant_name'),
|
||||
];
|
||||
|
||||
return $transformed;
|
||||
|
@ -11,20 +11,21 @@
|
||||
|
||||
namespace App\Services\Invoice;
|
||||
|
||||
use App\Events\Invoice\InvoiceWasArchived;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Jobs\Inventory\AdjustProductInventory;
|
||||
use App\Jobs\Invoice\CreateEInvoice;
|
||||
use App\Libraries\Currency\Conversion\CurrencyApi;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\Task;
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Task;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Models\Subscription;
|
||||
use App\Models\CompanyGateway;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Jobs\Invoice\CreateEInvoice;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Events\Invoice\InvoiceWasArchived;
|
||||
use App\Jobs\Inventory\AdjustProductInventory;
|
||||
use App\Libraries\Currency\Conversion\CurrencyApi;
|
||||
|
||||
class InvoiceService
|
||||
{
|
||||
@ -619,6 +620,19 @@ class InvoiceService
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPaymentLink(string $subscription_id): self
|
||||
{
|
||||
|
||||
$sub_id = $this->decodePrimaryKey($subscription_id);
|
||||
|
||||
if(Subscription::withTrashed()->where('id', $sub_id)->where('company_id', $this->invoice->company_id)->exists()) {
|
||||
$this->invoice->subscription_id = $sub_id;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the invoice.
|
||||
* @return Invoice object
|
||||
|
@ -11,16 +11,20 @@
|
||||
|
||||
namespace App\Services\Recurring;
|
||||
|
||||
use App\Jobs\RecurringInvoice\SendRecurring;
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Subscription;
|
||||
use App\Models\RecurringQuote;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Models\RecurringExpense;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Models\RecurringQuote;
|
||||
use App\Utils\Ninja;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Jobs\RecurringInvoice\SendRecurring;
|
||||
|
||||
class RecurringService
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
public function __construct(public RecurringInvoice | RecurringExpense | RecurringQuote $recurring_entity)
|
||||
{
|
||||
}
|
||||
@ -161,6 +165,19 @@ class RecurringService
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPaymentLink(string $subscription_id): self
|
||||
{
|
||||
|
||||
$sub_id = $this->decodePrimaryKey($subscription_id);
|
||||
|
||||
if(Subscription::withTrashed()->where('id', $sub_id)->where('company_id', $this->recurring_entity->company_id)->exists()) {
|
||||
$this->recurring_entity->subscription_id = $sub_id;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->recurring_entity->saveQuietly();
|
||||
|
@ -5255,6 +5255,8 @@ $lang = array(
|
||||
'select_provider' => 'Select Provider',
|
||||
'nordigen_requisition_subject' => 'Requisition expired, please reauthenticate.',
|
||||
'nordigen_requisition_body' => 'Access to bank account feeds has expired as set in End User Agreement. <br><br>Please log into Invoice Ninja and re-authenticate with your banks to continue receiving transactions.',
|
||||
'participant' => 'Participant',
|
||||
'participant_name' => 'Participant name',
|
||||
);
|
||||
|
||||
return $lang;
|
||||
|
@ -5240,6 +5240,13 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette
|
||||
'nordigen_handler_error_contents_requisition_no_accounts' => 'Le service n\'a retourné aucun compte valide. Veuillez redémarrer le processus.',
|
||||
'nordigen_handler_restart' => 'Redémarrer le processus',
|
||||
'nordigen_handler_return' => 'Retour à l\'application',
|
||||
'lang_Lao' => 'Lao',
|
||||
'currency_lao_kip' => 'Kip laotien',
|
||||
'yodlee_regions' => 'Régions: USA, Royaume-Uni, Australie et Inde',
|
||||
'nordigen_regions' => 'Régions: Europe et Royaume-Uni',
|
||||
'select_provider' => 'Sélectionner le fournisseur',
|
||||
'nordigen_requisition_subject' => 'La réquisition a expiré, veuillez vous réauthentifier.',
|
||||
'nordigen_requisition_body' => 'L\'accès aux flux de compte bancaire a expiré tel que défini dans l\'accord de l\'utilisateur final. <br><br>Veuillez vous connecter à Invoice Ninja et réauthentifier auprès de vos banques pour continuer à recevoir les transactions.',
|
||||
);
|
||||
|
||||
return $lang;
|
||||
|
@ -5248,6 +5248,13 @@ $lang = array(
|
||||
'nordigen_handler_error_contents_requisition_no_accounts' => 'ການບໍລິການບໍ່ໄດ້ສົ່ງຄືນບັນຊີທີ່ຖືກຕ້ອງໃດໆ. ພິຈາລະນາເລີ່ມການໄຫຼເຂົ້າໃໝ່.',
|
||||
'nordigen_handler_restart' => 'ເລີ່ມການໄຫຼເຂົ້າໃໝ່.',
|
||||
'nordigen_handler_return' => 'ກັບຄືນໄປຫາແອັບພລິເຄຊັນ.',
|
||||
'lang_Lao' => 'ລາວ',
|
||||
'currency_lao_kip' => 'ລາວກີບ',
|
||||
'yodlee_regions' => 'Regions: USA, UK, Australia & India',
|
||||
'nordigen_regions' => 'Regions: Europe & UK',
|
||||
'select_provider' => 'ເລືອກຜູ້ໃຫ້ບໍລິການ',
|
||||
'nordigen_requisition_subject' => 'Requisition expired, please reauthenticate.',
|
||||
'nordigen_requisition_body' => 'Access to bank account feeds has expired as set in End User Agreement. <br><br>Please log into Invoice Ninja and re-authenticate with your banks to continue receiving transactions.',
|
||||
);
|
||||
|
||||
return $lang;
|
||||
|
109
public/build/assets/app-01291e40.js
vendored
109
public/build/assets/app-01291e40.js
vendored
File diff suppressed because one or more lines are too long
9
public/build/assets/app-253efa47.js
vendored
Normal file
9
public/build/assets/app-253efa47.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@
|
||||
]
|
||||
},
|
||||
"resources/js/app.js": {
|
||||
"file": "assets/app-01291e40.js",
|
||||
"file": "assets/app-253efa47.js",
|
||||
"imports": [
|
||||
"_index-08e160a7.js",
|
||||
"__commonjsHelpers-725317a4.js"
|
||||
|
3
resources/js/app.js
vendored
3
resources/js/app.js
vendored
@ -10,9 +10,6 @@
|
||||
|
||||
import axios from 'axios';
|
||||
import cardValidator from 'card-validator';
|
||||
import { Livewire } from '../../vendor/livewire/livewire/dist/livewire.esm'
|
||||
|
||||
Livewire.start()
|
||||
|
||||
window.axios = axios;
|
||||
window.valid = cardValidator;
|
||||
|
@ -67,6 +67,8 @@
|
||||
<link rel="canonical" href="{{ config('ninja.site_url') }}/{{ request()->path() }}"/>
|
||||
|
||||
|
||||
@livewireStyles
|
||||
|
||||
{{-- Feel free to push anything to header using @push('header') --}}
|
||||
@stack('head')
|
||||
|
||||
|
@ -90,6 +90,7 @@
|
||||
</style>
|
||||
@endif
|
||||
|
||||
@livewireStyles
|
||||
|
||||
{{-- Feel free to push anything to header using @push('header') --}}
|
||||
@stack('head')
|
||||
|
@ -96,6 +96,7 @@
|
||||
{{-- Feel free to push anything to header using @push('header') --}}
|
||||
@stack('head')
|
||||
|
||||
@livewireStyles
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{{ asset('vendor/cookieconsent@3/cookieconsent.min.css') }}" defer>
|
||||
</head>
|
||||
|
@ -93,7 +93,7 @@
|
||||
</style>
|
||||
@endif
|
||||
|
||||
|
||||
@livewireStyles
|
||||
|
||||
{{-- Feel free to push anything to header using @push('header') --}}
|
||||
@stack('head')
|
||||
|
@ -83,7 +83,7 @@
|
||||
{{-- Feel free to push anything to header using @push('header') --}}
|
||||
@stack('head')
|
||||
|
||||
|
||||
@livewireStyles
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{{ asset('vendor/cookieconsent@3/cookieconsent.min.css') }}" />
|
||||
</head>
|
||||
|
@ -11,18 +11,20 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use Tests\TestCase;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Project;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
use App\Models\Subscription;
|
||||
use App\Models\ClientContact;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -49,6 +51,48 @@ class InvoiceTest extends TestCase
|
||||
$this->makeTestData();
|
||||
}
|
||||
|
||||
public function testInvoicePaymentLinkMutation()
|
||||
{
|
||||
|
||||
|
||||
$s = Subscription::factory()
|
||||
->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]);
|
||||
|
||||
|
||||
$s2 = Subscription::factory()
|
||||
->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]);
|
||||
|
||||
|
||||
$r = Invoice::factory()
|
||||
->create(['company_id' => $this->company->id, 'user_id' => $this->user->id,'client_id' => $this->client->id]);
|
||||
|
||||
$rr = $r->service()->setPaymentLink($s->hashed_id)->save();
|
||||
|
||||
$this->assertEquals($s->id, $rr->subscription_id);
|
||||
|
||||
$data = [
|
||||
'subscription_id' => $s2->hashed_id,
|
||||
'action' => 'set_payment_link',
|
||||
'ids' => [$r->hashed_id],
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->postJson('/api/v1/invoices/bulk', $data)
|
||||
->assertStatus(200);
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
$r = $r->fresh();
|
||||
|
||||
$this->assertEquals($s2->id, $r->subscription_id);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testPostNewInvoiceWithProjectButNoClient()
|
||||
{
|
||||
|
||||
|
@ -11,24 +11,26 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Factory\InvoiceItemFactory;
|
||||
use App\Factory\InvoiceToRecurringInvoiceFactory;
|
||||
use App\Factory\RecurringInvoiceFactory;
|
||||
use App\Factory\RecurringInvoiceToInvoiceFactory;
|
||||
use App\Jobs\RecurringInvoice\UpdateRecurring;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Product;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Utils\Helpers;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
use App\Models\Client;
|
||||
use App\Utils\Helpers;
|
||||
use App\Models\Product;
|
||||
use Tests\MockAccountData;
|
||||
use App\Models\Subscription;
|
||||
use App\Models\ClientContact;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Factory\InvoiceItemFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use App\Factory\RecurringInvoiceFactory;
|
||||
use Database\Factories\SubscriptionFactory;
|
||||
use App\Jobs\RecurringInvoice\UpdateRecurring;
|
||||
use App\Factory\InvoiceToRecurringInvoiceFactory;
|
||||
use App\Factory\RecurringInvoiceToInvoiceFactory;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -59,8 +61,44 @@ class RecurringInvoiceTest extends TestCase
|
||||
$this->makeTestData();
|
||||
}
|
||||
|
||||
public function testLinkingSubscription()
|
||||
{
|
||||
$s = Subscription::factory()
|
||||
->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]);
|
||||
|
||||
|
||||
$s2 = Subscription::factory()
|
||||
->create(['company_id' => $this->company->id, 'user_id' => $this->user->id]);
|
||||
|
||||
|
||||
$r = RecurringInvoice::factory()
|
||||
->create(['company_id' => $this->company->id, 'user_id' => $this->user->id,'client_id' => $this->client->id]);
|
||||
|
||||
$rr = $r->service()->setPaymentLink($s->hashed_id)->save();
|
||||
|
||||
$this->assertEquals($s->id, $rr->subscription_id);
|
||||
|
||||
$data = [
|
||||
'subscription_id' => $s2->hashed_id,
|
||||
'action' => 'set_payment_link',
|
||||
'ids' => [$r->hashed_id],
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->postJson('/api/v1/recurring_invoices/bulk', $data)
|
||||
->assertStatus(200);
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
$r = $r->fresh();
|
||||
|
||||
$this->assertEquals($s2->id, $r->subscription_id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testStartDate()
|
||||
{
|
||||
$line_items = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user