Add warmmiete calculation logic and related metadata; implement custom view for warmmiete field

This commit is contained in:
2026-01-23 23:14:31 +01:00
parent ebe8d86732
commit cc142af834
4 changed files with 45 additions and 3 deletions

View File

@@ -0,0 +1,38 @@
define('custom:views/c-vmh-mietverhaeltnis/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;
}
});
});