Complete: can invoices be related to activities?

Support for our integrated Contact Manager, Calendar, and Project Tracker.
Posts: 116
Joined: Mon Sep 04, 2006 1:19 pm
PostPosted: Sun Aug 19, 2007 9:26 am
Hi John:

Just started working with SeedCode Complete. In my "doctored" (pun intended) version of SeedCode Calendar, "Contacts" are actually patients in our medical practice, and "Activities" are actually appointments. I'd like to do two things:

    (1) generate an invoice at the time of each appointment, and

    (2) when viewing an appointment, be able to go to the associated invoice with one click.


I think I can achieve (1) simply by adding a button and script that would run from the "MiniWindowEditAppointment" layout. But I'd prefer to have the invoice generated automatically whenever a new activity (appointment) is created. It seems to me that this requires a relationship between invoices (or line items) and activities. Is that correct?

Regarding (2), again, I think that a relationship between invoices (or line items) would do the trick -- but I'm not sure how to set that up. Could you help me out?

Yours,
Jim Recht
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Mon Aug 20, 2007 6:52 pm
Hi Jim,

At the end of the day you'll need to write a script that turns a given appointment into an invoice with one or more invoice lines. Sounds like you know how you'd go about that. Making it "automatic" is just about intercepting one of the appointment creation scripts and attaching your invoice creation script to it.

I imagine this will be easiest if tied to the "continue" button that completes appointment creation; at that time we're more likely to have a patient attached to the appointment than we are at the moment of appointment creation. In this scenario you'd call your invoice creation script from within the $Action = "Continue" branch of our "Edit Appointment - Continue ( Action )" script.

You may want a relationship between the appointment ID and a new field for the appointment ID stored in the invoice or invoice line so that you only make this invoice once for each appointment- not every time someone views the appointment and clicks "continue". (Store the Appointment ID in the invoice line if you want to record multiple appointments on the same invoice.)

This same relationship could be used for item (2), to go to the relevant invoice from the Edit Appointment Mini Window. Check out the script we use when clicking on the arrow pointing to the appointment's contact (the script is "Edit Appointment - Show Contact") for an example of how to manage the open mini window when leaving it for a layout (in this case the invoice layout) in the main file.

Hope that helps.
John Sindelar
SeedCode
Posts: 116
Joined: Mon Sep 04, 2006 1:19 pm
PostPosted: Tue Aug 21, 2007 5:36 am
John:

Thanks for this helpful reply. I have a couple of questions about your third paragraph...

You may want a relationship between the appointment ID and a new field for the appointment ID stored in the invoice or invoice line so that you only make this invoice once for each appointment- not every time someone views the appointment and clicks "continue". (Store the Appointment ID in the invoice line if you want to record multiple appointments on the same invoice.)


1) What would be the relationship between the appointment::appointment ID and the invoice::appointmentID (or invoiceline::appointment ID)?

2) How is it that the the creation of this relationship would enable me to "only make this invoice once for each appointment- not every time someone views the appointment and clicks "continue"?

3) If I do make it a relationship with the invoice lines table (I think that's what you mean when you say "store the appointment ID in the invoice line"), will I then have the option of recording multiple appointments (vs. recording a single appointment) on on any given invoice?

Whew. That's a lot of questions! Thanks for bearing with me on this.

Yours,
Jim Recht
Posts: 116
Joined: Mon Sep 04, 2006 1:19 pm
PostPosted: Sat Aug 25, 2007 8:48 am
Hi again John:

Sorry to bother you again about this. I've created a relationship between the appointment ID and a new field for the appointment ID stored in the invoice line (InvoiceLines::InvLineApptID_kf). Now, if I understand you, I want to write a script that will
    (1) begin by checking for the presence of an invoice line for this appointment ID (because I want to avoid making duplicate invoice lines for this appointment), and
    (2) If no such invoice line exists, then go on to create a new invoice line with the current ApptID.


Here's where I'm stuck -- I don't know how to do (1). Can you advise?

Yours,
Jim Recht
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Mon Aug 27, 2007 7:54 am
You'd create a table occurrence for Invoice Lines in the Daily section of the graph and relate it to CalDailyAppointments by ApptID_kprime = InvLineApptID_kf

Then, if this table occurrence were called CalDailyApptInvoiceLines, your script would test for Not isempty ( CalDailyApptInvoiceLines::InvLineApptID_kf ) if that value isn't empty, you already have a related invoice line.

If you'd like to get into the details of this script further, I'd like to suggest we move this to an hour or so of paid support where we can get together on this and coach you through the rest of this script.
John Sindelar
SeedCode
Posts: 36
Joined: Sun May 11, 2008 9:56 am
Location: Bahrain
PostPosted: Fri May 23, 2008 5:21 am
Hi Jim, John
Like you I am using SC Complete for a clinic and like your idea of auto invoicing the appointments. However, I have one question, what happens when an invoice is created automatically for the appointment, but then the appointment is canceled or duplicated. How did you handle that?

regards
Salman Maidan
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Sat May 24, 2008 7:58 am
I'll let Jim chime in on how he plans to handle this, but you have a lot of options depending on how you script it. One possibility is to handle it with an invoice "status" so that an invoice created automatically isn't "sent" or "valid" until its status is changed later- perhaps as part of completing the appointment.

Other than that it is all up to you in how you craft this. You can add invoice creation to the duplicate routine (and/or the repeating events script) or not. And you can decide how you want to control orphaned invoices if you delete an appointment which has an invoice related to it: probably prohibiting deletion if that invoice is "sent". (See "Orphan Control" and the end of this article.
John Sindelar
SeedCode

Return to SeedCode Calendar

Who is online

Users browsing this forum: No registered users and 3 guests

(855) SEEDCODE
[email protected]
Follow us: