Merge pull request #500 from R0m1k3/1.1

Add TTC amount configuration and display for financial tracking
This commit is contained in:
LogiFlow authored and GitHub committed 2025-11-04 11:35:34 +01:00
commit 9b61a42d8d
4 files changed
+76 -14

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

+17 -1
View File
@@ -50,6 +50,7 @@ export default function Groups() {
invoiceColumnName: "", invoiceColumnName: "",
nocodbBlColumnName: "", nocodbBlColumnName: "",
nocodbAmountColumnName: "", nocodbAmountColumnName: "",
nocodbInvoiceAmountTTCColumnName: "",
nocodbSupplierColumnName: "", nocodbSupplierColumnName: "",
nocodbDueDateColumnName: "", nocodbDueDateColumnName: "",
webhookUrl: "", webhookUrl: "",
@@ -106,6 +107,7 @@ export default function Groups() {
invoiceColumnName: "", invoiceColumnName: "",
nocodbBlColumnName: "", nocodbBlColumnName: "",
nocodbAmountColumnName: "", nocodbAmountColumnName: "",
nocodbInvoiceAmountTTCColumnName: "",
nocodbSupplierColumnName: "", nocodbSupplierColumnName: "",
nocodbDueDateColumnName: "", nocodbDueDateColumnName: "",
webhookUrl: "", webhookUrl: "",
@@ -151,6 +153,7 @@ export default function Groups() {
invoiceColumnName: "", invoiceColumnName: "",
nocodbBlColumnName: "", nocodbBlColumnName: "",
nocodbAmountColumnName: "", nocodbAmountColumnName: "",
nocodbInvoiceAmountTTCColumnName: "",
nocodbSupplierColumnName: "", nocodbSupplierColumnName: "",
nocodbDueDateColumnName: "", nocodbDueDateColumnName: "",
webhookUrl: "", webhookUrl: "",
@@ -259,6 +262,7 @@ export default function Groups() {
invoiceColumnName: "", invoiceColumnName: "",
nocodbBlColumnName: "", nocodbBlColumnName: "",
nocodbAmountColumnName: "", nocodbAmountColumnName: "",
nocodbInvoiceAmountTTCColumnName: "",
nocodbSupplierColumnName: "", nocodbSupplierColumnName: "",
nocodbDueDateColumnName: "", nocodbDueDateColumnName: "",
webhookUrl: "", webhookUrl: "",
@@ -276,6 +280,7 @@ export default function Groups() {
invoiceColumnName: group.invoiceColumnName || "", invoiceColumnName: group.invoiceColumnName || "",
nocodbBlColumnName: group.nocodbBlColumnName || "", nocodbBlColumnName: group.nocodbBlColumnName || "",
nocodbAmountColumnName: group.nocodbAmountColumnName || "", nocodbAmountColumnName: group.nocodbAmountColumnName || "",
nocodbInvoiceAmountTTCColumnName: group.nocodbInvoiceAmountTTCColumnName || "",
nocodbSupplierColumnName: group.nocodbSupplierColumnName || "", nocodbSupplierColumnName: group.nocodbSupplierColumnName || "",
nocodbDueDateColumnName: group.nocodbDueDateColumnName || "", nocodbDueDateColumnName: group.nocodbDueDateColumnName || "",
webhookUrl: group.webhookUrl || "", webhookUrl: group.webhookUrl || "",
@@ -624,7 +629,7 @@ export default function Groups() {
</div> </div>
<div> <div>
<Label htmlFor="nocodbAmountColumnName">Colonne Montant</Label> <Label htmlFor="nocodbAmountColumnName">Colonne Montant HT</Label>
<Input <Input
id="nocodbAmountColumnName" id="nocodbAmountColumnName"
value={formData.nocodbAmountColumnName} value={formData.nocodbAmountColumnName}
@@ -633,6 +638,16 @@ export default function Groups() {
/> />
</div> </div>
<div>
<Label htmlFor="nocodbInvoiceAmountTTCColumnName">Colonne Montant TTC</Label>
<Input
id="nocodbInvoiceAmountTTCColumnName"
value={formData.nocodbInvoiceAmountTTCColumnName}
onChange={(e) => handleChange('nocodbInvoiceAmountTTCColumnName', e.target.value)}
placeholder="ex: Montant_TTC"
/>
</div>
<div> <div>
<Label htmlFor="nocodbSupplierColumnName">Colonne Fournisseur</Label> <Label htmlFor="nocodbSupplierColumnName">Colonne Fournisseur</Label>
<Input <Input
@@ -713,6 +728,7 @@ export default function Groups() {
invoiceColumnName: "", invoiceColumnName: "",
nocodbBlColumnName: "", nocodbBlColumnName: "",
nocodbAmountColumnName: "", nocodbAmountColumnName: "",
nocodbInvoiceAmountTTCColumnName: "",
nocodbSupplierColumnName: "", nocodbSupplierColumnName: "",
nocodbDueDateColumnName: "", nocodbDueDateColumnName: "",
webhookUrl: "", webhookUrl: "",
+58 -13
View File
@@ -18,6 +18,7 @@ interface PaymentSchedule {
invoiceReference: string; invoiceReference: string;
dueDate: string; dueDate: string;
amount: number; amount: number;
amountTTC: number;
supplierName: string; supplierName: string;
paymentMethod: string | null; paymentMethod: string | null;
groupId: number; groupId: number;
@@ -87,12 +88,17 @@ export default function PaymentSchedulePage() {
}); });
}, [data?.schedules, selectedMonth]); }, [data?.schedules, selectedMonth]);
// Calculer le total du mois // Calculer le total du mois (HT)
const monthTotal = useMemo(() => { const monthTotal = useMemo(() => {
return filteredSchedules.reduce((sum, schedule) => sum + schedule.amount, 0); return filteredSchedules.reduce((sum, schedule) => sum + schedule.amount, 0);
}, [filteredSchedules]); }, [filteredSchedules]);
// Grouper par mode de paiement // Calculer le total du mois (TTC)
const monthTotalTTC = useMemo(() => {
return filteredSchedules.reduce((sum, schedule) => sum + schedule.amountTTC, 0);
}, [filteredSchedules]);
// Grouper par mode de paiement (HT)
const paymentMethodTotals = useMemo(() => { const paymentMethodTotals = useMemo(() => {
const totals: Record<string, number> = {}; const totals: Record<string, number> = {};
filteredSchedules.forEach(schedule => { filteredSchedules.forEach(schedule => {
@@ -102,6 +108,16 @@ export default function PaymentSchedulePage() {
return totals; return totals;
}, [filteredSchedules]); }, [filteredSchedules]);
// Grouper par mode de paiement (TTC)
const paymentMethodTotalsTTC = useMemo(() => {
const totals: Record<string, number> = {};
filteredSchedules.forEach(schedule => {
const method = schedule.paymentMethod || 'Non défini';
totals[method] = (totals[method] || 0) + schedule.amountTTC;
});
return totals;
}, [filteredSchedules]);
if (!selectedStoreId) { if (!selectedStoreId) {
return ( return (
<div className="flex-1 flex items-center justify-center"> <div className="flex-1 flex items-center justify-center">
@@ -188,10 +204,21 @@ export default function PaymentSchedulePage() {
<DollarSign className="h-4 w-4 text-muted-foreground" /> <DollarSign className="h-4 w-4 text-muted-foreground" />
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="text-2xl font-bold" data-testid="text-month-total"> <div className="space-y-1">
{monthTotal.toFixed(2)} € <div className="flex justify-between items-baseline">
<span className="text-sm text-gray-600">HT:</span>
<span className="text-xl font-bold" data-testid="text-month-total-ht">
{monthTotal.toFixed(2)} €
</span>
</div>
<div className="flex justify-between items-baseline">
<span className="text-sm text-gray-600">TTC:</span>
<span className="text-xl font-bold text-blue-600" data-testid="text-month-total-ttc">
{monthTotalTTC.toFixed(2)} €
</span>
</div>
</div> </div>
<p className="text-xs text-muted-foreground"> <p className="text-xs text-muted-foreground mt-2">
{filteredSchedules.length} échéance{filteredSchedules.length > 1 ? 's' : ''} {filteredSchedules.length} échéance{filteredSchedules.length > 1 ? 's' : ''}
</p> </p>
</CardContent> </CardContent>
@@ -203,11 +230,20 @@ export default function PaymentSchedulePage() {
<CreditCard className="h-4 w-4 text-muted-foreground" /> <CreditCard className="h-4 w-4 text-muted-foreground" />
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="text-sm space-y-1"> <div className="text-sm space-y-2">
{Object.entries(paymentMethodTotals).map(([method, total]) => ( {Object.entries(paymentMethodTotals).map(([method, totalHT]) => (
<div key={method} className="flex justify-between"> <div key={method} className="border-b pb-2 last:border-b-0">
<span className="text-gray-600">{method}:</span> <div className="font-medium text-gray-700 mb-1">{method}</div>
<span className="font-semibold">{total.toFixed(2)} €</span> <div className="flex justify-between text-xs">
<span className="text-gray-500">HT:</span>
<span className="font-semibold">{totalHT.toFixed(2)} €</span>
</div>
<div className="flex justify-between text-xs">
<span className="text-gray-500">TTC:</span>
<span className="font-semibold text-blue-600">
{paymentMethodTotalsTTC[method]?.toFixed(2) || '0.00'} €
</span>
</div>
</div> </div>
))} ))}
</div> </div>
@@ -272,9 +308,18 @@ export default function PaymentSchedulePage() {
)} )}
</div> </div>
</div> </div>
<div className="text-right"> <div className="text-right space-y-1">
<div className="text-xl font-bold text-blue-600"> <div className="flex items-center gap-2 justify-end">
{schedule.amount.toFixed(2)} € <span className="text-xs text-gray-500">HT:</span>
<span className="text-lg font-semibold">
{schedule.amount.toFixed(2)} €
</span>
</div>
<div className="flex items-center gap-2 justify-end">
<span className="text-xs text-gray-500">TTC:</span>
<span className="text-lg font-bold text-blue-600">
{schedule.amountTTC.toFixed(2)} €
</span>
</div> </div>
</div> </div>
</div> </div>
+1
View File
@@ -445,6 +445,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
invoiceReference: delivery.invoiceReference, invoiceReference: delivery.invoiceReference,
dueDate: delivery.dueDate, dueDate: delivery.dueDate,
amount: delivery.invoiceAmount ? parseFloat(delivery.invoiceAmount) : 0, amount: delivery.invoiceAmount ? parseFloat(delivery.invoiceAmount) : 0,
amountTTC: delivery.invoiceAmountTTC ? parseFloat(delivery.invoiceAmountTTC) : 0,
supplierName: supplier?.name || 'Fournisseur inconnu', supplierName: supplier?.name || 'Fournisseur inconnu',
paymentMethod: supplier?.paymentMethod || null, paymentMethod: supplier?.paymentMethod || null,
groupId: group.id, groupId: group.id,