Bug 336843 - Attach files to Transactions

Patrick patrick at setsuid.net
Sat Nov 9 09:11:48 EST 2013


John/List,

Indeed, knew it broke backwards compatibility because of the structure
changes. I wasn't aware of the KVP structures. I'll poke around with that
and see if I can change things up to store the URI there.

Got it regarding attaching to bugs, but I was hoping for feedback such as
what you provided first. (I was hoping there was a better way.)

I should have some time off coming up, but probably won't get to it for
several weeks. I'm still going to come up short on the Mac and Win32 code
sections though. I have no ability to compile and test for those
environments.

Regards,
Patrick


On Fri, Nov 8, 2013 at 3:40 PM, John Ralls <jralls at ceridwen.us> wrote:

>
> On Nov 8, 2013, at 11:34 AM, Patrick <patrick at setsuid.net> wrote:
>
> > Hi folks,
> >
> > I've been a gnucash user for several years and have always wanted the
> > ability to attach my scanned invoices or receipts to transactions.
> >
> > Lurking about for some time, I'd been following bug #336843 and several
> > threads of others wanting similar functionality. Rather than wait
> > patiently, I found a few free hours last weekend and decided to attempt
> to
> > implement this myself.
> >
> > Attached you'll find a patch which works adequately for my needs, but I
> > wanted to share with the larger community.
> >
> > Primary functionality:
> > - User selects a file via a dialog, the URI is stored in a new char* in
> > the Transaction structure.
> > - User can similarly launch the associated file via the Transaction menu.
> > (Launches via gtk viewer, so filetypes such as .JPG, .PDF, etc are
> already
> > handled.)
> >
> > The functionality works under Linux with the XML backend, however there
> are
> > a few untested areas and TODOs:
> > - SQL backend (untested), I added a column which of course would cause
> > issues for existing tables.
> > - Code to execute the associate file is modeled after gnc_gnome_help() -
> > which is platform dependent. I have no objective C experience so the Mac
> > functionality is completely not implemented. Windows is untested and
> likely
> > needs a tweak or two.
> > - Lastly, and a minor tweak - I intended to find the menu for the
> > right-click menu on a transaction and add similar menu options to what I
> > added in the Transaction menu.
>
> Add to that that it breaks backwards compatibility for both XML and SQL
> backends. The file would cause errors on any previous version that tried to
> open it. The way we’ve been getting around that for many years is to add
> new data items to the KVP structure associated with each QofInstance. The
> source along with what documentation exists is in
> src/libqof/qof/kvp_frame.[ch]. Since one is unlikely to want to search or
> sort on the image link, that’s probably where the link belongs anyway,
> rather than as a field in the transaction table. Having it in KVP
> simplifies a few other things as well, since you don’t have to add code to
> copy it or test equality; that’s already handled for everything in KVP.
>
> It’s better to attach patches to bugs—especially when the bug already
> exists—than to post them here. They tend to get forgotten about rather
> quickly when they’re here.
>
> Thanks,
> John Ralls


More information about the gnucash-devel mailing list