changes
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { Component } from "@odoo/owl";
|
||||
|
||||
export class AgingBucketStrip extends Component {
|
||||
static template = "fusion_accounting_followup.AgingBucketStrip";
|
||||
static props = {
|
||||
aging: { type: Object },
|
||||
};
|
||||
|
||||
bucketWidth(bucket) {
|
||||
const total = this.props.aging.total_amount || 1;
|
||||
return ((bucket.amount / total) * 100).toFixed(2) + "%";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="fusion_accounting_followup.AgingBucketStrip">
|
||||
<div class="mt-2">
|
||||
<div class="fu-aging-strip">
|
||||
<div t-foreach="props.aging.buckets" t-as="b" t-key="b.name"
|
||||
class="bucket" t-att-data-name="b.name"
|
||||
t-att-style="'width: ' + bucketWidth(b)"
|
||||
t-att-title="b.name + ': $' + (b.amount or 0).toFixed(2)"/>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between text-muted" style="font-size: 0.7rem;">
|
||||
<span>Current</span>
|
||||
<span>30</span>
|
||||
<span>60</span>
|
||||
<span>90</span>
|
||||
<span>120+</span>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,10 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { Component } from "@odoo/owl";
|
||||
|
||||
export class AiTextPanel extends Component {
|
||||
static template = "fusion_accounting_followup.AiTextPanel";
|
||||
static props = {
|
||||
text: { type: Object },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="fusion_accounting_followup.AiTextPanel">
|
||||
<div class="fu-ai-text-panel mt-3">
|
||||
<h5>AI-Generated Follow-up Text</h5>
|
||||
<div class="ai-subject">
|
||||
Subject: <t t-esc="props.text.subject"/>
|
||||
</div>
|
||||
<div class="ai-body">
|
||||
<t t-esc="props.text.body"/>
|
||||
</div>
|
||||
<div class="key-points" t-if="props.text.key_points and props.text.key_points.length">
|
||||
<strong>Key points:</strong>
|
||||
<ul>
|
||||
<li t-foreach="props.text.key_points" t-as="point" t-key="point_index">
|
||||
<t t-esc="point"/>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="text-muted mt-2" style="font-size: 0.75rem;">
|
||||
Tone used: <t t-esc="props.text.tone_used or props.text.tone or 'gentle'"/>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,15 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { Component } from "@odoo/owl";
|
||||
|
||||
export class FollowupHistoryTable extends Component {
|
||||
static template = "fusion_accounting_followup.FollowupHistoryTable";
|
||||
static props = {
|
||||
history: { type: Object },
|
||||
};
|
||||
|
||||
formatDate(s) {
|
||||
if (!s) return "";
|
||||
return s.slice(0, 10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="fusion_accounting_followup.FollowupHistoryTable">
|
||||
<div class="mt-4">
|
||||
<h5>Follow-up History (<t t-esc="props.history.count or 0"/>)</h5>
|
||||
<table t-if="props.history.runs and props.history.runs.length" class="fu-history-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Level</th>
|
||||
<th>Tone</th>
|
||||
<th>State</th>
|
||||
<th class="text-end">Overdue</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr t-foreach="props.history.runs" t-as="run" t-key="run.id">
|
||||
<td><t t-esc="formatDate(run.date)"/></td>
|
||||
<td><t t-esc="run.level_name or '-'"/></td>
|
||||
<td><t t-esc="run.tone_used or '-'"/></td>
|
||||
<td><t t-esc="run.state"/></td>
|
||||
<td class="text-end">
|
||||
<t t-if="run.overdue_amount">$<t t-esc="run.overdue_amount.toFixed(2)"/></t>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div t-else="" class="text-muted">No history yet.</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,15 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { Component } from "@odoo/owl";
|
||||
import { RiskBadge } from "../risk_badge/risk_badge";
|
||||
|
||||
export class PartnerCard extends Component {
|
||||
static template = "fusion_accounting_followup.PartnerCard";
|
||||
static props = {
|
||||
partner: { type: Object },
|
||||
selected: { type: Boolean, optional: true },
|
||||
onSelect: { type: Function },
|
||||
formatCurrency: { type: Function },
|
||||
};
|
||||
static components = { RiskBadge };
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="fusion_accounting_followup.PartnerCard">
|
||||
<div class="o_fusion_followup_card"
|
||||
t-att-class="props.selected ? 'selected' : ''"
|
||||
t-on-click="props.onSelect">
|
||||
<div class="o_fusion_followup_card_header">
|
||||
<div class="partner-name"><t t-esc="props.partner.partner_name"/></div>
|
||||
<div>
|
||||
<span class="fu-status-badge" t-att-data-status="props.partner.status">
|
||||
<t t-esc="props.partner.status"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="partner-numbers">
|
||||
<div>
|
||||
<span class="label">Overdue:</span>
|
||||
<span class="value">$<t t-esc="props.formatCurrency(props.partner.overdue_amount)"/></span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="label">Lines:</span>
|
||||
<span class="value"><t t-esc="props.partner.overdue_line_count or 0"/></span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="label">Risk:</span>
|
||||
<RiskBadge band="props.partner.risk_band" score="props.partner.risk_score"/>
|
||||
</div>
|
||||
<div t-if="props.partner.last_level_name">
|
||||
<span class="label">Last:</span>
|
||||
<span class="value"><t t-esc="props.partner.last_level_name"/></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,11 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { Component } from "@odoo/owl";
|
||||
|
||||
export class RiskBadge extends Component {
|
||||
static template = "fusion_accounting_followup.RiskBadge";
|
||||
static props = {
|
||||
band: { type: String, optional: true },
|
||||
score: { type: Number, optional: true },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="fusion_accounting_followup.RiskBadge">
|
||||
<span class="fu-risk-badge" t-att-data-band="props.band || 'low'">
|
||||
<t t-esc="props.band || 'low'"/>
|
||||
<t t-if="props.score !== undefined"> (<t t-esc="props.score"/>)</t>
|
||||
</span>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,19 @@
|
||||
// Fusion follow-up design tokens.
|
||||
// COLOR uses BS5 CSS custom properties (--bs-*) declared inline in
|
||||
// followup.scss so dark mode flips automatically. SCSS vars below are
|
||||
// for spacing/typography only.
|
||||
|
||||
$fu-space-1: 0.25rem;
|
||||
$fu-space-2: 0.5rem;
|
||||
$fu-space-3: 0.75rem;
|
||||
$fu-space-4: 1rem;
|
||||
$fu-space-6: 1.5rem;
|
||||
|
||||
$fu-font-size-xs: 0.75rem;
|
||||
$fu-font-size-sm: 0.875rem;
|
||||
$fu-font-size-base: 1rem;
|
||||
$fu-font-size-lg: 1.125rem;
|
||||
$fu-font-size-xl: 1.25rem;
|
||||
|
||||
$fu-border-radius: 0.375rem;
|
||||
$fu-border-radius-md: 0.5rem;
|
||||
@@ -0,0 +1,244 @@
|
||||
// Variables (spacing/typography) come from _variables.scss via manifest order.
|
||||
// COLOR uses BS5 CSS custom properties so dark mode flips automatically.
|
||||
|
||||
:root {
|
||||
--fusion-fu-accent: #3b82f6;
|
||||
--fusion-fu-accent-bg: rgba(59, 130, 246, 0.10);
|
||||
|
||||
--fusion-fu-status-no-action: #6b7280;
|
||||
--fusion-fu-status-no-action-bg: rgba(107, 114, 128, 0.12);
|
||||
--fusion-fu-status-action-due: #f59e0b;
|
||||
--fusion-fu-status-action-due-bg: rgba(245, 158, 11, 0.14);
|
||||
--fusion-fu-status-paused: #6366f1;
|
||||
--fusion-fu-status-paused-bg: rgba(99, 102, 241, 0.14);
|
||||
--fusion-fu-status-blocked: #ef4444;
|
||||
--fusion-fu-status-blocked-bg: rgba(239, 68, 68, 0.14);
|
||||
--fusion-fu-status-with-credit: #8b5cf6;
|
||||
--fusion-fu-status-with-credit-bg:rgba(139, 92, 246, 0.14);
|
||||
|
||||
--fusion-fu-risk-low: #10b981;
|
||||
--fusion-fu-risk-low-bg: rgba(16, 185, 129, 0.12);
|
||||
--fusion-fu-risk-medium: #f59e0b;
|
||||
--fusion-fu-risk-medium-bg: rgba(245, 158, 11, 0.12);
|
||||
--fusion-fu-risk-high: #ef4444;
|
||||
--fusion-fu-risk-high-bg: rgba(239, 68, 68, 0.12);
|
||||
--fusion-fu-risk-critical: #b91c1c;
|
||||
--fusion-fu-risk-critical-bg:rgba(185, 28, 28, 0.18);
|
||||
|
||||
--fusion-fu-bucket-current: #10b981;
|
||||
--fusion-fu-bucket-1-30: #fbbf24;
|
||||
--fusion-fu-bucket-31-60: #f59e0b;
|
||||
--fusion-fu-bucket-61-90: #ef4444;
|
||||
--fusion-fu-bucket-91-120: #dc2626;
|
||||
--fusion-fu-bucket-120-plus: #7f1d1d;
|
||||
}
|
||||
|
||||
.o_fusion_followup {
|
||||
background: var(--bs-body-bg);
|
||||
color: var(--bs-body-color);
|
||||
min-height: 100vh;
|
||||
|
||||
&_header {
|
||||
background: var(--bs-body-bg);
|
||||
color: var(--bs-emphasis-color);
|
||||
border-bottom: 1px solid var(--bs-border-color);
|
||||
padding: $fu-space-4 $fu-space-6;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
h1 { font-size: $fu-font-size-xl; margin: 0; color: inherit; }
|
||||
|
||||
.summary {
|
||||
display: flex;
|
||||
gap: $fu-space-6;
|
||||
font-size: $fu-font-size-sm;
|
||||
color: var(--bs-secondary-color);
|
||||
|
||||
.summary-value {
|
||||
font-weight: 600;
|
||||
color: var(--bs-emphasis-color);
|
||||
margin-left: $fu-space-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&_card {
|
||||
background: var(--bs-body-bg);
|
||||
color: var(--bs-body-color);
|
||||
border: 1px solid var(--bs-border-color);
|
||||
border-radius: $fu-border-radius-md;
|
||||
padding: $fu-space-4;
|
||||
margin-bottom: $fu-space-3;
|
||||
cursor: pointer;
|
||||
transition: all 200ms ease-in-out;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--fusion-fu-accent);
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&.selected {
|
||||
border-color: var(--fusion-fu-accent);
|
||||
background: var(--fusion-fu-accent-bg);
|
||||
}
|
||||
|
||||
&_header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: $fu-space-2;
|
||||
|
||||
.partner-name {
|
||||
font-weight: 600;
|
||||
font-size: $fu-font-size-base;
|
||||
color: var(--bs-emphasis-color);
|
||||
}
|
||||
}
|
||||
|
||||
.partner-numbers {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: $fu-space-2;
|
||||
font-size: $fu-font-size-sm;
|
||||
color: var(--bs-secondary-color);
|
||||
|
||||
.label { font-weight: 500; margin-right: $fu-space-2; }
|
||||
.value { color: var(--bs-emphasis-color); font-weight: 500; }
|
||||
}
|
||||
}
|
||||
|
||||
.btn_fu {
|
||||
padding: $fu-space-2 $fu-space-4;
|
||||
border-radius: $fu-border-radius;
|
||||
background: var(--bs-body-bg);
|
||||
border: 1px solid var(--bs-border-color);
|
||||
color: var(--bs-body-color);
|
||||
font-size: $fu-font-size-sm;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover { background: var(--bs-tertiary-bg); }
|
||||
&.primary {
|
||||
background: var(--fusion-fu-accent);
|
||||
border-color: var(--fusion-fu-accent);
|
||||
color: #ffffff;
|
||||
&:hover { filter: brightness(0.92); }
|
||||
}
|
||||
&.danger {
|
||||
background: var(--fusion-fu-status-blocked);
|
||||
border-color: var(--fusion-fu-status-blocked);
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fu-status-badge {
|
||||
padding: $fu-space-1 $fu-space-2;
|
||||
border-radius: $fu-border-radius;
|
||||
font-size: $fu-font-size-xs;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
|
||||
&[data-status="no_action"] { background: var(--fusion-fu-status-no-action-bg); color: var(--fusion-fu-status-no-action); }
|
||||
&[data-status="action_due"] { background: var(--fusion-fu-status-action-due-bg); color: var(--fusion-fu-status-action-due); }
|
||||
&[data-status="paused"] { background: var(--fusion-fu-status-paused-bg); color: var(--fusion-fu-status-paused); }
|
||||
&[data-status="blocked"] { background: var(--fusion-fu-status-blocked-bg); color: var(--fusion-fu-status-blocked); }
|
||||
&[data-status="with_credit_team"] { background: var(--fusion-fu-status-with-credit-bg); color: var(--fusion-fu-status-with-credit); }
|
||||
}
|
||||
|
||||
.fu-risk-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: $fu-space-1 $fu-space-2;
|
||||
border-radius: $fu-border-radius;
|
||||
font-weight: 600;
|
||||
font-size: $fu-font-size-xs;
|
||||
|
||||
&[data-band="low"] { background: var(--fusion-fu-risk-low-bg); color: var(--fusion-fu-risk-low); }
|
||||
&[data-band="medium"] { background: var(--fusion-fu-risk-medium-bg); color: var(--fusion-fu-risk-medium); }
|
||||
&[data-band="high"] { background: var(--fusion-fu-risk-high-bg); color: var(--fusion-fu-risk-high); }
|
||||
&[data-band="critical"] { background: var(--fusion-fu-risk-critical-bg); color: var(--fusion-fu-risk-critical); font-weight: 700; }
|
||||
}
|
||||
|
||||
.fu-aging-strip {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
height: 8px;
|
||||
border-radius: $fu-border-radius;
|
||||
overflow: hidden;
|
||||
margin: $fu-space-2 0;
|
||||
|
||||
.bucket {
|
||||
height: 100%;
|
||||
|
||||
&[data-name="current"] { background: var(--fusion-fu-bucket-current); }
|
||||
&[data-name="1_30"] { background: var(--fusion-fu-bucket-1-30); }
|
||||
&[data-name="31_60"] { background: var(--fusion-fu-bucket-31-60); }
|
||||
&[data-name="61_90"] { background: var(--fusion-fu-bucket-61-90); }
|
||||
&[data-name="91_120"] { background: var(--fusion-fu-bucket-91-120); }
|
||||
&[data-name="120_plus"] { background: var(--fusion-fu-bucket-120-plus); }
|
||||
}
|
||||
}
|
||||
|
||||
.fu-ai-text-panel {
|
||||
background: var(--bs-body-bg);
|
||||
color: var(--bs-body-color);
|
||||
border: 1px solid var(--bs-border-color);
|
||||
border-radius: $fu-border-radius-md;
|
||||
padding: $fu-space-4;
|
||||
|
||||
h5 {
|
||||
margin: 0 0 $fu-space-2;
|
||||
font-size: $fu-font-size-base;
|
||||
color: var(--bs-emphasis-color);
|
||||
}
|
||||
|
||||
.ai-subject {
|
||||
font-weight: 600;
|
||||
margin-bottom: $fu-space-2;
|
||||
padding: $fu-space-2;
|
||||
background: var(--fusion-fu-accent-bg);
|
||||
color: var(--bs-body-color);
|
||||
border-radius: $fu-border-radius;
|
||||
}
|
||||
|
||||
.ai-body {
|
||||
white-space: pre-wrap;
|
||||
font-family: monospace;
|
||||
font-size: $fu-font-size-sm;
|
||||
padding: $fu-space-3;
|
||||
background: var(--bs-secondary-bg);
|
||||
color: var(--bs-body-color);
|
||||
border-radius: $fu-border-radius;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.key-points {
|
||||
margin-top: $fu-space-3;
|
||||
font-size: $fu-font-size-sm;
|
||||
color: var(--bs-secondary-color);
|
||||
|
||||
ul { margin: 0; padding-left: $fu-space-4; }
|
||||
}
|
||||
}
|
||||
|
||||
.fu-history-table {
|
||||
width: 100%;
|
||||
font-size: $fu-font-size-sm;
|
||||
color: var(--bs-body-color);
|
||||
|
||||
th {
|
||||
background: var(--bs-tertiary-bg);
|
||||
padding: $fu-space-2 $fu-space-3;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
color: var(--bs-secondary-color);
|
||||
}
|
||||
|
||||
td {
|
||||
padding: $fu-space-2 $fu-space-3;
|
||||
border-bottom: 1px solid var(--bs-border-color);
|
||||
color: var(--bs-body-color);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
import { reactive } from "@odoo/owl";
|
||||
import { rpc } from "@web/core/network/rpc";
|
||||
|
||||
const ENDPOINT_BASE = "/fusion/followup";
|
||||
|
||||
export class FollowupService {
|
||||
constructor(env, services) {
|
||||
this.env = env;
|
||||
// V19: rpc is a standalone import, not a service.
|
||||
this.rpc = rpc;
|
||||
this.notification = services.notification;
|
||||
|
||||
this.state = reactive({
|
||||
partners: [],
|
||||
count: 0,
|
||||
total: 0,
|
||||
statusFilter: null,
|
||||
isLoading: false,
|
||||
isProcessing: false,
|
||||
selectedPartnerId: null,
|
||||
selectedDetail: null,
|
||||
companyId: null,
|
||||
limit: 50,
|
||||
offset: 0,
|
||||
generatedText: null,
|
||||
});
|
||||
}
|
||||
|
||||
async loadOverdue(companyId = null) {
|
||||
this.state.companyId = companyId;
|
||||
this.state.isLoading = true;
|
||||
try {
|
||||
const result = await this.rpc(`${ENDPOINT_BASE}/list_overdue`, {
|
||||
status: this.state.statusFilter,
|
||||
limit: this.state.limit,
|
||||
offset: this.state.offset,
|
||||
company_id: companyId,
|
||||
});
|
||||
this.state.partners = result.partners;
|
||||
this.state.count = result.count;
|
||||
this.state.total = result.total;
|
||||
} finally {
|
||||
this.state.isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async selectPartner(partnerId) {
|
||||
this.state.selectedPartnerId = partnerId;
|
||||
this.state.selectedDetail = null;
|
||||
this.state.generatedText = null;
|
||||
try {
|
||||
this.state.selectedDetail = await this.rpc(`${ENDPOINT_BASE}/get_partner_detail`, {
|
||||
partner_id: partnerId,
|
||||
});
|
||||
} catch (err) {
|
||||
this.notification.add(`Failed to load partner detail: ${err.message || err}`, { type: "danger" });
|
||||
}
|
||||
}
|
||||
|
||||
async generateText(partnerId, levelId = null, forceRegenerate = false) {
|
||||
this.state.isProcessing = true;
|
||||
try {
|
||||
this.state.generatedText = await this.rpc(`${ENDPOINT_BASE}/generate_text`, {
|
||||
partner_id: partnerId, level_id: levelId,
|
||||
force_regenerate: forceRegenerate,
|
||||
});
|
||||
return this.state.generatedText;
|
||||
} catch (err) {
|
||||
this.notification.add(`Generate failed: ${err.message || err}`, { type: "danger" });
|
||||
throw err;
|
||||
} finally {
|
||||
this.state.isProcessing = false;
|
||||
}
|
||||
}
|
||||
|
||||
async sendFollowup(partnerId, levelId = null, force = false) {
|
||||
this.state.isProcessing = true;
|
||||
try {
|
||||
const result = await this.rpc(`${ENDPOINT_BASE}/send`, {
|
||||
partner_id: partnerId, level_id: levelId, force: force,
|
||||
});
|
||||
const status = result.status || "unknown";
|
||||
const type = status === "sent" ? "success" : status.startsWith("paused") ? "warning" : "info";
|
||||
this.notification.add(`Send result: ${status}`, { type: type });
|
||||
if (this.state.selectedPartnerId === partnerId) {
|
||||
await this.selectPartner(partnerId);
|
||||
}
|
||||
await this.loadOverdue(this.state.companyId);
|
||||
return result;
|
||||
} catch (err) {
|
||||
this.notification.add(`Send failed: ${err.message || err}`, { type: "danger" });
|
||||
throw err;
|
||||
} finally {
|
||||
this.state.isProcessing = false;
|
||||
}
|
||||
}
|
||||
|
||||
async pausePartner(partnerId, untilDate = null) {
|
||||
try {
|
||||
const result = await this.rpc(`${ENDPOINT_BASE}/pause`, {
|
||||
partner_id: partnerId, until_date: untilDate,
|
||||
});
|
||||
this.notification.add(`Paused until ${result.paused_until}`, { type: "info" });
|
||||
if (this.state.selectedPartnerId === partnerId) {
|
||||
await this.selectPartner(partnerId);
|
||||
}
|
||||
await this.loadOverdue(this.state.companyId);
|
||||
return result;
|
||||
} catch (err) {
|
||||
this.notification.add(`Pause failed: ${err.message || err}`, { type: "danger" });
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async resetPartner(partnerId) {
|
||||
try {
|
||||
const result = await this.rpc(`${ENDPOINT_BASE}/reset`, {
|
||||
partner_id: partnerId,
|
||||
});
|
||||
this.notification.add(`Reset`, { type: "info" });
|
||||
if (this.state.selectedPartnerId === partnerId) {
|
||||
await this.selectPartner(partnerId);
|
||||
}
|
||||
await this.loadOverdue(this.state.companyId);
|
||||
return result;
|
||||
} catch (err) {
|
||||
this.notification.add(`Reset failed: ${err.message || err}`, { type: "danger" });
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
setStatusFilter(status) {
|
||||
this.state.statusFilter = status;
|
||||
this.state.offset = 0;
|
||||
this.loadOverdue(this.state.companyId);
|
||||
}
|
||||
}
|
||||
|
||||
export const followupService = {
|
||||
dependencies: ["notification"],
|
||||
start(env, services) { return new FollowupService(env, services); },
|
||||
};
|
||||
|
||||
registry.category("services").add("fusion_followup", followupService);
|
||||
@@ -0,0 +1,50 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
|
||||
// Tour 1: smoke
|
||||
registry.category("web_tour.tours").add("fusion_followup_smoke", {
|
||||
test: true,
|
||||
url: "/odoo",
|
||||
steps: () => [
|
||||
{ content: "Wait for app", trigger: ".o_navbar" },
|
||||
],
|
||||
});
|
||||
|
||||
// Tour 2: open partners list
|
||||
registry.category("web_tour.tours").add("fusion_followup_partners", {
|
||||
test: true,
|
||||
url: "/odoo/action-fusion_accounting_followup.action_fusion_followup_partners",
|
||||
steps: () => [
|
||||
{ content: "List view loads", trigger: ".o_list_view, .o_view_nocontent" },
|
||||
],
|
||||
});
|
||||
|
||||
// Tour 3: open levels
|
||||
registry.category("web_tour.tours").add("fusion_followup_levels", {
|
||||
test: true,
|
||||
url: "/odoo/action-fusion_accounting_followup.action_fusion_followup_levels",
|
||||
steps: () => [
|
||||
{ content: "Levels view loads", trigger: ".o_list_view, .o_view_nocontent" },
|
||||
],
|
||||
});
|
||||
|
||||
// Tour 4: history
|
||||
registry.category("web_tour.tours").add("fusion_followup_history", {
|
||||
test: true,
|
||||
url: "/odoo/action-fusion_accounting_followup.action_fusion_followup_runs",
|
||||
steps: () => [
|
||||
{ content: "History view loads", trigger: ".o_list_view, .o_view_nocontent" },
|
||||
],
|
||||
});
|
||||
|
||||
// Tour 5: batch wizard
|
||||
registry.category("web_tour.tours").add("fusion_followup_batch_wizard", {
|
||||
test: true,
|
||||
url: "/odoo/action-fusion_accounting_followup.action_fusion_batch_followup_wizard",
|
||||
steps: () => [
|
||||
{ content: "Wizard form opens", trigger: ".modal-dialog .o_form_view" },
|
||||
{ content: "Scope field exists", trigger: ".modal-dialog [name='scope']" },
|
||||
{ content: "Close wizard", trigger: ".modal-dialog .btn-secondary", run: "click" },
|
||||
],
|
||||
});
|
||||
@@ -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