## #65 Bill Creation: Considering Account Balance

open
nobody
None
5
2012-11-27
2007-04-23
Daniel Lutz
No

If a patient has a positive account, it should be possible to add this amount to a newly created bill, i. e. the user should be asked if he wants to add this amount to the bill as a prepayment or not.

Examples:
- A patient has paid too much for a bill. We should be able to refund this with the next bill.
- A bill has been caceled, but the patient has already paid it. Instead of creating a new bill and manually transfer the paid money, Elexis should just offer to add the amount to the new bill as a prepayment.

I've already started with a little code. But I'm not sure how to calculate the account excess.

- We shouldn't consider open bills.
- We shouldn't consider partly paid bills.
- We shouldn't consider paid bills.

- We should consider bills where the patient paid too much.
- We should consider account transactions that have no relation with bills.

## Discussion

• gweirich
2007-04-23

Logged In: YES
user_id=474050
Originator: NO

process balance
You charge 100.- -> -100
the Patient pays 80.- -> -20.-
you cancel 100.- -> 80.-
you charge 20.- -> 60.-
you charge 200.- -> -140.-
The patient pays 140.- -> 0.-

So, to my opinion, you should consider open and partly paid bills as well
But maybe we should just try oout some calculation models.

• Daniel Lutz
2007-04-23

Logged In: YES
user_id=620838
Originator: YES

First, I tried it this way (taking all transactions into account).
But then I realized that this doesn't work if there are open bills.

process balance account excess
you charge 100 -> -100 0
the patient pays 80 -> -20 0
you cancel 100 -> +80 80

Now the patient has paid 80 too much. Let's call this "account excess".

process balance account excess
you charge 200 -> -160 80 (we don't consider the account excess this time)

Now the patient has a balance of -160, but still an excess of 80, since
this excess hasn't yet bee associated to a bill. In this case, I don't consider
the balance the same as the account excess. If we create another bill,
we may add 80 as prepayment. But to calculate this, we must not consider the
open bill.

Now lets charge 300 and consider the account exccess (300-80=220):

process balance account excess
you charge 220 -> -160 0 (we consider the account excess this time)

Therefore I think we should not consider open and partly paid bills.
(The point is that we need to be able to calculate the account excess from the transactions.)

• Daniel Lutz
2007-04-23

Logged In: YES
user_id=620838
Originator: YES

I just checked in the method Patient.getAccountExcess().
Could you please have a look at it?

I have added a new action in my working copy to call this method for a bill and
add this account excess. So far it works. Do you agree to add this feature?
Then I will check it in, too.

(I haven't yet activated it in Rechnung.build(), since I think the performance of my
implementation is not good enough. We should use a direct SQL statement for this.)

I'm not sure how to name this feature.

- Positives Kontoguthaben

Is this clear enough what it means? (As said, it's not the same as the balance).
(We need to differentiate between the "Kontostand", which may be < 0, and "Guthaben", which is always >= 0.)

• gweirich
2007-04-23

Logged In: YES
user_id=474050
Originator: NO

I'm still not sure why not just use Patient#getKontostand() to check for positive account. But let's try with your version, I don't think that peformance is an issue here, because we only need to calculate one Patient per user action.

The adding of a positive balance can IMO not be done automatically. The bills may have different guarantors, or one may have a special agreement with the patient about how to pay. Thus I'd suggest to extend the context menu in RechnungsListeView with an entry "Guthaben verbuchen" that opens a Dialog that offers the possible positive value and lets the user change it as necessary.

The Name of the feature: Why not just call it "Guthaben"?