Invoiced report
This commit is contained in:
@@ -5,24 +5,24 @@
|
||||
* Time: 11:43
|
||||
*/
|
||||
|
||||
|
||||
dbo.invoicereportInit = function () {
|
||||
|
||||
if ( dbo.invoicereport !== undefined ) {
|
||||
if (dbo.invoicereport !== undefined) {
|
||||
|
||||
dbo.invoicereport.initModule();
|
||||
dbo.invoicereport.initModule()
|
||||
|
||||
} else {
|
||||
dbo.invoicereport = {
|
||||
|
||||
years : ko.observableArray([]),
|
||||
selectedYear : ko.observable(),
|
||||
invoiceOverview : ko.observableArray( [] ),
|
||||
forecasts : ko.observableArray( [] ),
|
||||
monthForecasts : ko.observableArray( [] ),
|
||||
monthPayments : ko.observableArray( [] ),
|
||||
months : ko.observableArray( [] ),
|
||||
monthTotals : ko.observableArray( [] ),
|
||||
monthPaymentTotals : ko.observableArray( [] ),
|
||||
invoiceOverview : ko.observableArray([]),
|
||||
forecasts : ko.observableArray([]),
|
||||
monthForecasts : ko.observableArray([]),
|
||||
monthPayments : ko.observableArray([]),
|
||||
months : ko.observableArray([]),
|
||||
monthTotals : ko.observableArray([]),
|
||||
monthPaymentTotals : ko.observableArray([]),
|
||||
validYear : ko.observable(),
|
||||
invoiceTab : ko.observable(),
|
||||
totalToInvoicingExcl : ko.observable(),
|
||||
@@ -39,221 +39,239 @@ dbo.invoicereportInit = function () {
|
||||
totalProjectPayments : ko.observable(),
|
||||
orderType : 'projectnumber',
|
||||
orderDirection : false,
|
||||
archive : ko.observable( false ),
|
||||
archive : ko.observable(false),
|
||||
recievedInvoices : ko.observableArray([]),
|
||||
invoiced : ko.observableArray([]),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.invoicereport;
|
||||
var vm = dbo.invoicereport
|
||||
|
||||
vm.selectedYear( (new Date()).getFullYear() );
|
||||
vm.invoiceTab( 'invoice' );
|
||||
vm.validYear( true );
|
||||
vm.months( dbo.monthArray );
|
||||
vm.selectedYear((new Date()).getFullYear())
|
||||
vm.invoiceTab('invoice')
|
||||
vm.validYear(true)
|
||||
vm.months(dbo.monthArray)
|
||||
|
||||
vm.initModule();
|
||||
vm.initModule()
|
||||
},
|
||||
|
||||
initModule: function () {
|
||||
var vm = dbo.invoicereport;
|
||||
var vm = dbo.invoicereport
|
||||
|
||||
vm.resetTotals();
|
||||
vm.resetTotals()
|
||||
|
||||
var orderDirection = vm.orderDirection ? 'ASC' : 'DESC';
|
||||
var archive = vm.archive() ? 'T' : 'F';
|
||||
var orderDirection = vm.orderDirection ? 'ASC' : 'DESC'
|
||||
var archive = vm.archive() ? 'T' : 'F'
|
||||
|
||||
dbo.invoiceDataService.getInvoiceOverview( vm.selectedYear(), vm.orderType, orderDirection, archive, function ( data ) {
|
||||
vm.invoiceOverview( data.invoiceOverview );
|
||||
vm.setInvoiceOverviewTotals( data.invoiceOverview );
|
||||
dbo.invoiceDataService.getInvoiceOverview(vm.selectedYear(), vm.orderType, orderDirection, archive, function (data) {
|
||||
vm.invoiceOverview(data.invoiceOverview)
|
||||
vm.setInvoiceOverviewTotals(data.invoiceOverview)
|
||||
|
||||
vm.forecasts( data.forecasts );
|
||||
vm.setForecastsTotals( data.forecasts );
|
||||
vm.forecasts(data.forecasts)
|
||||
vm.setForecastsTotals(data.forecasts)
|
||||
|
||||
vm.monthForecasts.removeAll();
|
||||
_.each( data.monthForecasts, function ( p ) {
|
||||
vm.monthForecasts.push( new vm.Monthforecast( p ) );
|
||||
} );
|
||||
_.each( vm.monthTotals(), function ( p ) {
|
||||
p.forecastamount( dbo.helpers.thousandSeparator( p.forecastamount() ) );
|
||||
} );
|
||||
vm.monthForecasts.removeAll()
|
||||
_.each(data.monthForecasts, function (p) {
|
||||
vm.monthForecasts.push(new vm.Monthforecast(p))
|
||||
})
|
||||
_.each(vm.monthTotals(), function (p) {
|
||||
p.forecastamount(dbo.helpers.thousandSeparator(p.forecastamount()))
|
||||
})
|
||||
|
||||
vm.monthPayments.removeAll();
|
||||
_.each( data.monthPayments, function ( p ) {
|
||||
vm.monthPayments.push( new vm.Monthpayment( p ) );
|
||||
vm.totalProjectPayments( Number( vm.totalProjectPayments() ) + Number( p.totalProjectPayments.replace( '.', '' ) ) );
|
||||
} );
|
||||
vm.totalProjectPayments( dbo.helpers.thousandSeparator( vm.totalProjectPayments() ) );
|
||||
_.each( vm.monthPaymentTotals(), function ( p ) {
|
||||
p.paymentamount( dbo.helpers.thousandSeparator( p.paymentamount() ) );
|
||||
} );
|
||||
vm.monthPayments.removeAll()
|
||||
_.each(data.monthPayments, function (p) {
|
||||
vm.monthPayments.push(new vm.Monthpayment(p))
|
||||
vm.totalProjectPayments(Number(vm.totalProjectPayments()) + Number(p.totalProjectPayments.replace('.', '')))
|
||||
})
|
||||
vm.totalProjectPayments(dbo.helpers.thousandSeparator(vm.totalProjectPayments()))
|
||||
_.each(vm.monthPaymentTotals(), function (p) {
|
||||
p.paymentamount(dbo.helpers.thousandSeparator(p.paymentamount()))
|
||||
})
|
||||
|
||||
} );
|
||||
vm.years(data.invoicedYears);
|
||||
|
||||
vm.invoiced.removeAll()
|
||||
_.each(data.invoiced, function(p){
|
||||
vm.invoiced.push( new vm.Invoice(p));
|
||||
});
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
toggleArchive: function () {
|
||||
var vm = dbo.invoicereport;
|
||||
vm.archive( !vm.archive() );
|
||||
var vm = dbo.invoicereport
|
||||
vm.archive(!vm.archive())
|
||||
|
||||
vm.initModule();
|
||||
vm.initModule()
|
||||
},
|
||||
|
||||
sortList: function ( orderType ) {
|
||||
var vm = dbo.invoicereport;
|
||||
sortList: function (orderType) {
|
||||
var vm = dbo.invoicereport
|
||||
|
||||
vm.orderType = orderType;
|
||||
vm.orderDirection = !vm.orderDirection;
|
||||
vm.orderType = orderType
|
||||
vm.orderDirection = !vm.orderDirection
|
||||
|
||||
vm.initModule();
|
||||
vm.initModule()
|
||||
},
|
||||
|
||||
resetTotals: function () {
|
||||
var vm = dbo.invoicereport;
|
||||
var vm = dbo.invoicereport
|
||||
|
||||
vm.totalToInvoicingExcl( 0 );
|
||||
vm.totalToInvoicingIncl( 0 );
|
||||
vm.totalInvoicedOtherYears( 0 );
|
||||
vm.totalInvoicedThisYear( 0 );
|
||||
vm.invoicesTotal( 0 );
|
||||
vm.totalPayment( 0 );
|
||||
vm.totalToPay( 0 );
|
||||
vm.needInvoice( Number( 0 ) );
|
||||
vm.forecastThisYear( 0 );
|
||||
vm.forecastOtherYears( 0 );
|
||||
vm.forecastRemaining( 0 );
|
||||
vm.totalProjectPayments( 0 );
|
||||
vm.totalToInvoicingExcl(0)
|
||||
vm.totalToInvoicingIncl(0)
|
||||
vm.totalInvoicedOtherYears(0)
|
||||
vm.totalInvoicedThisYear(0)
|
||||
vm.invoicesTotal(0)
|
||||
vm.totalPayment(0)
|
||||
vm.totalToPay(0)
|
||||
vm.needInvoice(Number(0))
|
||||
vm.forecastThisYear(0)
|
||||
vm.forecastOtherYears(0)
|
||||
vm.forecastRemaining(0)
|
||||
vm.totalProjectPayments(0)
|
||||
|
||||
vm.monthTotals.removeAll();
|
||||
vm.monthPaymentTotals.removeAll();
|
||||
for ( var i = 1; i <= 12; i++ ) {
|
||||
vm.monthTotals.push( {monthID: i, forecastamount: ko.observable( 0 )} );
|
||||
vm.monthPaymentTotals.push( {monthID: i, paymentamount: ko.observable( 0 )} );
|
||||
vm.monthTotals.removeAll()
|
||||
vm.monthPaymentTotals.removeAll()
|
||||
for (var i = 1; i <= 12; i++) {
|
||||
vm.monthTotals.push({ monthID: i, forecastamount: ko.observable(0) })
|
||||
vm.monthPaymentTotals.push({ monthID: i, paymentamount: ko.observable(0) })
|
||||
}
|
||||
},
|
||||
|
||||
setInvoiceOverviewTotals: function ( data ) {
|
||||
var vm = dbo.invoicereport;
|
||||
setInvoiceOverviewTotals: function (data) {
|
||||
var vm = dbo.invoicereport
|
||||
|
||||
_.each( data, function ( p ) {
|
||||
vm.totalToInvoicingExcl( vm.totalToInvoicingExcl() + Number( p.totalToInvoicingExcl.replace( '.', '' ) ) );
|
||||
vm.totalToInvoicingIncl( vm.totalToInvoicingIncl() + Number( p.totalToInvoicingIncl.replace( '.', '' ) ) );
|
||||
vm.totalInvoicedOtherYears( vm.totalInvoicedOtherYears() + Number( p.totalInvoicedOtherYears.replace( '.', '' ) ) );
|
||||
vm.totalInvoicedThisYear( vm.totalInvoicedThisYear() + Number( p.totalInvoicedThisYear.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( Number( vm.needInvoice() ) + Number( p.needInvoice.replace( '.', '' ) ) );
|
||||
} );
|
||||
_.each(data, function (p) {
|
||||
vm.totalToInvoicingExcl(vm.totalToInvoicingExcl() + Number(p.totalToInvoicingExcl.replace('.', '')))
|
||||
vm.totalToInvoicingIncl(vm.totalToInvoicingIncl() + Number(p.totalToInvoicingIncl.replace('.', '')))
|
||||
vm.totalInvoicedOtherYears(vm.totalInvoicedOtherYears() + Number(p.totalInvoicedOtherYears.replace('.', '')))
|
||||
vm.totalInvoicedThisYear(vm.totalInvoicedThisYear() + Number(p.totalInvoicedThisYear.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(Number(vm.needInvoice()) + Number(p.needInvoice.replace('.', '')))
|
||||
})
|
||||
|
||||
vm.totalToInvoicingExcl( dbo.helpers.thousandSeparator( vm.totalToInvoicingExcl() ) );
|
||||
vm.totalToInvoicingIncl( dbo.helpers.thousandSeparator( vm.totalToInvoicingIncl() ) );
|
||||
vm.totalInvoicedOtherYears( dbo.helpers.thousandSeparator( vm.totalInvoicedOtherYears() ) );
|
||||
vm.totalInvoicedThisYear( dbo.helpers.thousandSeparator( vm.totalInvoicedThisYear() ) );
|
||||
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.totalToInvoicingExcl(dbo.helpers.thousandSeparator(vm.totalToInvoicingExcl()))
|
||||
vm.totalToInvoicingIncl(dbo.helpers.thousandSeparator(vm.totalToInvoicingIncl()))
|
||||
vm.totalInvoicedOtherYears(dbo.helpers.thousandSeparator(vm.totalInvoicedOtherYears()))
|
||||
vm.totalInvoicedThisYear(dbo.helpers.thousandSeparator(vm.totalInvoicedThisYear()))
|
||||
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()))
|
||||
},
|
||||
|
||||
setForecastsTotals: function ( data ) {
|
||||
var vm = dbo.invoicereport;
|
||||
setForecastsTotals: function (data) {
|
||||
var vm = dbo.invoicereport
|
||||
|
||||
_.each( data, function ( p ) {
|
||||
vm.forecastThisYear( vm.forecastThisYear() + Number( p.forecastThisYear.replace( '.', '' ) ) );
|
||||
vm.forecastOtherYears( vm.forecastOtherYears() + Number( p.forecastOtherYears.replace( '.', '' ) ) );
|
||||
vm.forecastRemaining( vm.forecastRemaining() + Number( p.forecastRemaining.replace( '.', '' ) ) );
|
||||
} );
|
||||
vm.forecastThisYear( dbo.helpers.thousandSeparator( vm.forecastThisYear() ) );
|
||||
vm.forecastOtherYears( dbo.helpers.thousandSeparator( vm.forecastOtherYears() ) );
|
||||
vm.forecastRemaining( dbo.helpers.thousandSeparator( vm.forecastRemaining() ) );
|
||||
_.each(data, function (p) {
|
||||
vm.forecastThisYear(vm.forecastThisYear() + Number(p.forecastThisYear.replace('.', '')))
|
||||
vm.forecastOtherYears(vm.forecastOtherYears() + Number(p.forecastOtherYears.replace('.', '')))
|
||||
vm.forecastRemaining(vm.forecastRemaining() + Number(p.forecastRemaining.replace('.', '')))
|
||||
})
|
||||
vm.forecastThisYear(dbo.helpers.thousandSeparator(vm.forecastThisYear()))
|
||||
vm.forecastOtherYears(dbo.helpers.thousandSeparator(vm.forecastOtherYears()))
|
||||
vm.forecastRemaining(dbo.helpers.thousandSeparator(vm.forecastRemaining()))
|
||||
},
|
||||
|
||||
setForecastMonthsTotals: function ( data ) {
|
||||
console.log( data );
|
||||
var vm = dbo.invoicereport;
|
||||
setForecastMonthsTotals: function (data) {
|
||||
console.log(data)
|
||||
var vm = dbo.invoicereport
|
||||
|
||||
_.each( data, function ( p ) {
|
||||
_.each( p.forecastMonths(), function ( q ) {
|
||||
vm.forecastMonths( vm.forecastMonths() + q );
|
||||
} );
|
||||
} );
|
||||
_.each(data, function (p) {
|
||||
_.each(p.forecastMonths(), function (q) {
|
||||
vm.forecastMonths(vm.forecastMonths() + q)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
checkYear: function () {
|
||||
var vm = dbo.invoicereport;
|
||||
if ( !Number.isInteger( Number( vm.selectedYear() ) ) ) return vm.validYear( false );
|
||||
if ( Number( vm.selectedYear() ) > 2100 ) return vm.validYear( false );
|
||||
if ( Number( vm.selectedYear() ) < 2000 ) return vm.validYear( false );
|
||||
vm.validYear( true );
|
||||
var vm = dbo.invoicereport
|
||||
if (!Number.isInteger(Number(vm.selectedYear()))) return vm.validYear(false)
|
||||
if (Number(vm.selectedYear()) > 2100) return vm.validYear(false)
|
||||
if (Number(vm.selectedYear()) < 2000) return vm.validYear(false)
|
||||
vm.validYear(true)
|
||||
|
||||
vm.initModule();
|
||||
vm.initModule()
|
||||
},
|
||||
|
||||
setActivetab: function ( page ) {
|
||||
var vm = dbo.invoicereport;
|
||||
setActivetab: function (page) {
|
||||
var vm = dbo.invoicereport
|
||||
|
||||
vm.invoiceTab( page );
|
||||
vm.invoiceTab(page)
|
||||
},
|
||||
|
||||
Monthforecast: function ( data ) {
|
||||
console.log( data );
|
||||
var vm = dbo.invoicereport;
|
||||
var self = this;
|
||||
self.projectnumber = data.projectnumber;
|
||||
self.projectname = data.projectname;
|
||||
self.customer = data.customer;
|
||||
self.needInvoice = data.needInvoice;
|
||||
self.forecastOtherYears = data.forecastOtherYears;
|
||||
self.forecastRemaining = data.forecastRemaining;
|
||||
Monthforecast: function (data) {
|
||||
var vm = dbo.invoicereport
|
||||
var self = this
|
||||
self.projectnumber = data.projectnumber
|
||||
self.projectname = data.projectname
|
||||
self.customer = data.customer
|
||||
self.needInvoice = data.needInvoice
|
||||
self.forecastOtherYears = data.forecastOtherYears
|
||||
self.forecastRemaining = data.forecastRemaining
|
||||
|
||||
self.forecastMonths = ko.observableArray( [] );
|
||||
_.each( data.forecastMonths, function ( p, i ) {
|
||||
self.forecastMonths.push( new vm.ForecastMonth( p ) );
|
||||
_.each( vm.monthTotals(), function ( q ) {
|
||||
if ( q.monthID == (i + 1) ) q.forecastamount( Math.round( Number( q.forecastamount() ) ) + Math.round( Number( p.forecastamount ) ) );
|
||||
} );
|
||||
} );
|
||||
self.forecastMonths = ko.observableArray([])
|
||||
_.each(data.forecastMonths, function (p, i) {
|
||||
self.forecastMonths.push(new vm.ForecastMonth(p))
|
||||
_.each(vm.monthTotals(), function (q) {
|
||||
if (q.monthID == (i + 1)) q.forecastamount(Math.round(Number(q.forecastamount())) + Math.round(Number(p.forecastamount)))
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
ForecastMonth: function ( data ) {
|
||||
this.forecastamount = dbo.helpers.thousandSeparator( Math.round( data.forecastamount ) );
|
||||
ForecastMonth: function (data) {
|
||||
this.forecastamount = dbo.helpers.thousandSeparator(Math.round(data.forecastamount))
|
||||
},
|
||||
|
||||
Monthpayment: function ( data ) {
|
||||
var vm = dbo.invoicereport;
|
||||
var self = this;
|
||||
self.projectname = data.projectname;
|
||||
self.customer = data.customer;
|
||||
self.totalProjectPayments = data.totalProjectPayments;
|
||||
Monthpayment: function (data) {
|
||||
var vm = dbo.invoicereport
|
||||
var self = this
|
||||
self.projectname = data.projectname
|
||||
self.customer = data.customer
|
||||
self.totalProjectPayments = data.totalProjectPayments
|
||||
|
||||
self.paymentMonths = ko.observableArray( [] );
|
||||
_.each( data.monthPayments, function ( p, i ) {
|
||||
self.paymentMonths.push( new vm.PaymentMonth( p ) );
|
||||
_.each( vm.monthPaymentTotals(), function ( q ) {
|
||||
if ( q.monthID == i ) q.paymentamount( Math.round(Number( q.paymentamount()) ) + Math.round(Number( p.paymentamount ) ));
|
||||
} );
|
||||
} );
|
||||
self.paymentMonths = ko.observableArray([])
|
||||
_.each(data.monthPayments, function (p, i) {
|
||||
self.paymentMonths.push(new vm.PaymentMonth(p))
|
||||
_.each(vm.monthPaymentTotals(), function (q) {
|
||||
if (q.monthID == i) q.paymentamount(Math.round(Number(q.paymentamount())) + Math.round(Number(p.paymentamount)))
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
PaymentMonth: function ( data ) {
|
||||
this.paymentamount = dbo.helpers.thousandSeparator( Math.round(data.paymentamount) );
|
||||
PaymentMonth: function (data) {
|
||||
this.paymentamount = dbo.helpers.thousandSeparator(Math.round(data.paymentamount))
|
||||
},
|
||||
|
||||
Invoice : function(data){
|
||||
var vat = Math.round((data.invoiceamount * 21) / 100);
|
||||
var inclVat = vat + Number(data.invoiceamount);
|
||||
this.invoiceamount = dbo.helpers.thousandSeparator(data.invoiceamount)
|
||||
this.vat = dbo.helpers.thousandSeparator(vat)
|
||||
this.inclVat = dbo.helpers.thousandSeparator(inclVat)
|
||||
this.project = data.projectnumber + ' ' + data.projectname
|
||||
this.invoicedate = data.invoicedate
|
||||
this.name = data.name
|
||||
this.invoicenumber = ko.observable(data.invoicenumber)
|
||||
},
|
||||
|
||||
createSpreadsheet: function () {
|
||||
var vm = dbo.invoicereport;
|
||||
var vm = dbo.invoicereport
|
||||
|
||||
var orderDirection = vm.orderDirection ? 'ASC' : 'DESC';
|
||||
var archive = vm.archive() ? 'T' : 'F';
|
||||
var orderDirection = vm.orderDirection ? 'ASC' : 'DESC'
|
||||
var archive = vm.archive() ? 'T' : 'F'
|
||||
|
||||
var url = 'index.php/reports/reportsController/createInvoicesSpreadsheet/' + vm.selectedYear() + '/' + vm.orderType + '/' + orderDirection + '/' + archive;
|
||||
window.open( url, '_blank' );
|
||||
var url = 'index.php/reports/reportsController/createInvoicesSpreadsheet/' + vm.selectedYear() + '/' + vm.orderType + '/' + orderDirection + '/' + archive
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
}
|
||||
|
||||
dbo.invoicereport.init();
|
||||
dbo.invoicereport.init()
|
||||
|
||||
ko.applyBindings(
|
||||
dbo.invoicereport, document.getElementById( "INVOICEREPORT" ) );
|
||||
|
||||
dbo.invoicereport, document.getElementById('INVOICEREPORT'))
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ dbo.reservationsInit = function () {
|
||||
var vm = dbo.reservationsModel;
|
||||
var self = this;
|
||||
|
||||
self.projectnumber = data.projectnumber;
|
||||
self.projectnumber = data.projectnumber + ' ' + data.projectname;
|
||||
self.costs = dbo.helpers.numberWithPoints( data.costs );
|
||||
self.reservation = dbo.helpers.numberWithPoints( data.reservation );
|
||||
self.payed = dbo.helpers.numberWithPoints( data.payed );
|
||||
|
||||
Reference in New Issue
Block a user