gnumed-bugs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-bugs] GNUmed 1.25 Billing module - Remove button does not re


From: Karsten Hilbert
Subject: Re: [Gnumed-bugs] GNUmed 1.25 Billing module - Remove button does not remove
Date: Sun, 6 Jan 2013 22:12:22 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat, Jan 05, 2013 at 01:49:13AM +0000, Jim Busser wrote:

>> further to the above, when in psql I do
>> 
>>      select * from bill.bill_item where fk_billable = (select pk from 
>> ref.billable where code = '00311') ;
>> 
>> psql returns one row, however even after I do
>> 
>>      set default_transaction_read_only to off;
>> 
>> I cannot successfully delete the above record… when I try
>> 
>>      delete from bill.bill_item where fk_billable = (select pk from 
>> ref.billable where code = '00311') ;
>> 
>> I get
>> 
>>      DELETE 0
>> 
>> ??

That is because

        tr_prevent_empty_bills

works to not let you create empty bills (say, by deleting the last item on a 
bill).

The UI will not even let you attempt to do that (unless someone modifies it).

>> By the way, I do not presently have any bills in my 'bill' table.

That is strange. In that case, deleting bill items should be
straightforward. I guess I would need to see the actual
table data to tell for sure. The trigger does not touch the
bill.bill table at all, btw.

> Disabling (after which deleting and then re-enabling)
> 
>       ALTER TABLE bill.bill_item DISABLE TRIGGER tr_prevent_empty_bills ;
> 
> allowed me to delete the offending record. Hopefully it was ok to circumvent 
> the constraint.

The worst that can happen would be an empty bill (one with
no items linked to it and thusly it not being linked to any
patient anymore). Those you can find with

        select * from bill.bill where pk not in (select fk_bill from 
bill.bill_item);

> Question: if I do
> 
>       \d+ bill.bill_item
> 
> I am shown triggers which include the following
> 
>       tr_prevent_empty_bills BEFORE DELETE OR UPDATE ON bill.bill_item FOR 
> EACH ROW EXECUTE PROCEDURE bill.trf_prevent_empty_bills()
> 
> but I had trouble to further examine for why the above gives trouble. Where 
> is the procedure
> 
>       bill.trf_prevent_empty_bills()
> 
> further defined?

Inside the database:

        \df+ bill.trf_prevent_empty_bills

> I am assuming that this trigger wants to avoid the
> existence of bills for which there exist no items linked to
> the bill.

Correct.

Karsten
-- 
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



reply via email to

[Prev in Thread] Current Thread [Next in Thread]