invoice added new columns

This commit is contained in:
2019-04-30 19:07:18 +02:00
parent ecb2d3437c
commit ddea739199
5 changed files with 55 additions and 2 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
{ {
parent::__construct(); parent::__construct();
$this->version = '1.00.04'; $this->version = '1.00.05';
$this->load->library( 'beheer/session/RetrieveUserSession' ); $this->load->library( 'beheer/session/RetrieveUserSession' );
@@ -20,6 +20,8 @@ class InvoiceOverview {
private $needInvoice; private $needInvoice;
private $projectDetails; private $projectDetails;
private $projectnumber; private $projectnumber;
private $projectPayment;
private $invoicesToPay;
public function __construct( $project, $year ) public function __construct( $project, $year )
{ {
@@ -35,7 +37,7 @@ class InvoiceOverview {
return $this->projectDetails; return $this->projectDetails;
} }
public function getNeedinvoice( ) public function getNeedinvoice()
{ {
return $this->needInvoice; return $this->needInvoice;
} }
@@ -56,8 +58,12 @@ class InvoiceOverview {
$this->setTotalInvoicedThisYear(); $this->setTotalInvoicedThisYear();
$this->setPaymentPerProject();
$this->setInvoicesTotal(); $this->setInvoicesTotal();
$this->setInvoicesToPay();
$this->setNeedInvoice(); $this->setNeedInvoice();
$this->setProjectDetails(); $this->setProjectDetails();
@@ -104,12 +110,22 @@ class InvoiceOverview {
Invoice::invoicePerYear( $this->project->id, $this->year, TRUE ); Invoice::invoicePerYear( $this->project->id, $this->year, TRUE );
} }
private function setPaymentPerProject()
{
$this->projectPayment = Payment::getPaymentPerProject( $this->project->id );
}
private function setInvoicesTotal() private function setInvoicesTotal()
{ {
$this->invoicesTotal = $this->invoicesTotal =
$this->totalInvoicedOtherYears + $this->totalInvoicedThisYear; $this->totalInvoicedOtherYears + $this->totalInvoicedThisYear;
} }
private function setInvoicesToPay()
{
$this->invoicesToPay = $this->invoicesTotal - $this->projectPayment;
}
private function setNeedInvoice() private function setNeedInvoice()
{ {
$this->needInvoice = $this->needInvoice =
@@ -127,6 +143,8 @@ class InvoiceOverview {
'totalInvoicedOtherYears' => number_format( $this->totalInvoicedOtherYears, 0, ',', '.' ), 'totalInvoicedOtherYears' => number_format( $this->totalInvoicedOtherYears, 0, ',', '.' ),
'totalInvoicedThisYear' => number_format( $this->totalInvoicedThisYear, 0, ',', '.' ), 'totalInvoicedThisYear' => number_format( $this->totalInvoicedThisYear, 0, ',', '.' ),
'invoicesTotal' => number_format( $this->invoicesTotal, 0, ',', '.' ), 'invoicesTotal' => number_format( $this->invoicesTotal, 0, ',', '.' ),
'projectPayment' => number_format( $this->projectPayment, 0, ',', '.' ),
'invoiceToPay' => number_format( $this->invoicesToPay, 0, ',', '.' ),
'needInvoice' => number_format( $this->needInvoice, 0, ',', '.' ) 'needInvoice' => number_format( $this->needInvoice, 0, ',', '.' )
]; ];
} }
+13
View File
@@ -15,6 +15,19 @@ class Payment extends BaseModel {
return $this->belongsTo( 'Invoice' ); return $this->belongsTo( 'Invoice' );
} }
public static function getPaymentPerProject( $projectID )
{
$projectPayment = self::selectRAW( 'id, invoice_id, SUM(paymentamount) as payment' )
->whereHas( 'invoice', function ( $q ) use ( $projectID ) {
$q->whereProjectId( $projectID );
} )
->first();
if( ! $projectPayment) return 0;
return $projectPayment->payment;
}
public static function savePayment( $paymentID, $payment ) public static function savePayment( $paymentID, $payment )
{ {
$payment = (array) $payment; $payment = (array) $payment;
@@ -29,6 +29,12 @@
<th class="rotate"> <th class="rotate">
<div><span>Gefactureerd totaal<br />incl. btw</span></div> <div><span>Gefactureerd totaal<br />incl. btw</span></div>
</th> </th>
<th class="rotate">
<div><span>Betaald incl. btw</span></div>
</th>
<th class="rotate">
<div><span>gefactureerd niet betaald<br />incl. btw</span></div>
</th>
<th class="rotate"> <th class="rotate">
<div><span>Nog te factureren<br />incl. btw</span></div> <div><span>Nog te factureren<br />incl. btw</span></div>
</th> </th>
@@ -45,6 +51,8 @@
<td class="align-right"><span data-bind="text:totalInvoicedOtherYears"></span></td> <td class="align-right"><span data-bind="text:totalInvoicedOtherYears"></span></td>
<td class="align-right"><span data-bind="text:totalInvoicedThisYear"></span></td> <td class="align-right"><span data-bind="text:totalInvoicedThisYear"></span></td>
<td class="align-right"><span data-bind="text:invoicesTotal"></span></td> <td class="align-right"><span data-bind="text:invoicesTotal"></span></td>
<td class="align-right"><span data-bind="text:projectPayment"></span></td>
<td class="align-right"><span data-bind="text:invoiceToPay"></span></td>
<td class="align-right focus-green"><span data-bind="text:needInvoice"></span></td> <td class="align-right focus-green"><span data-bind="text:needInvoice"></span></td>
</tr> </tr>
<!-- /ko --> <!-- /ko -->
@@ -69,6 +77,12 @@
<th class="align-right"> <th class="align-right">
<span data-bind="text:invoicesTotal"></span> <span data-bind="text:invoicesTotal"></span>
</th> </th>
<th class="align-right">
<span data-bind="text:totalPayment"></span>
</th>
<th class="align-right">
<span data-bind="text:totalToPay"></span>
</th>
<th class="align-right focus-green"> <th class="align-right focus-green">
<span data-bind="text:needInvoice"></span> <span data-bind="text:needInvoice"></span>
</th> </th>
@@ -29,6 +29,8 @@ dbo.invoicereportInit = function () {
totalToInvoicingIncl : ko.observable(), totalToInvoicingIncl : ko.observable(),
totalInvoicedOtherYears: ko.observable(), totalInvoicedOtherYears: ko.observable(),
totalInvoicedThisYear : ko.observable(), totalInvoicedThisYear : ko.observable(),
totalPayment : ko.observable(),
totalToPay : ko.observable(),
invoicesTotal : ko.observable(), invoicesTotal : ko.observable(),
needInvoice : ko.observable(), needInvoice : ko.observable(),
forecastThisYear : ko.observable(), forecastThisYear : ko.observable(),
@@ -111,6 +113,8 @@ dbo.invoicereportInit = function () {
vm.totalInvoicedOtherYears( 0 ); vm.totalInvoicedOtherYears( 0 );
vm.totalInvoicedThisYear( 0 ); vm.totalInvoicedThisYear( 0 );
vm.invoicesTotal( 0 ); vm.invoicesTotal( 0 );
vm.totalPayment( 0 );
vm.totalToPay( 0 );
vm.needInvoice( 0 ); vm.needInvoice( 0 );
vm.forecastThisYear( 0 ); vm.forecastThisYear( 0 );
vm.forecastOtherYears( 0 ); vm.forecastOtherYears( 0 );
@@ -134,6 +138,8 @@ dbo.invoicereportInit = function () {
vm.totalInvoicedOtherYears( vm.totalInvoicedOtherYears() + Number( p.totalInvoicedOtherYears.replace( '.', '' ) ) ); vm.totalInvoicedOtherYears( vm.totalInvoicedOtherYears() + Number( p.totalInvoicedOtherYears.replace( '.', '' ) ) );
vm.totalInvoicedThisYear( vm.totalInvoicedThisYear() + Number( p.totalInvoicedThisYear.replace( '.', '' ) ) ); vm.totalInvoicedThisYear( vm.totalInvoicedThisYear() + Number( p.totalInvoicedThisYear.replace( '.', '' ) ) );
vm.invoicesTotal( vm.invoicesTotal() + Number( p.invoicesTotal.replace( '.', '' ) ) ); vm.invoicesTotal( vm.invoicesTotal() + Number( p.invoicesTotal.replace( '.', '' ) ) );
vm.totalPayment( vm.totalPayment() + Number( p.projectPayment.replace( '.', '' ) ) );
vm.totalToPay( vm.totalToPay() + Number( p.invoiceToPay.replace( '.', '' ) ) );
vm.needInvoice( vm.needInvoice() + Number( p.needInvoice.replace( '.', '' ) ) ); vm.needInvoice( vm.needInvoice() + Number( p.needInvoice.replace( '.', '' ) ) );
} ); } );
@@ -142,6 +148,8 @@ dbo.invoicereportInit = function () {
vm.totalInvoicedOtherYears( dbo.helpers.thousandSeparator( vm.totalInvoicedOtherYears() ) ); vm.totalInvoicedOtherYears( dbo.helpers.thousandSeparator( vm.totalInvoicedOtherYears() ) );
vm.totalInvoicedThisYear( dbo.helpers.thousandSeparator( vm.totalInvoicedThisYear() ) ); vm.totalInvoicedThisYear( dbo.helpers.thousandSeparator( vm.totalInvoicedThisYear() ) );
vm.invoicesTotal( dbo.helpers.thousandSeparator( vm.invoicesTotal() ) ); vm.invoicesTotal( dbo.helpers.thousandSeparator( vm.invoicesTotal() ) );
vm.totalPayment( dbo.helpers.thousandSeparator( vm.totalPayment() ) );
vm.totalToPay( dbo.helpers.thousandSeparator( vm.totalToPay() ) );
vm.needInvoice( dbo.helpers.thousandSeparator( vm.needInvoice() ) ); vm.needInvoice( dbo.helpers.thousandSeparator( vm.needInvoice() ) );
}, },