$query = qq|UPDATE ar SET paid = ? WHERE id = ?|;
do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id}));
$query = qq|UPDATE ar SET paid = ? WHERE id = ?|;
do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id}));
# save printed, emailed and queued
$form->save_status($dbh);
# save printed, emailed and queued
$form->save_status($dbh);
# Link this record to the records it was created from.
RecordLinks->create_links('dbh' => $dbh,
# Link this record to the records it was created from.
RecordLinks->create_links('dbh' => $dbh,
# sellprice is the cost of the item
my $linetotal = $form->round_amount(($ref->{sellprice} * $qty) / ( ($ref->{price_factor} || 1) * ( $basefactor || 1 )), 2);
# sellprice is the cost of the item
my $linetotal = $form->round_amount(($ref->{sellprice} * $qty) / ( ($ref->{price_factor} || 1) * ( $basefactor || 1 )), 2);
$ref->{expense_accno} = ($form->{"expense_accno_$row"}) ? $form->{"expense_accno_$row"} : $ref->{expense_accno};
# add to expense
$form->{amount_cogs}{ $form->{id} }{ $ref->{expense_accno} } += -$linetotal;
$ref->{expense_accno} = ($form->{"expense_accno_$row"}) ? $form->{"expense_accno_$row"} : $ref->{expense_accno};
# add to expense
$form->{amount_cogs}{ $form->{id} }{ $ref->{expense_accno} } += -$linetotal;
# Falls wir ein Storno haben, müssen zwei Felder in der stornierten Rechnung wieder
# zurückgesetzt werden. Vgl:
# Falls wir ein Storno haben, müssen zwei Felder in der stornierten Rechnung wieder
# zurückgesetzt werden. Vgl:
# to distinguish case A and B the variable pricegroup_id_$i is used
# for new articles this variable isn't defined, for loaded articles it is
# sellprice can't be used, as it already has 0,00 set
# to distinguish case A and B the variable pricegroup_id_$i is used
# for new articles this variable isn't defined, for loaded articles it is
# sellprice can't be used, as it already has 0,00 set
if ($pkr->{pricegroup_id} eq $form->{"pricegroup_id_$i"} and defined $form->{"pricegroup_id_$i"}) {
# Case A
$pkr->{selected} = ' selected';
if ($pkr->{pricegroup_id} eq $form->{"pricegroup_id_$i"} and defined $form->{"pricegroup_id_$i"}) {
# Case A
$pkr->{selected} = ' selected';
- } elsif ($pkr->{pricegroup_id} eq $form->{customer_klass}
- and not defined $form->{"pricegroup_id_$i"}
+ } elsif ($pkr->{pricegroup_id} eq $form->{customer_klass}
+ and not defined $form->{"pricegroup_id_$i"}
and $pkr->{price} != 0 # only use customer pricegroup price if it has a value, else use default_sellprice
# for the case where pricegroup prices haven't been set
) {
and $pkr->{price} != 0 # only use customer pricegroup price if it has a value, else use default_sellprice
# for the case where pricegroup prices haven't been set
) {