feat(fusion_accounting_followup): top-level followup_dashboard component
Made-with: Cursor
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
'name': 'Fusion Accounting Follow-up',
|
||||
'version': '19.0.1.0.20',
|
||||
'version': '19.0.1.0.21',
|
||||
'category': 'Accounting/Accounting',
|
||||
'summary': 'AI-augmented customer follow-ups (dunning) for unpaid invoices.',
|
||||
'description': """
|
||||
@@ -41,6 +41,9 @@ menu hides; the engine + AI tools remain available for the chat.
|
||||
'fusion_accounting_followup/static/src/scss/followup.scss',
|
||||
'fusion_accounting_followup/static/src/scss/dark_mode.scss',
|
||||
'fusion_accounting_followup/static/src/services/followup_service.js',
|
||||
'fusion_accounting_followup/static/src/views/followup_dashboard/followup_dashboard.js',
|
||||
'fusion_accounting_followup/static/src/views/followup_dashboard/followup_dashboard.xml',
|
||||
'fusion_accounting_followup/static/src/views/followup_dashboard/followup_dashboard_view.js',
|
||||
],
|
||||
},
|
||||
'installable': True,
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { Component, useState, onWillStart } from "@odoo/owl";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { PartnerCard } from "../../components/partner_card/partner_card";
|
||||
import { AgingBucketStrip } from "../../components/aging_bucket_strip/aging_bucket_strip";
|
||||
import { RiskBadge } from "../../components/risk_badge/risk_badge";
|
||||
import { AiTextPanel } from "../../components/ai_text_panel/ai_text_panel";
|
||||
import { FollowupHistoryTable } from "../../components/followup_history_table/followup_history_table";
|
||||
|
||||
export class FollowupDashboard extends Component {
|
||||
static template = "fusion_accounting_followup.FollowupDashboard";
|
||||
static props = { "*": true };
|
||||
static components = { PartnerCard, AgingBucketStrip, RiskBadge, AiTextPanel, FollowupHistoryTable };
|
||||
|
||||
setup() {
|
||||
this.followup = useService("fusion_followup");
|
||||
this.state = useState(this.followup.state);
|
||||
|
||||
const companyId = this.env.services.user?.context?.allowed_company_ids?.[0];
|
||||
|
||||
onWillStart(async () => {
|
||||
await this.followup.loadOverdue(companyId);
|
||||
});
|
||||
}
|
||||
|
||||
onSelectPartner(partnerId) {
|
||||
this.followup.selectPartner(partnerId);
|
||||
}
|
||||
|
||||
onStatusFilter(status) {
|
||||
this.followup.setStatusFilter(status || null);
|
||||
}
|
||||
|
||||
async onGenerateText() {
|
||||
if (!this.state.selectedPartnerId) return;
|
||||
await this.followup.generateText(this.state.selectedPartnerId);
|
||||
}
|
||||
|
||||
async onSend() {
|
||||
if (!this.state.selectedPartnerId) return;
|
||||
await this.followup.sendFollowup(this.state.selectedPartnerId, null, true);
|
||||
}
|
||||
|
||||
async onPause() {
|
||||
if (!this.state.selectedPartnerId) return;
|
||||
const days = parseInt(prompt("Pause for how many days?", "30"));
|
||||
if (isNaN(days)) return;
|
||||
const until = new Date();
|
||||
until.setDate(until.getDate() + days);
|
||||
await this.followup.pausePartner(
|
||||
this.state.selectedPartnerId, until.toISOString().slice(0, 10));
|
||||
}
|
||||
|
||||
async onReset() {
|
||||
if (!this.state.selectedPartnerId) return;
|
||||
await this.followup.resetPartner(this.state.selectedPartnerId);
|
||||
}
|
||||
|
||||
formatCurrency(amount) {
|
||||
return new Intl.NumberFormat(undefined, {
|
||||
minimumFractionDigits: 2, maximumFractionDigits: 2,
|
||||
}).format(amount || 0);
|
||||
}
|
||||
|
||||
get totalOverdue() {
|
||||
return this.state.partners.reduce((sum, p) => sum + (p.overdue_amount || 0), 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="fusion_accounting_followup.FollowupDashboard">
|
||||
<div class="o_fusion_followup">
|
||||
<div class="o_fusion_followup_header">
|
||||
<div>
|
||||
<h1>Customer Follow-ups</h1>
|
||||
<div class="text-muted"><t t-esc="state.count"/> of <t t-esc="state.total"/> partners with overdue</div>
|
||||
</div>
|
||||
<div class="summary">
|
||||
<div>Total overdue: <span class="summary-value">$<t t-esc="formatCurrency(totalOverdue)"/></span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex" style="gap: 0.5rem; padding: 0.75rem;">
|
||||
<button class="btn_fu" t-on-click="() => this.onStatusFilter(null)"
|
||||
t-att-class="state.statusFilter === null ? 'primary' : ''">All</button>
|
||||
<button class="btn_fu" t-on-click="() => this.onStatusFilter('action_due')"
|
||||
t-att-class="state.statusFilter === 'action_due' ? 'primary' : ''">Action Due</button>
|
||||
<button class="btn_fu" t-on-click="() => this.onStatusFilter('paused')"
|
||||
t-att-class="state.statusFilter === 'paused' ? 'primary' : ''">Paused</button>
|
||||
<button class="btn_fu" t-on-click="() => this.onStatusFilter('blocked')"
|
||||
t-att-class="state.statusFilter === 'blocked' ? 'primary' : ''">Blocked</button>
|
||||
</div>
|
||||
|
||||
<div class="d-flex" style="gap: 1rem; padding: 1rem;">
|
||||
<div style="flex: 1 1 50%;">
|
||||
<div t-if="state.isLoading" class="text-center p-4 text-muted">Loading...</div>
|
||||
<div t-elif="state.partners.length === 0" class="text-center p-4 text-muted">No overdue partners.</div>
|
||||
<div t-else="">
|
||||
<PartnerCard t-foreach="state.partners" t-as="partner" t-key="partner.partner_id"
|
||||
partner="partner" selected="state.selectedPartnerId === partner.partner_id"
|
||||
onSelect="() => this.onSelectPartner(partner.partner_id)"
|
||||
formatCurrency="formatCurrency.bind(this)"/>
|
||||
</div>
|
||||
</div>
|
||||
<div style="flex: 1 1 50%;">
|
||||
<div t-if="state.selectedDetail">
|
||||
<h3><t t-esc="state.selectedDetail.partner.name"/></h3>
|
||||
<div class="text-muted">
|
||||
<t t-if="state.selectedDetail.partner.email"><t t-esc="state.selectedDetail.partner.email"/></t>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<RiskBadge band="state.selectedDetail.partner.risk_band"
|
||||
score="state.selectedDetail.partner.risk_score"/>
|
||||
</div>
|
||||
<AgingBucketStrip aging="state.selectedDetail.overdue.aging"/>
|
||||
<div class="d-flex mt-3" style="gap: 0.5rem; flex-wrap: wrap;">
|
||||
<button class="btn_fu" t-on-click="onGenerateText">Generate Text</button>
|
||||
<button class="btn_fu primary" t-on-click="onSend">Send Now</button>
|
||||
<button class="btn_fu" t-on-click="onPause">Pause</button>
|
||||
<button class="btn_fu" t-on-click="onReset">Reset</button>
|
||||
</div>
|
||||
<AiTextPanel t-if="state.generatedText" text="state.generatedText"/>
|
||||
<FollowupHistoryTable t-if="state.selectedDetail.history"
|
||||
history="state.selectedDetail.history"/>
|
||||
</div>
|
||||
<div t-else="" class="p-4 text-muted">Select a partner.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,14 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
import { FollowupDashboard } from "./followup_dashboard";
|
||||
|
||||
export const fusionFollowupDashboardView = {
|
||||
type: "fusion_followup",
|
||||
Controller: FollowupDashboard,
|
||||
display_name: "Fusion Customer Follow-ups",
|
||||
icon: "fa-bell",
|
||||
multiRecord: true,
|
||||
};
|
||||
|
||||
registry.category("views").add("fusion_followup", fusionFollowupDashboardView);
|
||||
Reference in New Issue
Block a user