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

Re: 1.3 bin/am.pl , sub update , what is it supposed to do?



On Wed, Nov 30, 2011 at 2:12 AM, herman vierendeels
<..hidden..> wrote:
> Hello,
>
>
> Can anyone figure out what subroutine  update  in  bin/am.pl is meant to do?
> This subroutine is triggered by button update in form generated from
> template  UI/am-taxes.html.
>
> After clicking the button different times, depending on the initial
> number of tax-accounts displayed,
> you get a form where each initial line is followed by an empty line.
>
> When clicking Save button, one gets:
>
> ERROR: duplicate key value violates unique constraint "tax_pkey"
> DETAIL: Key (chart_id, validto)=(53, infinity) already exists.
> CONTEXT: SQL statement "INSERT INTO tax(chart_id, validto, rate,
> taxnumber, pass, taxmodule_id)
> VALUES (in_chart_id, in_validto, in_rate, in_taxnumber, in_pass,
> in_taxmodule_id)"
> PL/pgSQL function "account__save_tax" line 14 at SQL statement
>
> So, after the actual commit-freeze is lifted, i would disable that
> button, so that ons does not get frustrated by these errors.

Please don't disable the button.  This is necessary to allow tax rates
to be expired.

A better approach might be to change "save" to ignore lines where the
rate is not entered at all.  Note 0 is still a valid rate as it
indicates that the tax no longer applies.

Or handle the error better.

Longer explanation:

Tax rates sometimes change.  So we allow tax rates to expire, and
after that new tax rates occur.  Update allows us to add new data
entry lines. The problem occurs when we don't expire the previous
lines first.  However this workflow itself is flawed because you
likely only want to change one tax rate, not all tax rates.

Best Wishes,
Chris Travers