mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on statements
This commit is contained in:
parent
446c30f37c
commit
e51baa4058
@ -17,6 +17,7 @@ use App\Ninja\Repositories\InvoiceRepository;
|
|||||||
use App\Ninja\Repositories\PaymentRepository;
|
use App\Ninja\Repositories\PaymentRepository;
|
||||||
use App\Ninja\Repositories\TaskRepository;
|
use App\Ninja\Repositories\TaskRepository;
|
||||||
use App\Services\PaymentService;
|
use App\Services\PaymentService;
|
||||||
|
use App\Jobs\Client\GenerateStatementData;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Barracuda\ArchiveStream\ZipArchive;
|
use Barracuda\ArchiveStream\ZipArchive;
|
||||||
use Cache;
|
use Cache;
|
||||||
@ -1025,7 +1026,6 @@ class ClientPortalController extends BaseController
|
|||||||
$statusId = request()->status_id;
|
$statusId = request()->status_id;
|
||||||
$startDate = request()->start_date;
|
$startDate = request()->start_date;
|
||||||
$endDate = request()->end_date;
|
$endDate = request()->end_date;
|
||||||
$account = auth()->user()->account;
|
|
||||||
|
|
||||||
if (! $startDate) {
|
if (! $startDate) {
|
||||||
$startDate = Utils::today(false)->modify('-6 month')->format('Y-m-d');
|
$startDate = Utils::today(false)->modify('-6 month')->format('Y-m-d');
|
||||||
@ -1033,7 +1033,7 @@ class ClientPortalController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (request()->json) {
|
if (request()->json) {
|
||||||
return dispatch(new GenerateStatementData($client, request()->all()));
|
return dispatch(new GenerateStatementData($client, request()->all(), $contact));
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
@ -9,10 +9,11 @@ use App\Models\Eloquent;
|
|||||||
|
|
||||||
class GenerateStatementData
|
class GenerateStatementData
|
||||||
{
|
{
|
||||||
public function __construct($client, $options)
|
public function __construct($client, $options, $contact = false)
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
|
$this->contact = $contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,9 +24,11 @@ class GenerateStatementData
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$client = $this->client;
|
$client = $this->client;
|
||||||
|
$client->load('contacts');
|
||||||
$account = $client->account;
|
$account = $client->account;
|
||||||
|
|
||||||
$invoice = $account->createInvoice(ENTITY_INVOICE);
|
$invoice = new Invoice();
|
||||||
|
$invoice->account = $account;
|
||||||
$invoice->client = $client;
|
$invoice->client = $client;
|
||||||
$invoice->date_format = $account->date_format ? $account->date_format->format_moment : 'MMM D, YYYY';
|
$invoice->date_format = $account->date_format ? $account->date_format->format_moment : 'MMM D, YYYY';
|
||||||
|
|
||||||
@ -42,8 +45,7 @@ class GenerateStatementData
|
|||||||
{
|
{
|
||||||
$statusId = intval($this->options['status_id']);
|
$statusId = intval($this->options['status_id']);
|
||||||
|
|
||||||
$invoices = Invoice::scope()
|
$invoices = Invoice::with(['client'])
|
||||||
->with(['client'])
|
|
||||||
->invoices()
|
->invoices()
|
||||||
->whereClientId($this->client->id)
|
->whereClientId($this->client->id)
|
||||||
->whereIsPublic(true)
|
->whereIsPublic(true)
|
||||||
@ -61,6 +63,12 @@ class GenerateStatementData
|
|||||||
->where('invoice_date', '<=', $this->options['end_date']);
|
->where('invoice_date', '<=', $this->options['end_date']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->contact) {
|
||||||
|
$invoices->whereHas('invitations', function ($query) {
|
||||||
|
$query->where('contact_id', $this->contact->id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$invoices = $invoices->get();
|
$invoices = $invoices->get();
|
||||||
$data = collect();
|
$data = collect();
|
||||||
|
|
||||||
@ -87,8 +95,7 @@ class GenerateStatementData
|
|||||||
|
|
||||||
private function getPayments()
|
private function getPayments()
|
||||||
{
|
{
|
||||||
$payments = Payment::scope()
|
$payments = Payment::with('invoice', 'payment_type')
|
||||||
->with('invoice', 'payment_type')
|
|
||||||
->withArchived()
|
->withArchived()
|
||||||
->whereClientId($this->client->id)
|
->whereClientId($this->client->id)
|
||||||
->where('payment_date', '>=', $this->options['start_date'])
|
->where('payment_date', '>=', $this->options['start_date'])
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
<link href="{{ asset('css/daterangepicker.css') }}" rel="stylesheet" type="text/css"/>
|
<link href="{{ asset('css/daterangepicker.css') }}" rel="stylesheet" type="text/css"/>
|
||||||
|
|
||||||
@include('money_script')
|
@include('money_script')
|
||||||
@foreach (Auth::user()->account->getFontFolders() as $font)
|
@foreach ($account->getFontFolders() as $font)
|
||||||
<script src="{{ asset('js/vfs_fonts/'.$font.'.js') }}" type="text/javascript"></script>
|
<script src="{{ asset('js/vfs_fonts/'.$font.'.js') }}" type="text/javascript"></script>
|
||||||
@endforeach
|
@endforeach
|
||||||
<script src="{{ asset('pdf.built.js') }}?no_cache={{ NINJA_VERSION }}" type="text/javascript"></script>
|
<script src="{{ asset('pdf.built.js') }}?no_cache={{ NINJA_VERSION }}" type="text/javascript"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var invoiceDesigns = {!! \App\Models\InvoiceDesign::getDesigns() !!};
|
var invoiceDesign = JSON.stringify({!! Utils::getFromCache($account->invoice_design_id ?: 1, 'invoiceDesigns')->pdfmake !!});
|
||||||
var invoiceFonts = {!! Cache::get('fonts') !!};
|
var invoiceFonts = {!! Cache::get('fonts') !!};
|
||||||
|
|
||||||
var statementStartDate = moment("{{ $startDate }}");
|
var statementStartDate = moment("{{ $startDate }}");
|
||||||
@ -22,26 +22,15 @@
|
|||||||
var dateRanges = {!! $account->present()->dateRangeOptions !!};
|
var dateRanges = {!! $account->present()->dateRangeOptions !!};
|
||||||
|
|
||||||
function getPDFString(cb) {
|
function getPDFString(cb) {
|
||||||
|
|
||||||
invoice.is_statement = true;
|
invoice.is_statement = true;
|
||||||
invoice.image = window.accountLogo;
|
invoice.image = window.accountLogo;
|
||||||
invoice.features = {
|
invoice.features = {
|
||||||
customize_invoice_design:{{ Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ? 'true' : 'false' }},
|
customize_invoice_design:{{ $account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ? 'true' : 'false' }},
|
||||||
remove_created_by:{{ Auth::user()->hasFeature(FEATURE_REMOVE_CREATED_BY) ? 'true' : 'false' }},
|
remove_created_by:{{ $account->hasFeature(FEATURE_REMOVE_CREATED_BY) ? 'true' : 'false' }},
|
||||||
invoice_settings:{{ Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS) ? 'true' : 'false' }}
|
invoice_settings:{{ $account->hasFeature(FEATURE_INVOICE_SETTINGS) ? 'true' : 'false' }}
|
||||||
};
|
};
|
||||||
|
|
||||||
var invoiceDesignId = parseInt(invoice.invoice_design_id);
|
generatePDF(invoice, invoiceDesign, true, cb);
|
||||||
// We don't currently support the hipster design to be used as a statement
|
|
||||||
if (invoiceDesignId == 8) {
|
|
||||||
invoiceDesignId = 1;
|
|
||||||
}
|
|
||||||
var invoiceDesign = _.findWhere(invoiceDesigns, {id: invoiceDesignId});
|
|
||||||
if (!invoiceDesign) {
|
|
||||||
invoiceDesign = invoiceDesigns[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
generatePDF(invoice, invoiceDesign.javascript, true, cb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
@ -98,7 +87,8 @@
|
|||||||
$('#reportrange').css('color', '#000');
|
$('#reportrange').css('color', '#000');
|
||||||
$('#reportrange').css('pointer-events', 'auto');
|
$('#reportrange').css('pointer-events', 'auto');
|
||||||
}
|
}
|
||||||
var url = '{{ url('/clients/statement/' . $client->public_id) }}' +
|
console.log("{{ request()->path() }}");
|
||||||
|
var url = '/{{ request()->path() . '/' . $client->public_id }}' +
|
||||||
'?status_id=' + statusId +
|
'?status_id=' + statusId +
|
||||||
'&start_date=' + statementStartDate.format('YYYY-MM-DD') +
|
'&start_date=' + statementStartDate.format('YYYY-MM-DD') +
|
||||||
'&end_date=' + statementEndDate.format('YYYY-MM-DD') +
|
'&end_date=' + statementEndDate.format('YYYY-MM-DD') +
|
||||||
@ -120,7 +110,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onDownloadClick() {
|
function onDownloadClick() {
|
||||||
var doc = generatePDF(invoice, invoiceDesigns[0].javascript, true);
|
var doc = generatePDF(invoice, invoiceDesign, true);
|
||||||
doc.save("{{ str_replace(' ', '_', trim($client->getDisplayName())) . '-' . trans('texts.statement') }}" + '.pdf');
|
doc.save("{{ str_replace(' ', '_', trim($client->getDisplayName())) . '-' . trans('texts.statement') }}" + '.pdf');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,6 +195,6 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@include('invoices.pdf', ['account' => Auth::user()->account])
|
@include('invoices.pdf', ['account' => $account])
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
@ -28,7 +28,7 @@ Route::group(['middleware' => ['lookup:contact', 'auth:client']], function () {
|
|||||||
Route::match(['GET', 'POST'], 'complete/{invitation_key?}/{gateway_type?}', 'OnlinePaymentController@offsitePayment');
|
Route::match(['GET', 'POST'], 'complete/{invitation_key?}/{gateway_type?}', 'OnlinePaymentController@offsitePayment');
|
||||||
Route::get('bank/{routing_number}', 'OnlinePaymentController@getBankInfo');
|
Route::get('bank/{routing_number}', 'OnlinePaymentController@getBankInfo');
|
||||||
Route::get('client/payment_methods', 'ClientPortalController@paymentMethods');
|
Route::get('client/payment_methods', 'ClientPortalController@paymentMethods');
|
||||||
Route::get('client/statement', 'ClientPortalController@statement');
|
Route::get('client/statement/{client_id?}', 'ClientPortalController@statement');
|
||||||
Route::post('client/payment_methods/verify', 'ClientPortalController@verifyPaymentMethod');
|
Route::post('client/payment_methods/verify', 'ClientPortalController@verifyPaymentMethod');
|
||||||
Route::post('client/payment_methods/default', 'ClientPortalController@setDefaultPaymentMethod');
|
Route::post('client/payment_methods/default', 'ClientPortalController@setDefaultPaymentMethod');
|
||||||
Route::post('client/payment_methods/{source_id}/remove', 'ClientPortalController@removePaymentMethod');
|
Route::post('client/payment_methods/{source_id}/remove', 'ClientPortalController@removePaymentMethod');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user