mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Merge pull request #7626 from turbo124/v5-develop
Pad out expense when converted from Purchase Order
This commit is contained in:
commit
63bd1a5561
@ -239,7 +239,7 @@ class InvitationController extends Controller
|
||||
$invitation->contact->restore();
|
||||
|
||||
auth()->guard('contact')->loginUsingId($invitation->contact->id, true);
|
||||
|
||||
|
||||
$invoice = $invitation->invoice;
|
||||
|
||||
if($invoice->partial > 0)
|
||||
|
@ -90,14 +90,17 @@ class PaymentController extends Controller
|
||||
|
||||
public function response(PaymentResponseRequest $request)
|
||||
{
|
||||
|
||||
|
||||
$gateway = CompanyGateway::findOrFail($request->input('company_gateway_id'));
|
||||
$payment_hash = PaymentHash::where('hash', $request->payment_hash)->first();
|
||||
$payment_hash = PaymentHash::where('hash', $request->payment_hash)->firstOrFail();
|
||||
$invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id);
|
||||
$client = $invoice ? $invoice->client : auth()->user()->client;
|
||||
$client = $invoice ? $invoice->client : auth()->guard('contact')->user()->client;
|
||||
|
||||
// 09-07-2022 catch duplicate responses for invoices that already paid here.
|
||||
if($invoice && $invoice->status_id == Invoice::STATUS_PAID)
|
||||
abort(400, 'Invoice paid. Duplicate submission');
|
||||
|
||||
return $gateway
|
||||
// ->driver(auth()->user()->client)
|
||||
->driver($client)
|
||||
->setPaymentMethod($request->input('payment_method_id'))
|
||||
->setPaymentHash($payment_hash)
|
||||
|
@ -44,6 +44,7 @@ use App\Http\Middleware\UrlSetDb;
|
||||
use App\Http\Middleware\UserVerified;
|
||||
use App\Http\Middleware\VendorLocale;
|
||||
use App\Http\Middleware\VerifyCsrfToken;
|
||||
use App\Http\Middleware\VerifyHash;
|
||||
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
|
||||
use Illuminate\Auth\Middleware\Authorize;
|
||||
use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
|
||||
@ -161,6 +162,7 @@ class Kernel extends HttpKernel
|
||||
'locale' => Locale::class,
|
||||
'vendor_locale' => VendorLocale::class,
|
||||
'contact_register' => ContactRegister::class,
|
||||
'verify_hash' => VerifyHash::class,
|
||||
'shop_token_auth' => ShopTokenAuth::class,
|
||||
'phantom_secret' => PhantomSecret::class,
|
||||
'contact_key_login' => ContactKeyLogin::class,
|
||||
|
37
app/Http/Middleware/VerifyHash.php
Normal file
37
app/Http/Middleware/VerifyHash.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Utils\Ninja;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class VerifyHash
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
if($request->has('payment_hash')){
|
||||
|
||||
$ph = PaymentHash::with('fee_invoice')->where('hash', $request->payment_hash)->first();
|
||||
|
||||
if($ph)
|
||||
auth()->guard('contact')->loginUsingId($ph->fee_invoice->invitations->first()->contact->id, true);
|
||||
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
|
||||
abort(404, 'Unable to verify payment hash');
|
||||
}
|
||||
}
|
@ -39,7 +39,7 @@ class VersionCheck implements ShouldQueue
|
||||
|
||||
nlog("latest version = {$version_file}");
|
||||
|
||||
if ($version_file) {
|
||||
if (Ninja::isSelfHost() && $version_file) {
|
||||
Account::whereNotNull('id')->update(['latest_version' => $version_file]);
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,11 @@ namespace App\Services\PurchaseOrder;
|
||||
|
||||
use App\Factory\ExpenseFactory;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Utils\Traits\GeneratesCounter;
|
||||
|
||||
class PurchaseOrderExpense
|
||||
{
|
||||
use GeneratesCounter;
|
||||
|
||||
private PurchaseOrder $purchase_order;
|
||||
|
||||
@ -36,11 +38,25 @@ class PurchaseOrderExpense
|
||||
$expense->public_notes = $this->purchase_order->public_notes;
|
||||
$expense->uses_inclusive_taxes = $this->purchase_order->uses_inclusive_taxes;
|
||||
$expense->calculate_tax_by_amount = true;
|
||||
$expense->private_notes = ctrans('texts.purchase_order_number_short') . " " . $this->purchase_order->number;
|
||||
|
||||
$line_items = $this->purchase_order->line_items;
|
||||
|
||||
$expense->public_notes = '';
|
||||
|
||||
foreach($line_items as $line_item){
|
||||
$expense->public_notes .= $line_item->quantity . " x " . $line_item->product_key. " [ " .$line_item->notes . " ]\n";
|
||||
}
|
||||
|
||||
$tax_map = $this->purchase_order->calc()->getTaxMap();
|
||||
|
||||
$expense->tax_amount1 = $this->purchase_order->total_taxes;
|
||||
$expense->tax_name1 = ctrans("texts.tax");
|
||||
if($this->purchase_order->total_taxes > 0)
|
||||
{
|
||||
$expense->tax_amount1 = $this->purchase_order->total_taxes;
|
||||
$expense->tax_name1 = ctrans("texts.tax");
|
||||
}
|
||||
|
||||
$expense->number = empty($expense->number) ? $this->getNextExpenseNumber($expense) : $expense->number;
|
||||
|
||||
$expense->save();
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIndexToPaymentHash extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('payment_hashes', function (Blueprint $table) {
|
||||
$table->string('hash', 255)->index()->change();
|
||||
});
|
||||
|
||||
Schema::table('activities', function (Blueprint $table) {
|
||||
$table->index(['quote_id', 'company_id']);
|
||||
$table->index(['recurring_invoice_id', 'company_id']);
|
||||
$table->index(['purchase_order_id', 'company_id']);
|
||||
$table->index(['vendor_contact_id', 'company_id']);
|
||||
});
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->index(['company_id', 'user_id', 'assigned_user_id', 'updated_at'],'pro_co_us_up_index');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
@ -2247,7 +2247,7 @@ $LANG = array(
|
||||
'navigation_variables' => 'Navigation Variables',
|
||||
'custom_variables' => 'Custom Variables',
|
||||
'invalid_file' => 'Invalid file type',
|
||||
'add_documents_to_invoice' => 'Add documents to invoice',
|
||||
'add_documents_to_invoice' => 'Add Documents to Invoice',
|
||||
'mark_expense_paid' => 'Mark paid',
|
||||
'white_label_license_error' => 'Failed to validate the license, check storage/logs/laravel-error.log for more details.',
|
||||
'plan_price' => 'Plan Price',
|
||||
|
@ -53,8 +53,9 @@ Route::group(['middleware' => ['auth:contact', 'locale', 'domain_db','check_clie
|
||||
|
||||
Route::get('payments', 'ClientPortal\PaymentController@index')->name('payments.index')->middleware('portal_enabled');
|
||||
Route::get('payments/{payment}', 'ClientPortal\PaymentController@show')->name('payments.show');
|
||||
Route::post('payments/process/response', 'ClientPortal\PaymentController@response')->name('payments.response');
|
||||
Route::get('payments/process/response', 'ClientPortal\PaymentController@response')->name('payments.response.get');
|
||||
|
||||
// Route::post('payments/process/response', 'ClientPortal\PaymentController@response')->name('payments.response');
|
||||
// Route::get('payments/process/response', 'ClientPortal\PaymentController@response')->name('payments.response.get');
|
||||
|
||||
Route::get('profile/{client_contact}/edit', 'ClientPortal\ProfileController@edit')->name('profile.edit');
|
||||
Route::put('profile/{client_contact}/edit', 'ClientPortal\ProfileController@update')->name('profile.update');
|
||||
@ -99,6 +100,9 @@ Route::group(['middleware' => ['auth:contact', 'locale', 'domain_db','check_clie
|
||||
|
||||
});
|
||||
|
||||
Route::post('payments/process/response', 'ClientPortal\PaymentController@response')->name('client.payments.response')->middleware(['locale', 'domain_db', 'verify_hash']);
|
||||
Route::get('payments/process/response', 'ClientPortal\PaymentController@response')->name('client.payments.response.get')->middleware(['locale', 'domain_db', 'verify_hash']);
|
||||
|
||||
Route::get('client/subscriptions/{subscription}/purchase', 'ClientPortal\SubscriptionPurchaseController@index')->name('client.subscription.purchase')->middleware('domain_db');
|
||||
|
||||
Route::group(['middleware' => ['invite_db'], 'prefix' => 'client', 'as' => 'client.'], function () {
|
||||
|
Loading…
Reference in New Issue
Block a user