/////////////////////////////////////////////////////////////////////////////
// This script fixes problems with converted companies that have unreconciled
// bank transactions. The Cleared Flag (TR_CBNKIND) needs to be set to
// 2 (BKIND_NOT_CLEARED) where currently set to 3 (BKIND_NOT_APPLICABLE).
//
// This will assert that the script was written to work for a specific
// application version.  Change the version number accordingly.
//
/////////////////////////////////////////////////////////////////////////////

// This does some version checking
VersionDB "5.00.0";
VersionMod OWPW.EXE "5.0.0";

// Prompt the user to backup or bailout
Ask "Your bank transaction reconciliation flag will be updated. If you have not backed up your company database, you should exit this script. Continue?";


// Fix the Non-Applicable records.
update bktran set TR_CBNKIND=2 where TR_CBNKIND=3;

// Fix the Payroll Reconciliation flags that do not agree
update bktran b,prtran p set b.TR_CBNKIND=(select TR_CBNKIND from PRTRAN p
  where TR_TYPE='EC' and   p.TR_OID = b.TR_REFOID)  
  where b.tr_refoid=p.tr_oid and b.tr_reftype=p.tr_type;

COMMIT;

