Files
Odoo-Modules/fusion_claims/static/src/js/tax_totals_patch.js
2026-02-22 01:22:18 -05:00

31 lines
1.0 KiB
JavaScript

/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { TaxTotalsComponent } from "@account/components/tax_totals/tax_totals";
/**
* Patch TaxTotalsComponent to handle cases where subtotals is undefined
* This fixes the "Invalid loop expression: 'undefined' is not iterable" error
* that occurs when invoices have no tax configuration.
*/
patch(TaxTotalsComponent.prototype, {
formatData(props) {
// Call the original formatData method
super.formatData(props);
// If totals exists but subtotals is undefined, set it to empty array
if (this.totals && this.totals.subtotals === undefined) {
this.totals.subtotals = [];
}
// Also ensure each subtotal has tax_groups array
if (this.totals && this.totals.subtotals) {
for (const subtotal of this.totals.subtotals) {
if (subtotal.tax_groups === undefined) {
subtotal.tax_groups = [];
}
}
}
}
});