Invoice report
This commit is contained in:
@@ -13,6 +13,14 @@ dbo.invoiceDataService = {
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
},
|
||||
|
||||
getMonthDetails: function ( year, callback ) {
|
||||
$.getJSON( 'index.php/reports/employeeHoursController/getMonthDetails/' + year )
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -41,12 +41,6 @@ dbo.projectDataService = {
|
||||
} );
|
||||
},
|
||||
|
||||
addProject: function ( callback ) {
|
||||
$.getJSON( 'index.php/projects/projectsController/addProject', function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
},
|
||||
|
||||
createProject: function ( offerID, callback ) {
|
||||
$.getJSON( 'index.php/projects/projectsController/creatProjectFromOffer/' + offerID )
|
||||
.done( function ( data ) {
|
||||
@@ -99,6 +93,20 @@ dbo.projectDataService = {
|
||||
} );
|
||||
},
|
||||
|
||||
saveForecast: function ( submitDATA, callback ) {
|
||||
$.post( 'index.php/projects/projectsController/saveForecast', submitDATA )
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
},
|
||||
|
||||
saveReservation: function ( submitDATA, callback ) {
|
||||
$.post( 'index.php/projects/projectsController/saveReservation', submitDATA )
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
},
|
||||
|
||||
archiveProject: function ( userID, status, callback ) {
|
||||
$.get( 'index.php/projects/projectsController/archiveProject/' + userID + '/' + status )
|
||||
.done( function () {
|
||||
@@ -132,6 +140,20 @@ dbo.projectDataService = {
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
},
|
||||
|
||||
removeForecast: function ( forecastID, callback ) {
|
||||
$.getJSON( 'index.php/projects/projectsController/removeForecast/' + forecastID )
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
},
|
||||
|
||||
removeReservation: function ( reservationID, callback ) {
|
||||
$.getJSON( 'index.php/projects/projectsController/removeReservation/' + reservationID )
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
|
||||
+24
-7
@@ -31,17 +31,34 @@ $( function () {
|
||||
};
|
||||
} );
|
||||
|
||||
function uploadFile(file, foreignID, tablename, callback){
|
||||
function uploadFile( file, foreignID, tablename, callback ) {
|
||||
var url = 'index.php/utils/fileUpload/upload/' + foreignID + '/' + tablename;
|
||||
var xhr = new XMLHttpRequest();
|
||||
var fd = new FormData();
|
||||
xhr.open("POST", url, true);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4 && xhr.status == 200) {
|
||||
xhr.open( "POST", url, true );
|
||||
xhr.onreadystatechange = function () {
|
||||
if ( xhr.readyState == 4 && xhr.status == 200 ) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
fd.append("userfile", file);
|
||||
fd.append( "userfile", file );
|
||||
|
||||
xhr.send( fd );
|
||||
}
|
||||
|
||||
dbo.monthLabels = ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'];
|
||||
|
||||
dbo.currentMonth = (new Date()).getMonth();
|
||||
dbo.monthArray = [];
|
||||
for ( var I = 0; I < 12; I++ ) {
|
||||
dbo.monthArray.push( {monthID: I, month: dbo.monthLabels[I]} );
|
||||
}
|
||||
|
||||
dbo.currentYear = (new Date()).getFullYear();
|
||||
dbo.years = []
|
||||
for ( var I = (dbo.currentYear - 2); I <= dbo.currentYear + 2; I++ ) {
|
||||
dbo.years.push( {year: I} );
|
||||
}
|
||||
|
||||
|
||||
|
||||
xhr.send(fd);
|
||||
}
|
||||
@@ -23,6 +23,8 @@ $( function () {
|
||||
projectcosts : ko.observableArray( [] ),
|
||||
vats : ko.observableArray( [] ),
|
||||
availableEmployees: ko.observableArray( [] ),
|
||||
forecasts : ko.observableArray( [] ),
|
||||
reservations : ko.observableArray( [] ),
|
||||
showProject : ko.observable( false ),
|
||||
projectID : null,
|
||||
callback : null,
|
||||
@@ -37,6 +39,8 @@ $( function () {
|
||||
ownRevenue : ko.observable(),
|
||||
otherRevenue : ko.observable(),
|
||||
projectname : ko.observable(),
|
||||
years : ko.observableArray( dbo.years ),
|
||||
months : ko.observableArray( dbo.monthArray ),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
@@ -119,6 +123,14 @@ $( function () {
|
||||
vm.saveProjecthour( this );
|
||||
},
|
||||
|
||||
setPayment: function ( status ) {
|
||||
var vm = dbo.editProjectModal;
|
||||
|
||||
this.payed( status );
|
||||
|
||||
vm.saveReservation( this );
|
||||
},
|
||||
|
||||
editProjecthour: function () {
|
||||
var self = this;
|
||||
var vm = dbo.editProjectModal;
|
||||
@@ -143,6 +155,30 @@ $( function () {
|
||||
} );
|
||||
},
|
||||
|
||||
editForecast: function () {
|
||||
var self = this;
|
||||
var vm = dbo.editProjectModal;
|
||||
$.each( vm.forecasts(), function ( i, p ) {
|
||||
if ( p.id == self.id ) {
|
||||
p.inEdit( !p.inEdit() );
|
||||
} else {
|
||||
p.inEdit( false );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
editReservation: function () {
|
||||
var self = this;
|
||||
var vm = dbo.editProjectModal;
|
||||
$.each( vm.reservations(), function ( i, p ) {
|
||||
if ( p.id == self.id ) {
|
||||
p.inEdit( !p.inEdit() );
|
||||
} else {
|
||||
p.inEdit( false );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
newOffer: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
var service = dbo.offersService;
|
||||
@@ -244,6 +280,35 @@ $( function () {
|
||||
} );
|
||||
},
|
||||
|
||||
addForecast: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
|
||||
var forecast = {
|
||||
id : 0,
|
||||
project_id : vm.projectID,
|
||||
year : dbo.currentYear,
|
||||
month_id : dbo.currentMonth,
|
||||
forecastamount: 0,
|
||||
inEdit : true
|
||||
};
|
||||
|
||||
vm.forecasts.push( new vm.Forecast( forecast ) );
|
||||
},
|
||||
|
||||
addReservation: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
|
||||
var reservation = {
|
||||
id : 0,
|
||||
project_id : vm.projectID,
|
||||
reservationamount: 0,
|
||||
payed : 'UNPAYED',
|
||||
inEdit : true
|
||||
};
|
||||
|
||||
vm.reservations.push( new vm.Reservation( reservation ) );
|
||||
},
|
||||
|
||||
editProject: function ( projectID, callback ) {
|
||||
var vm = dbo.editProjectModal;
|
||||
|
||||
@@ -394,6 +459,39 @@ $( function () {
|
||||
} );
|
||||
},
|
||||
|
||||
saveForecast: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
var self = this;
|
||||
|
||||
var submitDATA = {
|
||||
id : self.id,
|
||||
project_id : self.project_id,
|
||||
year : self.year(),
|
||||
month_id : self.month_id(),
|
||||
forecastamount: self.forecastamount()
|
||||
}
|
||||
|
||||
dbo.projectDataService.saveForecast( submitDATA, function ( data ) {
|
||||
if ( data.success ) self.id = data.forecastID;
|
||||
} );
|
||||
},
|
||||
|
||||
saveReservation: function ( self = false ) {
|
||||
var vm = dbo.editProjectModal;
|
||||
if ( !self ) self = this;
|
||||
|
||||
var submitDATA = {
|
||||
id : self.id,
|
||||
project_id : self.project_id,
|
||||
payed : self.payed(),
|
||||
reservationamount: self.reservationamount()
|
||||
}
|
||||
|
||||
dbo.projectDataService.saveReservation( submitDATA, function ( data ) {
|
||||
if ( data.success ) self.id = data.reservationID;
|
||||
} );
|
||||
},
|
||||
|
||||
removeProjectemployee: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
var self = this;
|
||||
@@ -510,6 +608,64 @@ $( function () {
|
||||
} );
|
||||
},
|
||||
|
||||
removeForecast: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
var self = this;
|
||||
|
||||
tellMe( {
|
||||
title : 'verwijderen prognose',
|
||||
message : 'weet u zeker dat u deze prognose wilt verwijderen, dit kan niet ongedaan worden gemaakt',
|
||||
notify : true,
|
||||
noText : 'nee verwijder prognose niet',
|
||||
yesText : 'ja verwijder de prognose',
|
||||
modalClass: 'modal-warning'
|
||||
}, function ( response ) {
|
||||
console.log( response );
|
||||
if ( response ) {
|
||||
dbo.projectDataService.removeForecast( self.id, function ( data ) {
|
||||
if ( data.result ) {
|
||||
vm.refreshProject();
|
||||
} else {
|
||||
tellMe( {
|
||||
title : 'fout bij verwijderen prognose',
|
||||
message : 'de prognose kan niet worden verwijderd',
|
||||
modalClass: 'modal-danger'
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
removeReservation: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
var self = this;
|
||||
|
||||
tellMe( {
|
||||
title : 'verwijderen reservering',
|
||||
message : 'weet u zeker dat u deze reservering wilt verwijderen, dit kan niet ongedaan worden gemaakt',
|
||||
notify : true,
|
||||
noText : 'nee verwijder reservering niet',
|
||||
yesText : 'ja verwijder de reservering',
|
||||
modalClass: 'modal-warning'
|
||||
}, function ( response ) {
|
||||
console.log( response );
|
||||
if ( response ) {
|
||||
dbo.projectDataService.removeReservation( self.id, function ( data ) {
|
||||
if ( data.result ) {
|
||||
vm.refreshProject();
|
||||
} else {
|
||||
tellMe( {
|
||||
title : 'fout bij verwijderen reserevring',
|
||||
message : 'de reservering kan niet worden verwijderd',
|
||||
modalClass: 'modal-danger'
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
closeProject: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
|
||||
@@ -577,6 +733,16 @@ $( function () {
|
||||
vm.invoices.push( new vm.Invoice( p ) );
|
||||
} );
|
||||
|
||||
vm.forecasts.removeAll();
|
||||
$.each( data.forecasts, function ( i, p ) {
|
||||
vm.forecasts.push( new vm.Forecast( p ) );
|
||||
} );
|
||||
|
||||
vm.reservations.removeAll();
|
||||
$.each( data.reservations, function ( i, p ) {
|
||||
vm.reservations.push( new vm.Reservation( p ) );
|
||||
} );
|
||||
|
||||
vm.busy = false;
|
||||
|
||||
dbo.charts.drawHoursVsBudget( 340, 230, 'hours-vs-budget' );
|
||||
@@ -692,6 +858,23 @@ $( function () {
|
||||
this.paymentdate = ko.observable( dbo.helpers.mysql2date( data.paymentdate ) );
|
||||
this.paymentamount = ko.observable( data.paymentamount );
|
||||
this.inEdit = ko.observable( inEdit );
|
||||
},
|
||||
|
||||
Forecast: function ( data ) {
|
||||
this.id = data.id;
|
||||
this.project_id = data.project_id;
|
||||
this.year = ko.observable( data.year );
|
||||
this.month_id = ko.observable( data.month_id );
|
||||
this.forecastamount = ko.observable( data.forecastamount );
|
||||
this.inEdit = ko.observable( data.inEdit || false );
|
||||
},
|
||||
|
||||
Reservation: function ( data ) {
|
||||
this.id = data.id;
|
||||
this.project_id = data.project_id;
|
||||
this.reservationamount = ko.observable( data.reservationamount );
|
||||
this.payed = ko.observable( data.payed );
|
||||
this.inEdit = ko.observable( data.inEdit || false );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -704,7 +887,7 @@ $( function () {
|
||||
totalHours += Number( p.hours() );
|
||||
}
|
||||
} );
|
||||
return totalHours.toFixed(2);
|
||||
return totalHours.toFixed( 2 );
|
||||
} );
|
||||
|
||||
dbo.editProjectModal.totalRevenue = ko.pureComputed( function () {
|
||||
|
||||
@@ -195,10 +195,10 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
|
||||
drawCharts: function ( self ) {
|
||||
if ( self.hourView() ) {
|
||||
dbo.charts.drawHoursChart( 'hours-per-month-' + self.slug, self.chartData, dbo.charts.monthLabels, 'uren per maand', '#f28f25' );
|
||||
dbo.charts.drawHoursChart( 'hours-per-month-' + self.slug, self.chartData, dbo.monthLabels, 'uren per maand', '#f28f25' );
|
||||
dbo.charts.drawHoursChart( 'hours-per-project-' + self.slug, self.totalHoursChart, self.projectChart, 'uren per project', '#0daef0' );
|
||||
} else {
|
||||
dbo.charts.drawHoursChart( 'revenue-per-month-' + self.slug, self.chartRevenueData, dbo.charts.monthLabels, 'omzet per maand', '#f28f25' );
|
||||
dbo.charts.drawHoursChart( 'revenue-per-month-' + self.slug, self.chartRevenueData, dbo.monthLabels, 'omzet per maand', '#f28f25' );
|
||||
dbo.charts.drawHoursChart( 'revenue-per-project-' + self.slug, self.totalHoursRevenueChart, self.projectChart, 'omzet per project', '#0daef0' );
|
||||
}
|
||||
},
|
||||
|
||||
@@ -19,6 +19,8 @@ dbo.outgoinginvoicesInit = function () {
|
||||
selectedYear : ko.observable(),
|
||||
selectedMonthID: ko.observable(),
|
||||
projects : ko.observableArray( [] ),
|
||||
invoiceTab : ko.observable( 'invoice' ),
|
||||
months : ko.observableArray( dbo.monthArray ),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
@@ -39,11 +41,16 @@ dbo.outgoinginvoicesInit = function () {
|
||||
} );
|
||||
},
|
||||
|
||||
setActivetab: function ( tab ) {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
|
||||
vm.invoiceTab( tab );
|
||||
},
|
||||
|
||||
initModule: function () {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
|
||||
vm.refreshInvoiceDetails();
|
||||
|
||||
},
|
||||
|
||||
refreshInvoiceDetails: function () {
|
||||
@@ -56,27 +63,55 @@ dbo.outgoinginvoicesInit = function () {
|
||||
_.each( data, function ( p ) {
|
||||
vm.projects.push( new vm.Project( p ) );
|
||||
} );
|
||||
|
||||
} );
|
||||
},
|
||||
|
||||
Project: function ( data ) {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
var self = this;
|
||||
var openstaand = data.revenues - (Number( data.currentyear ) + Number( data.otheryear ));
|
||||
this.projectnumber = data.projectnumber;
|
||||
this.customername = data.customername;
|
||||
this.statusProject = Math.abs( openstaand ) > 2 ? 'OPEN' : 'CLOSED';
|
||||
this.fullname = data.fullname;
|
||||
this.openstaand = dbo.helpers.numberWithPoints(Math.round(openstaand));
|
||||
this.openstaandIncl = dbo.helpers.numberWithPoints(Math.round(openstaand * 1.21));
|
||||
this.invoicedOtherYears = dbo.helpers.numberWithPoints(Math.round(data.otheryear));
|
||||
this.invoicedCurentYear = dbo.helpers.numberWithPoints(Math.round(data.currentyear));
|
||||
this.totalInvoiced = dbo.helpers.numberWithPoints(Math.round(data.currentyear) + Math.round(data.otheryear));
|
||||
this.invoicedOtherYearsPayed = dbo.helpers.numberWithPoints(Math.round(data.otheryearpayed));
|
||||
this.invoicedCurentYearPayed = dbo.helpers.numberWithPoints(Math.round(data.currentyearpayed));
|
||||
this.totalInvoicedPayed = dbo.helpers.numberWithPoints(Math.round(data.currentyearpayed) + Math.round(data.otheryearpayed));
|
||||
var totalInvoice = data.revenues * (1 + (data.vatrate / 100));
|
||||
var totalInvoiced = Math.round( data.currentyear ) + Math.round( data.otheryear );
|
||||
var totalInvoicedPayed = Math.round( data.currentyearpayed ) + Math.round( data.otheryearpayed );
|
||||
var notPayed = totalInvoiced - totalInvoicedPayed;
|
||||
|
||||
self.projectnumber = data.projectnumber;
|
||||
self.customername = data.customername;
|
||||
self.statusProject = Math.abs( openstaand ) > 2 ? 'OPEN' : 'CLOSED';
|
||||
self.fullname = data.fullname;
|
||||
self.revenues = dbo.helpers.numberWithPoints( data.revenues );
|
||||
self.totalInvoice = dbo.helpers.numberWithPoints( totalInvoice );
|
||||
self.openstaand = dbo.helpers.numberWithPoints( Math.round( openstaand ) );
|
||||
self.openstaandIncl = dbo.helpers.numberWithPoints( Math.round( openstaand * 1.21 ) );
|
||||
self.invoicedOtherYears = dbo.helpers.numberWithPoints( Math.round( data.otheryear ) );
|
||||
self.invoicedCurentYear = dbo.helpers.numberWithPoints( Math.round( data.currentyear ) );
|
||||
self.totalInvoiced = dbo.helpers.numberWithPoints( totalInvoiced );
|
||||
self.invoicedOtherYearsPayed = dbo.helpers.numberWithPoints( Math.round( data.otheryearpayed ) );
|
||||
self.invoicedCurentYearPayed = dbo.helpers.numberWithPoints( Math.round( data.currentyearpayed ) );
|
||||
self.totalInvoicedPayed = dbo.helpers.numberWithPoints( totalInvoicedPayed );
|
||||
self.notPayed = dbo.helpers.numberWithPoints( notPayed );
|
||||
self.toInvoice = dbo.helpers.numberWithPoints( totalInvoice - totalInvoiced );
|
||||
self.currentforecast = dbo.helpers.numberWithPoints( data.currentforecast );
|
||||
self.otherforecast = dbo.helpers.numberWithPoints( data.otherforecast );
|
||||
self.missingForecast =
|
||||
dbo.helpers.numberWithPoints( totalInvoice - totalInvoiced - data.otherforecast );
|
||||
|
||||
self.months = ko.observableArray( [] );
|
||||
_.each( data.months, function ( p ) {
|
||||
self.months.push( new vm.Month( p ) );
|
||||
|
||||
if ( !vm['forecast' + p.month] ) vm['forecast' + p.month] = ko.observable( 0 );
|
||||
vm['forecast' + p.month]( Number( vm['forecast' + p.month]() ) + Number( p.forecastamount ) );
|
||||
|
||||
if ( !vm['payment' + p.month] ) vm['payment' + p.month] = ko.observable( 0 );
|
||||
vm['payment' + p.month]( Number( vm['payment' + p.month]() ) + Number( p.paymentamount ) );
|
||||
} );
|
||||
},
|
||||
|
||||
Month: function ( data ) {
|
||||
this.forecastamount = dbo.helpers.numberWithPoints( Number( data.forecastamount ).toFixed( 0 ) );
|
||||
this.paymentamount = dbo.helpers.numberWithPoints( Number( data.paymentamount ).toFixed( 0 ) );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
dbo.outgoinginvoicesModel.init();
|
||||
|
||||
@@ -9,7 +9,6 @@ dbo.charts = {
|
||||
|
||||
pieColors : ['#ffcf30', '#06b2dc', '#048a44', '#a63305', '#a0c03b', '#ffcb22', '#89c540', '#f77c01', '#1094f6', '#6733ba'],
|
||||
barColor : ['#f3a921', '#f2770c', '#72221a', '#04843b', '#d63f2e', '#fec220'],
|
||||
monthLabels: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
|
||||
charts : [],
|
||||
|
||||
drawHoursVsBudget: function ( hours, budget, element ) {
|
||||
|
||||
Reference in New Issue
Block a user