mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on Payment list for client portal
This commit is contained in:
parent
c2441bdef0
commit
a40fb82971
@ -13,6 +13,7 @@ namespace App\Filters;
|
|||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PaymentFilters
|
* PaymentFilters
|
||||||
@ -30,7 +31,8 @@ class PaymentFilters extends QueryFilters
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function filter(string $filter = '') : Builder
|
public function filter(string $filter = '') : Builder
|
||||||
{
|
{Log::error('ewwo');
|
||||||
|
Log::error($filter);
|
||||||
if(strlen($filter) == 0)
|
if(strlen($filter) == 0)
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
|
||||||
|
@ -39,19 +39,19 @@ class PaymentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(PaymentFilters $filters, Builder $builder)
|
public function index(PaymentFilters $filters, Builder $builder)
|
||||||
{
|
{
|
||||||
$payments = Payment::filter($filters);
|
//$payments = Payment::filter($filters);
|
||||||
|
$payments = Payment::all();
|
||||||
if (request()->ajax()) {
|
if (request()->ajax()) {
|
||||||
|
|
||||||
return DataTables::of($payments)->addColumn('action', function ($payment) {
|
return DataTables::of($payments)->addColumn('action', function ($payment) {
|
||||||
return '<a href="/client/payments/'. $payment->hashed_id .'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
|
return '<a href="/client/payments/'. $payment->hashed_id .'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
|
||||||
})->editColumn('payment_type_id', function ($payment) {
|
})->editColumn('payment_type_id', function ($payment) {
|
||||||
return Payment::typeForKey($payment->payment_type_id);
|
return $payment->type->name;
|
||||||
})
|
})
|
||||||
->editColumn('status_id', function ($payment){
|
->editColumn('status_id', function ($payment){
|
||||||
return Payment::badgeForStatus($invoice->status);
|
return Payment::badgeForStatus($payment->status_id);
|
||||||
})
|
})
|
||||||
->rawColumns(['action', 'status_id'])
|
->rawColumns(['action', 'status_id','payment_type_id'])
|
||||||
->make(true);
|
->make(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\BaseModel;
|
||||||
use App\Models\Filterable;
|
use App\Models\Filterable;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@ -27,6 +28,21 @@ class Payment extends BaseModel
|
|||||||
const STATUS_PARTIALLY_REFUNDED = 5;
|
const STATUS_PARTIALLY_REFUNDED = 5;
|
||||||
const STATUS_REFUNDED = 6;
|
const STATUS_REFUNDED = 6;
|
||||||
|
|
||||||
|
const TYPE_CREDIT_CARD = 1;
|
||||||
|
const TYPE_BANK_TRANSFER = 2;
|
||||||
|
const TYPE_PAYPAL = 3;
|
||||||
|
const TYPE_BITCOIN = 4;
|
||||||
|
const TYPE_DWOLLA = 5;
|
||||||
|
const TYPE_CUSTOM1 = 6;
|
||||||
|
const TYPE_ALIPAY = 7;
|
||||||
|
const TYPE_SOFORT = 8;
|
||||||
|
const TYPE_SEPA = 9;
|
||||||
|
const TYPE_GOCARDLESS = 10;
|
||||||
|
const TYPE_APPLE_PAY = 11;
|
||||||
|
const TYPE_CUSTOM2 = 12;
|
||||||
|
const TYPE_CUSTOM3 = 13;
|
||||||
|
const TYPE_TOKEN = 'token';
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'client_id',
|
'client_id',
|
||||||
'payment_type_id',
|
'payment_type_id',
|
||||||
@ -65,18 +81,32 @@ class Payment extends BaseModel
|
|||||||
return $this->morphMany(CompanyLedger::class, 'company_ledgerable');
|
return $this->morphMany(CompanyLedger::class, 'company_ledgerable');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function typeForId(int $payment_type_id)
|
public function type()
|
||||||
{
|
{
|
||||||
|
return $this->hasOne(PaymentType::class,'id','payment_type_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function badgeForStatus(int $status)
|
public static function badgeForStatus(int $status)
|
||||||
{
|
{
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case 'value':
|
case self::STATUS_PENDING:
|
||||||
# code...
|
return '<h4><span class="badge badge-light">'.ctrans('texts.payment_status_1').'</span></h4>';
|
||||||
break;
|
break;
|
||||||
|
case self::STATUS_VOIDED:
|
||||||
|
return '<h4><span class="badge badge-light">'.ctrans('texts.payment_status_2').'</span></h4>';
|
||||||
|
break;
|
||||||
|
case self::STATUS_FAILED:
|
||||||
|
return '<h4><span class="badge badge-light">'.ctrans('texts.payment_status_3').'</span></h4>';
|
||||||
|
break;
|
||||||
|
case self::STATUS_COMPLETED:
|
||||||
|
return '<h4><span class="badge badge-light">'.ctrans('texts.payment_status_4').'</span></h4>';
|
||||||
|
break;
|
||||||
|
case self::STATUS_PARTIALLY_REFUNDED:
|
||||||
|
return '<h4><span class="badge badge-light">'.ctrans('texts.payment_status_5').'</span></h4>';
|
||||||
|
break;
|
||||||
|
case self::STATUS_REFUNDED:
|
||||||
|
return '<h4><span class="badge badge-light">'.ctrans('texts.payment_status_6').'</span></h4>';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
# code...
|
# code...
|
||||||
break;
|
break;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use App\DataMapper\ClientSettings;
|
use App\DataMapper\ClientSettings;
|
||||||
use App\DataMapper\CompanySettings;
|
use App\DataMapper\CompanySettings;
|
||||||
|
use App\Models\Payment;
|
||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
$factory->define(App\Models\Payment::class, function (Faker $faker) {
|
$factory->define(App\Models\Payment::class, function (Faker $faker) {
|
||||||
@ -10,6 +11,8 @@ $factory->define(App\Models\Payment::class, function (Faker $faker) {
|
|||||||
'amount' => $faker->numberBetween(1,10),
|
'amount' => $faker->numberBetween(1,10),
|
||||||
'payment_date' => $faker->date(),
|
'payment_date' => $faker->date(),
|
||||||
'transaction_reference' => $faker->text(10),
|
'transaction_reference' => $faker->text(10),
|
||||||
|
'payment_type_id' => Payment::TYPE_CREDIT_CARD,
|
||||||
|
'status_id' => Payment::STATUS_COMPLETED
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -101,6 +101,8 @@ class RandomDataSeeder extends Seeder
|
|||||||
/** Recurring Invoice Factory */
|
/** Recurring Invoice Factory */
|
||||||
factory(\App\Models\RecurringInvoice::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
|
factory(\App\Models\RecurringInvoice::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
|
||||||
|
|
||||||
|
factory(\App\Models\Payment::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
|
||||||
|
|
||||||
|
|
||||||
$clients = Client::all();
|
$clients = Client::all();
|
||||||
|
|
||||||
|
@ -117,12 +117,12 @@ $(function() {
|
|||||||
columns: [
|
columns: [
|
||||||
|
|
||||||
{data: 'checkbox', name: 'checkbox', title: '<input type="checkbox" class="select_all">', searchable: false, orderable: false},
|
{data: 'checkbox', name: 'checkbox', title: '<input type="checkbox" class="select_all">', searchable: false, orderable: false},
|
||||||
{data: 'invoice_number', name: 'invoice_number', title: '{{trans('texts.invoice_number')}}', visible: true},
|
{data: 'invoice_number', name: 'invoice_number', title: '{{ctrans('texts.invoice_number')}}', visible: true},
|
||||||
{data: 'invoice_date', name: 'invoice_date', title: '{{trans('texts.invoice_date')}}', visible: true},
|
{data: 'invoice_date', name: 'invoice_date', title: '{{ctrans('texts.invoice_date')}}', visible: true},
|
||||||
{data: 'amount', name: 'amount', title: '{{trans('texts.total')}}', visible: true},
|
{data: 'amount', name: 'amount', title: '{{ctrans('texts.total')}}', visible: true},
|
||||||
{data: 'balance', name: 'balance', title: '{{trans('texts.balance')}}', visible: true},
|
{data: 'balance', name: 'balance', title: '{{ctrans('texts.balance')}}', visible: true},
|
||||||
{data: 'due_date', name: 'due_date', title: '{{trans('texts.due_date')}}', visible: true},
|
{data: 'due_date', name: 'due_date', title: '{{ctrans('texts.due_date')}}', visible: true},
|
||||||
{data: 'status_id', name: 'status_id', title: '{{trans('texts.status')}}', visible: true},
|
{data: 'status_id', name: 'status_id', title: '{{ctrans('texts.status')}}', visible: true},
|
||||||
{data: 'action', name: 'action', title: '', searchable: false, orderable: false},
|
{data: 'action', name: 'action', title: '', searchable: false, orderable: false},
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
@ -54,7 +54,7 @@ $(function() {
|
|||||||
zeroRecords: "{{ trans('texts.no_records_found') }}"
|
zeroRecords: "{{ trans('texts.no_records_found') }}"
|
||||||
},
|
},
|
||||||
ajax: {
|
ajax: {
|
||||||
url: '{!! route('client.recurring_invoices.index') !!}',
|
url: '{!! route('client.payments.index') !!}',
|
||||||
data: function(data) {
|
data: function(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,16 +62,16 @@ $(function() {
|
|||||||
drawCallback: function(settings){
|
drawCallback: function(settings){
|
||||||
|
|
||||||
data = this.api().ajax.json().data;
|
data = this.api().ajax.json().data;
|
||||||
|
console.log(data);
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
|
|
||||||
{data: 'payment_date', name: 'payment_date', title: '{{trans('texts.payment_date')}}', visible: true},
|
{data: 'payment_date', name: 'payment_date', title: '{{ctrans('texts.payment_date')}}', visible: true},
|
||||||
{data: 'payment_type_id', name: 'payment_type_id', title: '{{trans('texts.payment_type_id')}}', visible: true},
|
{data: 'payment_type_id', name: 'payment_type_id', title: '{{ctrans('texts.payment_type_id')}}', visible: true},
|
||||||
{data: 'amount', name: 'amount', title: '{{trans('texts.amount')}}', visible: true},
|
{data: 'amount', name: 'amount', title: '{{ctrans('texts.amount')}}', visible: true},
|
||||||
{data: 'status_id', name: 'status_id', title: '{{trans('texts.status')}}', visible: true},
|
{data: 'transaction_reference', name: 'transaction_reference', title: '{{ctrans('texts.transaction_reference')}}', visible: true},
|
||||||
{data: 'transaction_reference', name: 'transaction_reference', title: '{{trans('texts.transaction_reference')}}', visible: true},
|
{data: 'status_id', name: 'status_id', title: '{{ctrans('texts.status')}}', visible: true},
|
||||||
{data: 'action', name: 'action', title: '', searchable: false, orderable: false},
|
{data: 'action', name: 'action', title: '', searchable: false, orderable: false}
|
||||||
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user