00 Add currency conversion utilities and update models for GTQ handling: Introduced currency conversion functions for GTQ and centavos, updated API and database models to handle GTQ amounts directly, and modified API endpoints to streamline deposit and balance summary responses. Adjusted frontend to reflect changes in currency representation, ensuring consistency across the application.

This commit is contained in:
padreug 2025-07-05 23:38:23 +02:00
parent 7b40fcef21
commit aa71321c84
5 changed files with 127 additions and 30 deletions

View file

@ -27,7 +27,7 @@ window.app = Vue.createApp({
depositsTable: {
columns: [
{ name: 'client_id', align: 'left', label: 'Client', field: 'client_id' },
{ name: 'amount', align: 'left', label: 'Amount', field: 'amount' },
{ name: 'amount_gtq', align: 'left', label: 'Amount', field: 'amount_gtq' },
{ name: 'currency', align: 'left', label: 'Currency', field: 'currency' },
{ name: 'status', align: 'left', label: 'Status', field: 'status' },
{ name: 'created_at', align: 'left', label: 'Created', field: 'created_at' },
@ -130,17 +130,15 @@ window.app = Vue.createApp({
///////////////////////////////////////////////////
methods: {
// Utility Methods
// Utility Methods - Simplified since API handles conversion
formatCurrency(amount) {
if (!amount) return 'Q 0.00';
// Convert centavos to GTQ for display
const gtqAmount = amount / 100;
// Amount is already in GTQ from API
return new Intl.NumberFormat('es-GT', {
style: 'currency',
currency: 'GTQ',
}).format(gtqAmount);
}).format(amount);
},
formatDate(dateString) {
@ -281,7 +279,7 @@ window.app = Vue.createApp({
)
return {
...client,
remaining_balance: balance.remaining_balance
remaining_balance: balance.remaining_balance_gtq
}
} catch (error) {
console.error(`Error fetching balance for client ${client.id}:`, error)
@ -305,7 +303,7 @@ window.app = Vue.createApp({
try {
const data = {
client_id: this.quickDepositForm.selectedClient?.value,
amount: Math.round(this.quickDepositForm.amount * 100), // Convert GTQ to centavos
amount_gtq: this.quickDepositForm.amount, // Send GTQ directly - API handles conversion
currency: 'GTQ',
notes: this.quickDepositForm.notes
}
@ -378,7 +376,7 @@ window.app = Vue.createApp({
try {
const data = {
client_id: this.depositFormDialog.data.client_id,
amount: Math.round(this.depositFormDialog.data.amount * 100), // Convert GTQ to centavos
amount_gtq: this.depositFormDialog.data.amount, // Send GTQ directly - API handles conversion
currency: this.depositFormDialog.data.currency,
notes: this.depositFormDialog.data.notes
}