#!/usr/bin/env node
const axios = require('axios');
async function testBankLeumiQuery() {
const apiKey = '57ade50e-c9a8-49f3-8ce7-28d44536a669:22676:139';
const baseUrl = 'https://api.umbrellacost.io/api/v1';
console.log('Testing Bank Leumi query with correct parameters...');
console.log('Customer Key: 22676');
console.log('Division ID: 139');
console.log('Account ID from logs: 696314371547');
try {
// First authenticate
const authResponse = await axios.post(`${baseUrl}/users/signin`, {
username: 'david+allcloud@umbrellacost.com',
password: 'Dsamsung1!123'
});
const token = authResponse.data.jwtToken;
console.log('\nAuthentication successful');
// Test the invoices/caui endpoint with correct params
const params = {
customer_account_key: '22676',
customer_division_id: '139',
startDate: '2025-08-01',
endDate: '2025-08-31',
periodGranLevel: 'month',
groupBy: 'none',
costType: ['cost', 'discount'],
isUnblended: true,
'excludeFilters[chargetype]': 'Tax' // Exclude tax like in MANUAL_ANSWERS
};
console.log('\nTesting /invoices/caui with params:', JSON.stringify(params, null, 2));
const response = await axios.get(`${baseUrl}/invoices/caui`, {
params,
headers: {
'apikey': apiKey,
'Authorization': token
}
});
console.log('\nResponse:', JSON.stringify(response.data, null, 2));
// Check if we got the expected data
if (response.data && response.data.length > 0) {
const augustData = response.data[0];
console.log('\n✅ August 2025 cost for Bank Leumi:', augustData.total_cost);
console.log('Expected: ~0.00268');
console.log('Match:', Math.abs(augustData.total_cost - 0.00268) < 0.0001 ? '✅ YES' : '❌ NO');
}
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
testBankLeumiQuery();