Tweak to Automatic Transaction Number Feature

Money Manager Ex Development related posts

Moderator: Renato

Post Reply
MMEX Developer
Posts: 112
Joined: Tue Jul 28, 2009 10:34 pm
Are you a spam bot?: No
Location: Atchison, KS

Tweak to Automatic Transaction Number Feature

Post by omalleypat »

I've never really been able to use the automatic transaction number feature (the ... button in the transaction dialog) because of how my bank numbers things. I want to use that button when I am writing checks to automatically put in the next number from my checkbook (for this account that number <1000). My bank uses transaction numbers of >10000 for online bill payments and very large numbers for transfers. Since MMEX just adds 1 to the max transaction number, I get a very large random number plus 1.

I've tweaked the source on my system to the following. When calculating the next transaction number, it will ignore transfers and any transaction number over 10000 when computing the max.

Code: Select all

Index: dbwrapper.cpp
--- dbwrapper.cpp	(revision 2189)
+++ dbwrapper.cpp	(working copy)
@@ -1573,11 +1573,16 @@
 int mmDBWrapper::getTransactionNumber(wxSQLite3Database* db, int accountID)
-    static const char sql[] = 
-    "select ifnull(max(cast(TRANSACTIONNUMBER as integer)),0)+1 as MaxTransID "
-    "where ACCOUNTID = ? ";
+    // BEGIN omalleypat custom mod ---------------------------------------------------
+	//  When automatically getting the next transaction number,
+	//    ignore transfers and any withdrawal with transaction number over 10000
+	static const char sql[] = 
+    "select ifnull(max(tnum),0)+1 as MaxTransID from "
+	"(   select cast(TRANSACTIONNUMBER as integer) as tnum from "
+	"         CHECKINGACCOUNT_V1 where ACCOUNTID = ? AND tnum<10000 AND TRANSCODE = 'Withdrawal'"
+	")";
+	// END omalleypat custom mod ------------------------------------------------------
     int transID = 1;
     wxSQLite3Statement st = db->PrepareStatement(sql);
I'm not checking this into svn because every bank has different requirements, and I don't think we could make something general enough to work for all users, but in case anyone wants to use this mod too, I thought I'd share.

Post Reply