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();
$this->version = '1.00.04';
$this->version = '1.00.05';
$this->load->library( 'beheer/session/RetrieveUserSession' );
@@ -20,6 +20,8 @@ class InvoiceOverview {
private $needInvoice;
private $projectDetails;
private $projectnumber;
private $projectPayment;
private $invoicesToPay;
public function __construct( $project, $year )
{
@@ -35,7 +37,7 @@ class InvoiceOverview {
return $this->projectDetails;
}
public function getNeedinvoice( )
public function getNeedinvoice()
{
return $this->needInvoice;
}
@@ -56,8 +58,12 @@ class InvoiceOverview {
$this->setTotalInvoicedThisYear();
$this->setPaymentPerProject();
$this->setInvoicesTotal();
$this->setInvoicesToPay();
$this->setNeedInvoice();
$this->setProjectDetails();
@@ -104,12 +110,22 @@ class InvoiceOverview {
Invoice::invoicePerYear( $this->project->id, $this->year, TRUE );
}
private function setPaymentPerProject()
{
$this->projectPayment = Payment::getPaymentPerProject( $this->project->id );
}
private function setInvoicesTotal()
{
$this->invoicesTotal =
$this->totalInvoicedOtherYears + $this->totalInvoicedThisYear;
}
private function setInvoicesToPay()
{
$this->invoicesToPay = $this->invoicesTotal - $this->projectPayment;
}
private function setNeedInvoice()
{
$this->needInvoice =
@@ -127,6 +143,8 @@ class InvoiceOverview {
'totalInvoicedOtherYears' => number_format( $this->totalInvoicedOtherYears, 0, ',', '.' ),
'totalInvoicedThisYear' => number_format( $this->totalInvoicedThisYear, 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, ',', '.' )
];
}
+13
View File
@@ -15,6 +15,19 @@ class Payment extends BaseModel {
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 )
{
$payment = (array) $payment;
@@ -29,6 +29,12 @@
<th class="rotate">
<div><span>Gefactureerd totaal<br />incl. btw</span></div>
</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">
<div><span>Nog te factureren<br />incl. btw</span></div>
</th>
@@ -45,6 +51,8 @@
<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: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>
</tr>
<!-- /ko -->
@@ -69,6 +77,12 @@
<th class="align-right">
<span data-bind="text:invoicesTotal"></span>
</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">
<span data-bind="text:needInvoice"></span>
</th>