CREATE UNIQUE INDEX unique_entry_per_day ON fidelity (user_id, entry_date);


SELECT COUNT(*) FROM entries WHERE user_id = ? AND DATE(entry_date) = CURDATE();

//Calcs
aTot - all total in out of fidelity
bTot - bank
cTot - Credit Card
dtTot - Daughters Total 'dt683', 'dt214',
edTot - education tot 'ed5318', 'ed5319', 'ed5320', 'ed5321', 
fidTot - Total at fidelity?
fidWorth - ??
mTot - Managed Tot 'mi866', 'mi543', 'mt592', 'as551', 
nTot - non-Managed Tot 'at420', 'ai163', 'ar091',
oTot - Other tot not including credit (bTot + dtTot + edTot)
    'fidCurDate', 'fidTot', 'aTot', 'mTot', 'nTot',
    'oTot', 'bTot', 'cTot', 'dTot', 'eTot',
    'at420', 'ai163', 'ar091',
    'mi866', 'mi543', 'mt592', 'as551', 
    'ed5318', 'ed5319', 'ed5320', 'ed5321', 
    'dt683', 'dt214',
    'djiaChange',  'fidComment', ];

// check mtot
SELECT
  fidId,
  mTot AS oMOTOT,
  mi543,mi866,mt592,as551,
  (mi543+mi866+mt592+as551) AS newMtot,
  fidCurDate
FROM fidelity
WHERE mTot > 0 and mTot = (mi543+mi866+mt592+as551);

//check nTot
SELECT fidId, nTot AS oMOTOT,
    (at420+ ai163+ ar091) AS newMtot, fidCurDate
FROM fidelity
WHERE nTot > 0 and nTot = (at420+ ai163+ ar091)
//oTot
SELECT fidId, bTot AS oOTOT, oTot,
ed5318, ed5319, ed5320, ed5321, dt683, dt214,bTot,
    ed5318+ ed5319+ ed5320+ ed5321+ dt683+ dt214+bTot AS newOtot, fidCurDate
FROM fidelity
WHERE bTot > 0;

//where  oTot not correct
SELECT fidId, bTot , oTot,
ed5318, ed5319, ed5320, ed5321, dt683, dt214,bTot,
    ed5318+ ed5319+ ed5320+ ed5321+ dt683+ dt214+bTot AS newOtot, fidCurDate
FROM fidelity
WHERE bTot > 0 
ORDER BY `fidelity`.`ed5318` ASC;
 // dTot
SELECT fidId, dTot, dt683, dt214,
    (dt683 + dt214) AS newdtot, fidCurDate
FROM fidelity
WHERE dTot > 0 and dTot = (dt683 + dt214) 
// Check aTot = mTot + nTot + oTot
SELECT fidId, aTot, bTot, mTot, nTot, (mTot+nTot+oTot+bTot) AS newdtot, fidCurDate FROM fidelity WHERE dTot > 0;


//Check dates and totals
SELECT fidId, fidTot, aTot, bTot, mTot, nTot, DATE(fidCurDate) AS fidDate, DATE_FORMAT(fidCurDate, '%W') AS mDate FROM fidelity where date(fidCurDate) > '2025-06-01' ORDER BY fidId DESC;
