Add RVG calculation module and integrate cost calculations into CVmhErstgespraech entity
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
define('custom:views/c-vmh-erstgespraech/fields/rvg-calculated', [
|
||||
'views/fields/currency',
|
||||
'custom:modules/rvg-calculator'
|
||||
], function (Dep, RvgCalculator) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
this.calculating = false;
|
||||
|
||||
// Listen to changes on relevant fields (combined listener)
|
||||
this.listenTo(this.model, 'change:streitwert change:anzahlVermieter change:anzahlMieter change:anzahlSonstigeVolljhrigeBewohner change:ustSatz', this.calculate.bind(this));
|
||||
|
||||
// Initial calculation
|
||||
this.calculate();
|
||||
},
|
||||
|
||||
calculate: function () {
|
||||
if (this.calculating) return;
|
||||
this.calculating = true;
|
||||
|
||||
var streitwert = parseFloat(this.model.get('streitwert')) || 0;
|
||||
var anzahlKlaeger = parseInt(this.model.get('anzahlVermieter')) || 1;
|
||||
var anzahlMieter = parseInt(this.model.get('anzahlMieter')) || 0;
|
||||
var anzahlSonstige = parseInt(this.model.get('anzahlSonstigeVolljhrigeBewohner')) || 0;
|
||||
var anzahlBeklagte = anzahlMieter + anzahlSonstige;
|
||||
if (anzahlBeklagte < 1) anzahlBeklagte = 1;
|
||||
|
||||
// USt-Satz: "0" oder "19" (String) direkt als Integer
|
||||
var ustSatzString = this.model.get('ustSatz') || '19';
|
||||
var ustSatz = parseInt(ustSatzString);
|
||||
|
||||
var result = RvgCalculator.kalkuliereKosten(streitwert, anzahlKlaeger, anzahlBeklagte, ustSatz);
|
||||
|
||||
// Update all cost fields
|
||||
this.model.set({
|
||||
'aussergerichtlicheGebuehren': result.aussergerichtlichBrutto,
|
||||
'gerichtskosten1Instanz': result.gerichtskosten1Instanz,
|
||||
'anwaltskostenKlaeger1Instanz': result.anwaltskostenKlaeger1InstanzBrutto,
|
||||
'vorzusch1Instanz': result.vorzusch1InstanzBrutto,
|
||||
'vergleich1InstanzGk': result.vergleich1InstanzGk,
|
||||
'vergleich1InstanzAnwK': result.vergleich1InstanzAnwK,
|
||||
'vergleich1InstanzSumme': result.vergleich1InstanzSumme,
|
||||
'saeumnis1InstanzGk': result.saeumnis1InstanzGk,
|
||||
'saeumnis1InstanzAnwK': result.saeumnis1InstanzAnwK,
|
||||
'saeumnis1InstanzSumme': result.saeumnis1InstanzSumme
|
||||
});
|
||||
|
||||
this.calculating = false;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user