Invoice report

This commit is contained in:
2018-03-07 17:03:45 +01:00
parent f540bab261
commit ad478b02b1
25 changed files with 1006 additions and 125 deletions
+184 -1
View File
@@ -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 () {