Invoicing a Cash Sale

I want to invoice a cash sale, as described on pages 53 - 57 in standard Sales & Receivables user manual (English version). So I created “CASH” customer, set up all properties (payment method etc.). Furthermore I want to create special simple form ONLY for that purpose (invoicing cash sales) so the users need not (and cannot) choose the (other) customer and have to use this one (“CASH” customer). I copied and modified standard form #43 (sales invoice) and saved is as form #51043. As a lookup form for the control “customer no.” I modified form #22 (customer list) with the value of sourcetableview property defined somewhat like SORTING(Name) ORDER(Ascending) WHERE(“Customer no.”=CONST(CASH)). But the user still have to pop up an lookup, “choose” (the only one) customer from the list, close lookup form with OK button and proceed with filling invoice lines (=two mouse clicks that I would like to avoid). So I copied the following code from Buy-from Vendor No. - Onvalidate() trigger (#38 Purchase Header table), and tried to include it in several triggers within the new sales invoice form #51043 (I added also GetVend function and Vend variable to that form): GetVend(“Buy-from Vendor No.”); Vend.TESTFIELD(Blocked,FALSE); Vend.TESTFIELD(“Gen. Bus. Posting Group”); “Buy-from Vendor Name” := Vend.Name; “Buy-from Vendor Name 2” := Vend.“Name 2”; “Buy-from Address” := Vend.Address; “Buy-from Address 2” := Vend.“Address 2”; “Buy-from City” := Vend.City; “Buy-from Post Code” := Vend.“Post Code”; “Buy-from County” := Vend.County; “Buy-from Country Code” := Vend.“Country Code”; “Buy-from Contact” := Vend.Contact; “Gen. Bus. Posting Group” := Vend.“Gen. Bus. Posting Group”; “VAT Bus. Posting Group” := Vend.“VAT Bus. Posting Group”; “Tax Area Code” := Vend.“Tax Area Code”; “Tax Liable” := Vend.“Tax Liable”; “VAT Country Code” := Vend.“Country Code”; “VAT Registration No.” := Vend.“VAT Registration No.”; VALIDATE(“Sell-to Customer No.”,’’); IF Vend.“Pay-to Vendor No.” <> ‘’ THEN VALIDATE(“Pay-to Vendor No.”,Vend.“Pay-to Vendor No.”) ELSE VALIDATE(“Pay-to Vendor No.”,“Buy-from Vendor No.”); However I have not found any trigger which will cause this job to be done automatically. So far the best solution working properly is a CommandButton with that code placed in OnRun(), but it is still silly to click the button every time you use the form, isn’t it. So, which place do you think will be best suitable for my code (i. e. which trigger, codeunit…)? (Once more, I need to fill in automatically Sell-to Customer No. with constant value (‘CASH’) and all corresponding fields, before I post (or, post and print) the invoice). Thank you in advance. karel2 Edited by - karel2 on 12/21/00 11:56:01 AM

Have you considered using OnInsertRecord on Form 51043? This trigger can write to the database, and will be called when you create a new record -before or after the table code, I don’t know. You could set and validate the Customer No. to ‘CASH’ there with no extra clicks required. Regards, Mark Dielmann

What do you do when you get a cash payment from a Customer who is not merely a cash customer— i.e., when you know who did the cash payment? Oner other thing: don’t hardwire the Customer No. ‘CASH’ into your code. Put a flag of some sort on the Customer table, and check it if this particular Customer No. happens correspnd to the ‘CASH’ customer. The advantage of doing this is so you can add multiple ‘CASH’ customers in the future… A simpler way to handle cash sales might be to use the Sales Journal… ------- Tim Horrigan