Add warmmiete and streitwert calculations; enhance check_and_rebuild script for cache clearing
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
define('custom:views/c-vmh-erstgespraech/fields/streitwert', ['views/fields/currency'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
this.calculating = false;
|
||||
|
||||
// Listen to changes on dependent fields
|
||||
this.listenTo(this.model, 'change:kaltmiete', this.calculate.bind(this));
|
||||
this.listenTo(this.model, 'change:bKPauschale', this.calculate.bind(this));
|
||||
},
|
||||
|
||||
afterRender: function () {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
// Don't calculate on initial render - only on changes
|
||||
},
|
||||
|
||||
calculate: function () {
|
||||
if (this.calculating) return;
|
||||
this.calculating = true;
|
||||
|
||||
var kaltmiete = parseFloat(this.model.get('kaltmiete')) || 0;
|
||||
var bKPauschale = parseFloat(this.model.get('bKPauschale')) || 0;
|
||||
|
||||
var streitwert = (kaltmiete + bKPauschale) * 12;
|
||||
|
||||
// Set value - this will trigger the parent view to update
|
||||
this.model.set('streitwert', streitwert);
|
||||
|
||||
this.calculating = false;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
define('custom:views/c-vmh-erstgespraech/fields/warmmiete', ['views/fields/currency'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
this.calculating = false;
|
||||
|
||||
// Listen to changes on dependent fields
|
||||
this.listenTo(this.model, 'change:kaltmiete', this.calculate.bind(this));
|
||||
this.listenTo(this.model, 'change:bKVorauszahlung', this.calculate.bind(this));
|
||||
this.listenTo(this.model, 'change:bKPauschale', this.calculate.bind(this));
|
||||
},
|
||||
|
||||
afterRender: function () {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
// Don't calculate on initial render - only on changes
|
||||
},
|
||||
|
||||
calculate: function () {
|
||||
if (this.calculating) return;
|
||||
this.calculating = true;
|
||||
|
||||
var kaltmiete = parseFloat(this.model.get('kaltmiete')) || 0;
|
||||
var bKVorauszahlung = parseFloat(this.model.get('bKVorauszahlung')) || 0;
|
||||
var bKPauschale = parseFloat(this.model.get('bKPauschale')) || 0;
|
||||
|
||||
var warmmiete = kaltmiete + bKVorauszahlung + bKPauschale;
|
||||
|
||||
// Set value - this will trigger the parent view to update
|
||||
this.model.set('warmmiete', warmmiete);
|
||||
|
||||
this.calculating = false;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
49
client/custom/src/views/c-vmh-erstgespraech/record/edit.js
Normal file
49
client/custom/src/views/c-vmh-erstgespraech/record/edit.js
Normal file
@@ -0,0 +1,49 @@
|
||||
define('custom:views/c-vmh-erstgespraech/record/edit', ['views/record/edit'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
// Listen for changes on Kaltmiete, BK-Vorauszahlung, and BK-Pauschale
|
||||
this.listenTo(this.model, 'change:kaltmiete change:bKVorauszahlung change:bKPauschale', function () {
|
||||
this.calculateFields();
|
||||
}, this);
|
||||
|
||||
// Initial calculation after fields are ready
|
||||
this.once('after:render', function () {
|
||||
this.calculateFields();
|
||||
}, this);
|
||||
},
|
||||
|
||||
calculateFields: function () {
|
||||
var kaltmiete = parseFloat(this.model.get('kaltmiete')) || 0;
|
||||
var bKVorauszahlung = parseFloat(this.model.get('bKVorauszahlung')) || 0;
|
||||
var bKPauschale = parseFloat(this.model.get('bKPauschale')) || 0;
|
||||
|
||||
// Berechne Warmmiete
|
||||
var warmmiete = kaltmiete + bKVorauszahlung + bKPauschale;
|
||||
this.model.set('warmmiete', warmmiete, {silent: false});
|
||||
|
||||
// Berechne Streitwert
|
||||
var streitwert = (kaltmiete + bKPauschale) * 12;
|
||||
this.model.set('streitwert', streitwert, {silent: false});
|
||||
|
||||
// Force update der View
|
||||
if (this.hasView('warmmiete')) {
|
||||
var warmmieteView = this.getView('warmmiete');
|
||||
if (warmmieteView && warmmieteView.reRender) {
|
||||
warmmieteView.reRender();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.hasView('streitwert')) {
|
||||
var streitwertView = this.getView('streitwert');
|
||||
if (streitwertView && streitwertView.reRender) {
|
||||
streitwertView.reRender();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user