source: project/gazette/src/issues/ @ 25547

Last change on this file since 25547 was 25547, checked in by Alaric Snell-Pym, 9 years ago

gazette: Split the omelette (insert pun about breaking eggs) between issues 20 and 21, at a suitable point near half-way, with a bit of link text.

File size: 32.9 KB
1((title . "Issue 21")
2 (authors "Andy Bennett")
3 (date . 1321465864))
5== 0. Introduction
7Welcome to the 21st issue of the Chicken Gazette. While the gazette
8was on hiatus the chicken community was definitely not.
10With the stabilisation of Chicken 4.7 well underway since the last
13Some people have also started to set up salmonella farms and C-Keen
14has completed his "Chicken Zoo".
19== 1. Chickens Out & About
21=== Nuremberg (December 2011)
22[[|Christian Kellermann]] wrote
23([[|2011/10/22 17:38Z]]) to
24confirm the planned Chicken Hacking Sprint scheduled for the beginning of December.
26Interested and available Chickenauts will meet in Nuremberg on the weekend of 9th, 10th and 11th
27of December. If you haven't done so already, you can let us know that you will be joining us by
28placing a note at the foot of the [[|wiki page]].
29If you can't attend in person then we'll be keeping an eye on IRC so feel free to book yourself
30a slot in your cave at home and join us throughout the weekend and into the evenings, Central European Time.
32For those of you keeping score, this will bring the total number of Chicken meets this year to
335 (FOSDEM, Cologne, FrOSCon, T-DOSE and Nuremberg).
36=== Cologne (March 2011)
38In March, Chickens met up at the Chaos Computer Club in Cologne, Germany for a Chicken Hacking Weekend. Here's
39[[|Moritz Heidkamp]]'s report on what they got up to.
44=== FrOSCon (August 2011)
45At FrOSCon in August we sported not only a project booth but a presentation room as well so we took the
46opportunity to lay on a couple of talks for the delegates.
48[[|Moritz Heidkamp]] presented
49"[[|An introduction to Lisp]]:
50Why to talk to computers in parentheses" whilst
51[[|Christian Kellermann]] offered
52"[[|A guided tour through the republic of CHICKEN]]:
53get up to speed with the practical scheme implementation".
54[[|Christian]] has been keeping his talk up-to-date and
55you can find the latest version [[|on the wiki]].
57Naturally, there are [[|pictures]].
60=== T-DOSE 2011 (November 2011)
61European Chickens met up at T-DOSE in Eindhoven, The Netherlands on the weekend of the 5th, 6th and 7th of
62November. [[|Peter Bex]] arranged for us to contribute a "Chicken
63Scheme Project Booth" and we subsequently lured a few Dutch hackers into #chicken on IRC.
65[[|Christian Kellermann]] knocked up some impressive demos
66of [[|PONG]] using Chicken's [[|Cairo Egg]].
68[[|Alaric Snell-Pym]] finished off the tests for his
69[[|Ugarit]] backup egg which allowed him to release version 1.0.
71...and [[|Moritz Heidkamp]] started on a replacement for the
72[[|Environments Egg]] as it has unfortunately has been overtaken
73by developments in the Chicken development branch.
75Pictures are up in the [[|usual place]] on the Chicken website.
79== 2. Chicken Talk
81=== R7RS to be dedicated to the memory of John McCarthy
83Matt Welland wrote in with the sad news that the "Father of Lisp", John McCarthy had sadly passed away ([[|2011/10/25 15:59Z]]). [[|John Cowan]], member of the R7RS working group, told us that R7RS,
84the upcoming version of the Scheme standard, would be dedicated to his memory ([[|16:22Z]])
87=== Parallel build patch for Chicken Makefile
89A lively discussion broke out on the [[|Chicken Users mailing list]] regarding
90[[|parallelisation of the Chicken build process]].
92Vitaly Magerya supplied a [[|patch]] (2011/10/06 12:37Z) to fix some problems
93he'd been having with builds failing when specifying the {{-j}} to {{gmake}}.
94[[|Mario Domenech Goulart]] noted that this functionality was already being
95addressed by [[|ticket 526]]
96([[|2011/10/06 12:39Z]]) and Vitaly was keen to see it committed
97soonly as he maintains the FreeBSD port and people had been asking him for parallel builds ([[|2011/10/06 14:24Z]]). Whilst still keen, [[|Mario]] [[|advised caution]] as he wanted to see it proven ([[|2011/10/06 14:40Z]]).
99Vitaly was keen to push things forward ([[|2011/10/06 15:45Z]]) and
100offered continued testing under FreeBSD 8.2-RELEASE on x86_64. He noted that, as far as he could tell, {{gmake check}} passed when using his
101patch, modified with [[|Moritz Wilhelmy's suggestions]]. Moreover, he
102offered to try the patch from [[|ticket 526]] as well.
104[[|Mario]] [[|suggested]]
105that using the [[|ticket 526]] patch was a good idea as it had, as far as he knew, received testing under Linux and MacOSX.
107Toby Thain spoke in favour of the patch, saying that a working parallel build gives confidence that the Makefile is, in fact, correct.
108He offered to test on three platforms, namely Solaris 10 SPARC SMP and both PowerPC and Intel version of MacOSX SMP.
110Vitaly updated the [[|ticket 526]] patch to the then current sources and confirmed that the build worked at {{-j8}}
111and the tests passed in his FreeBSD 8.2-RELEASE, x86_64 environment. He did, however, note that parallelisation does not work for the install phase
112([[|2011/10/08 12:29Z]]).
114Toby Thain reported successful builds on the 64-bit version MacOSX-10.6 as well as MacOSX-10.5 on a dual-processor G5. He noted "{{make -j8}}
115reduces the make step from 3:39 to 0:47 on my 8-core system". Unfortunately {{make check}} did not pass on either system, with or without the patch
116([[|2011/10/12 01:59Z]] &
117[[|2011/10/15 19:53Z]])
119[[|Christian Kellermann]] noted that it might necessary to install the compiled binaries
120([[|2011/10/15 20:07Z]]) however, Toby did not report back as to whether this
121had any effect on the results of the tests.
124=== 64-bit SPARC Build
126Nicolas Pelletier came to the [[|mailing list]]
127unable to build for Solaris 10 running on SPARC64 due to a missing {{apply-hack.S}}
128([[|2011/11/09 11:48Z]]).
130It turned out that there was no SPARC64 support for Chicken at all and [[|John Cowan]]
131came to the rescue ([[|15:36Z]])
132with instructions for how to add it to the supported architectures list and disable the
133apply hack. [[|Christian Kellermann]] chimed in with affirmations
134around the utility of using Chicken without an apply hack ([[|15:54Z]])
136Nicolas struggled with disabling the apply hack ([[|2011/11/10 11:10Z]])
137due to the Two Lies Of The README. Over the course of the next few minutes [[|Christian]]
138and [[|Mario Domenech Goulart]]]
139confirmed that the lies, which related to the way bootstrap compilers are distributed and invoked, had
140already been fixed in the development versions.
142Meanwhile, Toby Thain tried the build on his SPARC64 ([[|12:40Z]])
143and discovered that GNU make 3.82 is required as well as the addition of {{-lrt}} in {{Makefile.solaris}}. Toby's
144build eventually succeeded and appeared to be good, albeit having only used 1 of his 4 CPUs and with a couple of {{make check}} errors.
146Later on the Thursday, [[|Jim Ursetto]] noted ([[|16:47Z]])
147that the [[|parallel build patch]] in
148[[|ticket 526]] still works on Chicken Toby [[|confirmed]]
149that the patch did indeed work on Solaris and build time was reduced to 10 just of his Earth minutes from the original 40.
150Of course, user time across the four CPUs was still in the region of 40 minutes in total. :-)
152To round everything off, Toby offered [[|binary SYSV packages for Solaris 10 on SPARC64]].
153Contact him via the [[|mailing list]] if you're interested.
156=== Static Linking & Standalone Binaries.
158Serg Kozhemyakin [[|asked]] whether it is possible to build static
159binaries after having trouble using the {{-static}} flag to {{csc}}. He also wondered about building standalone binaries for Windows.
160[[|Christian Kellermann]] [[|advised]]
161against static linking as many of the eggs cannot cope with it. He did, however, suggest that the {{-deploy}} option may well solve both
162issues as it ensures that all the DLLs (including the Chicken runtime and other shared objects) are bundled together into a single directory.
165=== Tracing with {{,tr}} moved to an egg
167[[|Mario Domenech Goulart]] [[|helped]]
168Curtis Cooley in his [[|search for the {{,tr}} command]].
169The functionality had been moved from the core into an egg in Chicken 4.3.0.
172=== {{gmake check}} sometimes fails.
174Pekka Niiranen wrote to tell us about
175[[|problems with {{gmake check}} in Chicken 4.7.0-st]]
176on OpenBSD 5.0.
178[[|Jim Ursetto]] [[|said]]
179that one of the failures had been fixed in the stability branch after the Chicken 4.7.0-st release and he filed
180[[|ticket 724]] for the segmentation fault issue.
182[[|Peter Bex]] mentioned that the [[|ticket 724]] segmentation
183fault had also been observed under NetBSD and Arch Linux. He said that "It's known to be broken" but that it is not properly reproducible
184as it only happens some of the time ([[|2011/11/06 09:51|]]).
187== 3. Salmonella and other tests
188Salmonella is Chicken's egg testing framework.
190For some time we have had daily salmonella runs of the master development
191version of Chicken under Linux on x86. Throughout November, MacOSX-x86_64 has also
192been regularly experiencing the runs. [[|Mario Domenech Goulart]] who maintains the testing
193effort at [[]], as well as the [[|Salmonella codebase]]
194itself, is always on the lookout for more feeds. We are aware that testing on
195other platforms is being organised but if you've got a private Salmonella
196running regularly on an interesting operating system or version of Chicken then
197give us a shout and we'll see if we can get it included with the other reports
198on [[]]
200There is also [[|an entirely new version of Salmonella]] over at github so test that too. The new version is more modular -- some features that were previously built in salmonella are now independent eggs (e.g., [[|salmonella-html-report]] and [[|salmonella-feeds]].  There's also a new egg that provides a new feature: [[|salmonella-diff]] which generates HTML output to render differences between two salmonella logs.
202Here's short list of new salmonella features:
204* egg lint mode: salmonella can now easily check for common egg mistakes before the code hits the egg repository.  Just run {{salmonella --this-egg}} from the egg directory
205* a new execution mode that can significantly reduce salmonella execution times.  In this mode, salmonella won't set the temporary egg installation directory empty before installing new eggs.  While this mode won't spot egg dependencies problems, it can drastically effect the execution time
206* a new tool to take advantage of multi-core systems ({{salmonella-epidemy}})
207* a simple text mode log file viewer ({{salmonella-log-viewer}})
208* [[|salmonella-html-report]] generates reverse dependencies graphs.  That can be useful, for
209example, to ilustrate how many eggs depend on a given egg.
212[[|Alaric Snell-Pym]] is one of the people who has been setting up a Chicken testing
213environment. After [[|some discussion]], he chose Chicken 4.5.0 under
214NetBSD ([[|2011/10/06 21:18Z]]). He's been keeping track of all the
215Egg dependencies and plans to publish them as a list of NetBSD pkgsrc packages.
217Thanks to [[|bevuta IT GmbH]], the CHICKEN test
218infrastructure will soon have more machines available to test the
219CHICKEN compiler, tools and eggs.  A new salmonella environment for
220Linux/x86-64 is currently being set up.
222In addition to salmonella, work on the
223[[|Chicken Playground]] project has
224been resumed.  The Chicken Playground project provides environments
225that can be used by tools like {{chroot}} to test CHICKEN tools and
226eggs.  Those environments contain tools and libraries required to
227build and test most eggs.  Currently a Linux/x86 environment is
228available. A Linux/x86-64 environment is under development and should
229be available soon.
231The new test infrastructure, based on new versions of salmonella and
232Chicken Playground and running on new platforms will probably go into
233production during the Nuremberg hackaton.
236== 4. Core Development
240I need some blurb on this from people Who Know.
241I'd like something on the scrutinizer and stability work that's been going on as well as the proposal to bug fix until r7rs
242and then do Chicken 5.0.
247mario, felix, ckeen
248lots of bug fixes, sparc64 support, scrutinizer fixes
250 * On origin/master:
251   * (e1a5437): when conditional branches differ in the number of results, do not merge the results (felix, 2 days ago)
252   * (bae7d92): clustering optimization added (felix, 5 weeks ago)
253   * (b1907c5): use different default stack-sizes on 32/64 bit platforms (felix, 6 days ago)
254   * (986bd3f): disable apply-hack on sparc64 (felix, 6 days ago)
255   * (28a36bf): Remove scripts/make-egg-rss-feed.scm (imported into the chicken-infrastructure repo) (Mario Domenech Goulart, 5 days ago)
256   * (fbeffd1): scripts/tools.scm: needs regex for `string-match' (Mario Domenech Goulart, 5 days ago)
257   * (1fca9c6): use equal? in case MSYSTEM is not defined (makedist.scm) (felix, 6 days ago)
258   * (42a8263): don't remove build-info files on make confclean or it is not possible to build from a tarball without preinstalled chicken (felix, 9 days ago)
259   * (3bb9645): write debugging output for optimizations into generated source file (felix, 3 weeks ago)
260   * (e7fe2fb): allow procedure in operator-position of evaluated list (#705, suggested by John Cowan) (felix, 2 weeks ago)
261   * (e2fb31c): fix subtype check for fixed-size list/vector types in scrutinizer (felix, 10 days ago)
262   * (fd018df): strip std-envs of non-std identifiers, ignore ##sys#macro-environment when evaluating with an explicit environment (felix, 13 days ago)
263   * (fe8f63c): minor change in port-tests.scm to handle case when HOME is not defined (Windows) (felix, 2 weeks ago)
264   * (723a469): cut of union types above a certain length (felix, 2 weeks ago)
265   * (919a7c7): fixes in build + Windows test script, added note to README (thanks to mario) (felix, 2 weeks ago)
266   * (ddb96f9): Also added runtests.bat to manifest. (felix, 3 weeks ago)
267   * (0df9bb8): another trivial fix for making boot-chicken work on cmd.exe (felix, 3 weeks ago)
268   * (cea668f): trivial Windows-related corrections in rules.make, found by Mario - not yet working, though (felix, 3 weeks ago)
269   * (1bc311d): undocumented scrutinize declaration (obsolete), reported by ckeen (felix, 3 weeks ago)
270   * (10494f6): fixed stupid paren-matching error (felix, 3 weeks ago)
271   * (f9a6702): disable debug output in scrutinizer (felix, 5 weeks ago)
272   * (2483f8d): check not necessary for lambda and  warn if using keyword as variable in binding form (felix, 3 weeks ago)
273   * (aa6b2bb): cleaning up uninitialized variables in C_reclaim, add debug output to C_mutate on m-stack resize, grow m-stack at higher rate (felix, 3 weeks ago)
274   * (1e04156): use write-string port-class method (felix, 3 weeks ago)
275   * (59cdaaf): remove obsolete C_h_... allocation functions (pointed out by Joerg Wittenberger) (felix, 3 weeks ago)
276   * (159611d): handle macro-aliases when resolving declared identifier, making sure things are done right inside modules. (felix, 4 weeks ago)
277   * (0cc88a4): removed obsolete file (felix, 4 weeks ago)
278   * (1f56f3a): ##core#type makes subtype-check optional; quit compile when type-mismatches in strict mode (felix, 5 weeks ago)
281== 5. Stability is for Chickens
283[[|Jim Ursetto]] has set up a Chicken Stability Branch
284effort over at [[]]. Jim describes it as "a fork of the Chicken
285Scheme core which backports certain useful bugfixes and minor features from the future to 'stable'
286maintenance versions". Releases for stability/4.7.0 have version numbers like {{4.7.0.x-st}} (for
287example, {{}}). If you're interested in running a stable Chicken in production, we recommend
288that you check out Jim's work.
292== 6. Hatching Farm
294There has been a lot of egg activity over the course of the past few months. I've selected a few,
295focussing on ones that were announced or discussed on the [[|mailing list]].
297TODO: Write about the distributed egg repository
299By far the most notable thing to have happened is the announcment and implementation of the new
300Egg management system.
302* [[|Ivan Raikov]]'s [[|proposal]]
303  to recategorise eggs filed under "Uncategorized or invalid" and "Miscellaneous" was met with enthusiasm with a number of people pitching in to
304  help as well as [[|Peter Bex]] suggesting that the category list be revisited
305  ([[|2011/10/11 08:12Z]]). [[|Peter]]
306  specifically suggested the addition of a "Communication"s category.
308* [[|Thomas Chust]] announced some new eggs: [[|bindings to WebKitGTK+ and JavaScriptCore]], [[|webgate: a tiny (S)CGI application framework]] and a [[|small binding for the BerkelyDB library]]
310* [[|Christian Kellermann]]
311  [[|fixed some bugs]] in the
312  [[|Cairo Egg]] and tagged version 0.1.11.
314* [[|Alan Post]] [[|patched]] the
315  [[|Sandbox Egg]] to bring it up-to-date with API changes in the Chicken core. His patch was duly accepted.
319== 7. Donations
321It's now possible to donate to your favourite scheme (as long as it's Chicken)!
325We've already had two donations since the account opened a month ago so get donating before it fills up! :-)
327Thank you [[|Sven Hartrumpf]] and Ross Lonstein!
330== 8. Omelette Recipes
332This issue's omelette is the second installment of
333[[|Alaric Snell-Pym]]'s
334"financial book-keeping in scheme" series. If you missed the first part,
335check it out [[|here]].
337Now, to make things easy, I parse the ledger by just defining a heap
338of procedures and macros, and then diving into the ledger with
339eval. It's just Scheme code that, as it is executed, builds up the
340data structures. We'll need some helpers to set up third parties
344(define (define-third-party name address group)
345        (let* ((balance-account
346                (make-account
347                 (string-append name ".balance")
348                 'balance
349                 group
350                 #f))
351               (expenses-account
352                (make-account
353                 (string-append name ".expenses")
354                 'delta
355                 'expenses-reclaimed
356                 #f))
357               (third-party
358                (make-third-party
359                 name address balance-account expenses-account)))
360          (account-third-party-set! balance-account third-party)
361          (account-third-party-set! expenses-account third-party)
362          (register-account! balance-account)
363          (register-account! expenses-account)
364          (set! (hash-table-ref *third-parties* name) third-party)))
367Now we can work on a way of representing bills and invoices. A nice
368input syntax would be:
371(define-third-party "clients.widgetcorp" "123 Any Street" 'clients)
372(register-account! (make-account "" 'delta 'income #f))
373(register-account! (make-account "" 'delta 'travel #f))
374(register-account! (make-account "stock.balance" 'balance 'stock #f))
375(register-account! (make-account "cash" 'balance 'cash #f))
376(register-account! (make-account "taxes.vat" 'balance 'vat #f))
378(invoice "INV005" "clients.widgetcorp" (ymd 2011 04 25)
379         (service "" 800 (vat20) "Router setup and installation")
380         (sale "stock.balance" 350 (vat20) "1 of LX300 router, serial number 0343248")
381         (expense (ymd 2011 03 02) "" "cash" 35 () "Travel to site"))
384The idea is that the sales taxes incurred on a line are specified as a
385list after the amount. If there's no taxes due, then we use an empty
386list. Otherwise we have a list of taxes, which are either plain tax
387names (to have the system compute the tax due itself) or two-element
388lists joining a tax name to a precomputed amount (often, when we pass
389on an expense, we know the tax we paid as it's on the receipt, so we
390should use that (even if they made a mistake working it out) rather
391than calculating our own).
393A nice way to implement that might be to make "invoice" a macro that
394absorbs its first three arguments as an invoice code, the name of the
395third party to invoice, and the date; then treats the rest as a body
396to be wrapped in a dynamic environment in which a parameter allows
397{{sale}}, {{expense}}, and {{service}} to add lines to the
398invoice. This is easily arranged:
401(define-record date year month day)
403(define-record invoice
404  name date third-party lines)
406(define (register-line! invoice line)
407  (invoice-lines-set! invoice
408                      (cons line (invoice-lines invoice))))
410;; Compute sales taxes
411(define (compute-tax tax amount)
412  (case tax
413    ((vat20) (* 0.20 amount)) ;; Current UK rate
414    ((vat15) (* 0.15 amount)) ;; Previous UK rate
415    ((vat175) (* 0.175 amount)))) ;; Previous UK rate
417;; Expand a list of taxes, some of which might be bare symbols
418;; naming taxes to work out, or (<tax> <amount>) lists for
419;; ready-computed taxes, into an alist of tax names to tax amounts
420(define (resolve-taxes amount taxes)
421  (map (lambda (tax-desc)
422         (if (list? tax-desc)
423             (cons (car tax-desc) (cadr tax-desc))
424             (cons tax-desc (compute-tax tax-desc amount))))
425       taxes))
427(define-record invoice-service-line
428  income-account amount taxes description)
430(define-syntax service
431  (syntax-rules ()
432    ((service income-account amount taxes description)
433     (register-service! (*current-invoice*) income-account amount 'taxes description))))
435(define (register-service! invoice income-account amount taxes description)
436  (let ((service
437         (make-invoice-service-line
438          (find-account income-account)
439          amount
440          (resolve-taxes amount taxes)
441          description)))
442    (register-line! invoice service)))
444(define-record invoice-sale-line
445  stock-account amount taxes description)
447(define (register-sale! invoice stock-account amount taxes description)
448  (let ((sale
449         (make-invoice-sale-line
450          (find-account stock-account)
451          amount
452          (resolve-taxes amount taxes)
453          description)))
454    (register-line! invoice sale)))
456(define-syntax sale
457  (syntax-rules ()
458    ((sale stock-account amount taxes description)
459     (register-sale! (*current-invoice*) stock-account amount 'taxes description))))
461(define-record invoice-expense-line
462  expense-account payment-account amount taxes description)
464(define (register-expense! invoice date expense-account payment-account amount taxes description)
465  (let ((expense
466         (make-invoice-expense-line
467          (find-account expense-account)
468          (find-account payment-account)
469          amount
470          (resolve-taxes amount taxes)
471          description)))
472    (register-line! invoice expense)))
474(define-syntax expense
475  (syntax-rules ()
476    ((expense (ymd year month day) expense-account payment-account amount taxes description)
477     (register-expense!
478      (*current-invoice*)
479      (make-date year month day)
480      expense-account
481      payment-account
482      amount
483      'taxes
484      description))))
486(define *current-invoice* (make-parameter #f))
487(define *invoices* (make-hash-table))
489(define-syntax invoice
490  (syntax-rules (service sale expense)
491    ((invoice name third-party (ymd year month day) body ...)
492     (let ((inv
493            (make-invoice name
494                          (make-date year month day)
495                          (hash-table-ref *third-parties* third-party)
496                          '())))
497       (parameterize
498        ((*current-invoice* inv))
499        (begin body ...))
500       (set! (hash-table-ref *invoices* name) inv)
501       (generate-invoice-transactions! inv)))))
504We end the expansion of the {{invoice}} macro with a call to
505{{generate-invoice-transactions!}}, which will do the task of creating
506the double-entry transactions for the invoice. Other types of summary
507structure can be added by calling additional generator procedures at
508this point. This is largely a matter of going through the invoice
509lines, handling them on a case-by-case basis to generate lists of
510transaction splits that we can append together to generate the invoice
511transaction. The case of expense lines is interesting, in that an
512extra transaction has to be generated for each expense, to record its
513initial spending, as well as a split to record the expense being
514claimed in the invoice.
516For now, let's just handle one case:
519(define (generate-invoice-transactions! inv)
520  (register-txn! (make-txn
521    (invoice-date inv)
522    (string-append "Invoice " (invoice-name inv) " for "
523                   (third-party-full-name (invoice-third-party inv)))
524    (let ((txn-balance-account
525           (third-party-balance-account
526            (invoice-third-party inv))))
527      (flatten
528       (map
529        (lambda (line)
530          (cond
531           ((invoice-expense-line? line)
532            (list)) ;; FIXME: Not implemented
533           ((invoice-sale-line? line)
534            (list)) ;; FIXME: Not implemented
535           ((invoice-service-line? line)
536            (list
537             (make-txn-split
538              (invoice-service-line-income-account line)
539              (- (invoice-service-line-amount line))
540              (invoice-service-line-description line))
541             (make-tax-splits
542              (invoice-service-line-taxes line)
543              txn-balance-account)
544             (make-txn-split
545              txn-balance-account
546              (invoice-service-line-amount line)
547              #f)))))
548        (invoice-lines inv)))))))
550(define (make-tax-splits taxes txn-balance-account)
551  (map (lambda (tax)
552         (let ((tax-type (car tax))
553               (tax-amount (cdr tax)))
554           (case tax-type
555             ((vat20 vat15 vat175)
556              (list
557               (make-txn-split
558                (find-account "taxes.vat")
559                (- tax-amount)
560                #f)
561               (make-txn-split
562                txn-balance-account
563                tax-amount
564                #f))))))
565       taxes))
568Feeding in the above example invoice, then checking out the resulting
569double-entry transaction list, shows that it worked:
572(hash-table-for-each *txns*
573                     (lambda (date txns)
574                       (for-each
575                        (lambda (txn)
576                          (printf "Date: ~A Desc: ~A\n"
577                                  (txn-date txn)
578                                  (txn-description txn))
579                          (for-each (lambda (split)
580                                      (printf "Acct: ~A Delta: ~A Notes: ~A\n"
581                                              (account-name (txn-split-account split))
582                                              (txn-split-amount split)
583                                              (txn-split-notes split))) (txn-splits txn)))
584                        txns)))
587   date: #<date> Desc: Invoice INV005 for Widget Corp
588   Acct: Delta: -800 Notes: Router setup and installation
589   Acct: taxes.vat Delta: -160.0 Notes: #f
590   Acct: clients.widgetcorp.balance Delta: 160.0 Notes: #f
591   Acct: clients.widgetcorp.balance Delta: 800 Notes: #f
593We've ended up with multiple splits for the same account, as we record
594that both VAT and the money due for the service are to come from the
595client's balance account - and other splits will add plenty more. To
596fix this, we need to write a procedure that canonicalises a list of
597splits, and call that on the splits before calling
598{{make-txn}}. Canonicalisation consists of finding all the splits that
599refer to the same account and have the same notes (be it {{#f}} or a
600string) and merging them into one with the total of the amounts. But
601I'll leave that (along with implementing bills, payments, and some
602actual reports) as an exercise to the reader... It's easy to imagine
603how to generate a VAT report from the list of transactions, by
604filtering them for membership of the required date range and looking
605for splits involving "taxes.vat", or to generate a nicely formatted
606invoice by extracting a single invoice record, or to work out the
607balance of an account at any point in time by adding up all the
608transaction splits that involve it up to that point in time. Also, the
609core engine needs to be wrapped up in a module that only exposes the
610required bindings, and hides internals.
612Having automated one's book-keeping and financial reporting, many
613operations (such as the VAT returns) can be done without involving an
614accountant; in my case, the accountant is only needed to help with the
615annual corporation tax computation and filing of official accounts,
616which requires deep understanding of the UK tax system to do
617everything properly. Having said that, if I studied the system
618properly (and tracked the changes each year), I'm sure I could
619automate that, too...
621== 9. About the Chicken Gazette
623The Gazette is produced occasionally by a volunteer from the Chicken
624community. The latest issue can be found at
625[[]] or you can follow it in your feed
626reader at [[]]. If you'd like to
627write an issue, [[|consult the wiki]]
628for the schedule and instructions!
Note: See TracBrowser for help on using the repository browser.