DBEasy’s EASY_OUT_CUSTOM

Although I felt comfortable with the previous version of DBEasy [Wood and Wind Computing, RR3 Box 92, Cornish, NH 03745], my implementation of the “easy_out_cus(tom)” procedure was to mimic the address label for printing disk labels with lines of BOLD or italics output on different lines. In retrospect, I clearly did not have a full appreciation of the power of generating a custom output using the relational capabilities of the Archive database program.

A few years ago when someone asked me if there was an easy to use program which could generate a simple, monthly invoice I thought DBEasy might be a good foundation for an alternative to accounting software. As the Fates would have it, in the few days that transpired between the original query and developing the prototype, I learned the need no longer existed.

The experience was not a lost effort — at least, that’s what I tell myself! After all, there were some programming routines which I “worked out” (surely, others have done the same elsewhere) that I would not have bothered to attempt otherwise. A “refined” version of that code is included in the following LISTing.

The standard DBEasy screen layout was used with the following sample labels and user input. Compare the final, generated output with the following record’s data.

Using : INVOICE..DBF           Order : Natural
Date  : 94/01/05               Keys  : TxWA1001-5
      ACCT. NAME      Wayne's Auto
      ADDRESS         84 Granny Smith Road
      more address
      city            Pie Town
      state           NM
      zip             87379
      description1    6 spark plugs
      description2    5 qt. oil 30wt
      dateRECEIVED
      Monthly FEE     5          itemized 1   5.88
      PreviousDUE     17.33      itemized 2   6.45
                      0                       0

In the following procedure, the “payment due” date isautomatically calculated to be the 30th day of the subsequent month that the invoice is generated, with February’s date adjusted to the “28th” of the month. Also, an adjustment to the next year is made if the invoice is generated in December.

proc easy_out_cus
rem /* use for invoicing */
let day_due=30
let month_due=val(today$(1 to 2))+1
let year_due=val(today$(9 to 10))
if month_due=13: let month_due=1: endif
if month_due=1: let year_due=year_due+1: endif
if month_due=2: let day_due=28: endif
lprint

The fonts defined are for a 9-pin, EPSON compatible printer. Of course, you will want to substitute the appropriate control codes for your printer. If you have a color printer, you can define the various colors as similar $trings. And similarly, you can define actual typefaces and scales, too.

rem /*  FX-80 printer control codes  */
let bold$=chr(0)+chr(27)+chr(69)
let bold_off$=chr(0)+chr(27)+chr(70)
let ital$=chr(0)+chr(27)+chr(52)
let ital_off$=chr(0)+chr(27)+chr(53)
let ff$=chr(0)+chr(12)

If you are a vendor, you will need to calculate the tax. The “rate” (0.675) is New Mexico’s previous rate in effect when this procedure was written.

rem /*  tax rate */
let rate=0.0675
let Inpt3$=str(n1_+n2_+n4_+n5_,0,2)
let tax$=str((n1_+n4_+n5_)*rate,0,2)
let total=val(Inpt3$)+val(tax$)

Of course, how your actual output looks depends on the information you want to include. Regardless, note how the printer’s fonts are turned on and off.

rem /*  this is your header  */
lprint
lprint tab 32;bold$;"PLATYPUS Software"
lprint tab 29;bold_off$;"914 Rio Vista Circle SW"
lprint tab 30;"Albuquerque, NM 87105"
lprint tab 35;ital$;"505 843-8414"
lprint ital_off$
rem /* line spaces vary with your header */
rem /* adjust accordingly if using letterhead */
lprint
rem /* the following is account information */
lprint tab 10;"Account Number: ";key_$; tab 48;
"Current Balance: $ ";total
lprint
rem /* parameters for this are modified above */
lprint tab 10;"Payment due by: ";month_due; "/" ;
day_due; "/" ;year_due; tab 48;
"Amount Enclosed: $ ______"
lprint : lprint
rem /* account address set for window envelope */
lprint
let i$=s1_$: if s2_$<>"": let i$=s2_$+" "+s1_$: endif
lprint tab 10;i$
lprint tab 10;s3_$
if s4_$<>"": lprint tab 10;s4_$: endif lprint tab
10;s5_$;", ";s6_$;" ";s7_$ lprint : lprint : lprint
lprint "================[ Please return above
portion with your payment ]================"
rem /* customer retains this part */
lprint : lprint : lprint
lprint tab 10;" Account Number: ";key_$; tab 50;
"Billing date: ";today$(1 to 6); today$(9 to 10)
lprint
lprint tab 10;"Your check number: __________";
tab 50;" Payment due: "; month_due; "/" ;
day_due; "/" ;year_due
lprint : lprint : lprint
lprint tab 10;i$
lprint tab 10;s3_$
if s4_$<>"": lprint tab 10;s4_$: endif
lprint tab10;s5_$;", ";s6_$;" ";s7_$
lprint : lprint

The following method for aligning the two-place decimal output in column may not be the most compact or elegant sequence; but, it works. Since the working example does not utilize numerical fields “n3_” and “n6_” you should note that there is no corresponding “AddOn3” or “AddOn6” value.

rem /*  to ensure two-place decimal output ...  */
let Inpt1$=str(n1_,0,2)
let Inpt2$=str(n2_,0,2)
let Inpt4$=str(n4_,0,2)
let Inpt5$=str(n5_,0,2)
let Ln1=len(Inpt1$): let Ln2=len(Inpt2$):
let Ln3=len(Inpt3$)
let Ln4=len(Inpt4$): let Ln5=len(Inpt5$):
let LnT=len(tax$)
let AddOn1=Ln3-Ln1
let AddOn2=Ln3-Ln2
let AddOn4=Ln3-Ln4
let AddOn5=Ln3-Ln5
let AddOnT=Ln3-LnT
let Blank$=" ": rem 8 spaces
if AddOn1<1: let AddOn1$="": endif
if AddOn2<1: let AddOn2$="": endif
if AddOn4<1: let Addon4$="": endif
if AddOn5<1: let AddOn5$="": endif
if AddOnT<1: let AddOnT$="": endif
if AddOn1>=1: let AddOn1$=Blank$(1 to AddOn1): endif
if AddOn2>=1: let AddOn2$=Blank$(1 to AddOn2): endif
if AddOn4>=1: let AddOn4$=Blank$(1 to AddOn4): endif
if AddOn5>=1: let AddOn5$=Blank$(1 to AddOn5): endif
if AddOnT>=1: let AddonT$=Blank$(1 to AddOnT): endif
lprint tab 44;" Previous balance: $ ";
AddOn2$;Inpt2$
lprint
lprint tab 10;"> ";s8_$; tab 65;" $ "; AddOn4$;Inpt4$
lprint tab 10;"> ";s9_$; tab 65;" $ "; AddOn5$;Inpt5$
lprint
lprint tab 44;"Monthly service fee: $ ";
AddOn1$;Inpt1$
lprint
lprint tab 54;"sales tax: $ ";AddOnT$;Tax$
lprint tab 65;" --------"
lprint tab 44;"Current balance DUE: $ ";total
lprint : lprint : lprint : lprint

If you are re-creating an invoice similar to this one, you will probably want to “end” the invoice by repeating the information contained in your header. In this example, the information is put in a single line.

lprint tab 27;ital$;"Thank you for your patronage";
ital_off$
lprint : lprint : lprint : lprint : lprint :
lprint : lprint
lprint bold$;" PLATYPUS Software";bold_off$;
" 914 Rio Vista Cir. SW, Albuquerque, NM
87105"; ital$;"505 843-8414";ital_off$
lprint ff$ : rem formfeed
endproc

Although the “invoice” example given is not a standalone procedure, it can edited exclusive of DBEasy, SAVEd, and then MERGEd with the main program.

While you may not have the need to generate an “invoice” from within DBEasy, I hope the preceding gives you a good idea about how flexible both DBEasy and the Archive programming language can be.

The sample record has “PLATYPUS Software” sourcing spark plugs and oil to “Wayne’s Auto” account. Obviously, the appropriate data will be generated by your real world situation.

HAPPY TRAILS,
AND COMPUTING, TO YOU …

                    PLATYPUS Software
                 914 Rio Vista Circle  SW
                  Albuquerque, NM  87105
                       505 843-8414

Account Number:  TxWA1001-5    Current Balance:  $ 35.83
Payment due by:  4/30/96       Amount Enclosed:  $ ______

Wayne's Auto
84 Granny Smith Road
Pie Town, NM  87379

=====[ Please return above portion with your payment ]=====

 Account Number:  TxWA1001-5      Billing date:  03/19/96
 Your check number:  __________   Payment due:  4/30/96

Wayne's Auto
84 Granny Smith Road
Pie Town, NM  87379
                         Previous balance:  $     17.33
  > 6 spark plugs                           $      5.88
  > 5 qt. oil 30wt                          $      6.45
                      Monthly service fee:  $      5.00
                                Sales tax:  $      1.17
                                            ----------
                      Current balance DUE:  $     35.83

              Thank you for your patronage

     PLATYPUS Software  914 Rio Vista Cir.  SW,
         Albuquerque, NM  87105  505 843-8414