$form->{invtotal} = $form->format_amount($myconfig, $form->{invtotal}, 2);
$form->{paid} = $form->format_amount($myconfig, $form->{paid}, 2);
- $form->set_payment_options($myconfig, $form->{invdate});
+ $form->set_payment_options($myconfig, $form->{invdate}, 'sales_invoice');
$form->{delivery_term} = SL::DB::Manager::DeliveryTerm->find_by(id => $form->{delivery_term_id} || undef);
- $form->{delivery_term}->description_long($form->{delivery_term}->translated_attribute('description_long', $form->{language_id})) if $form->{delivery_term} && $form->{language_id};
+ if ($form->{delivery_term} && $form->{language_id}) {
+ $form->{delivery_term}->description_long( $form->{delivery_term}->translated_attribute('description_long', $form->{language_id}));
+ $form->{delivery_term}->description_long_invoice($form->{delivery_term}->translated_attribute('description_long_invoice', $form->{language_id}));
+ }
+
$form->{department} = SL::DB::Manager::Department->find_by(id => $form->{department_id})->description if $form->{department_id};
$form->{username} = $myconfig->{name};
}
# Invoice Summary includes Rounding
+ my $grossamount = $netamount + $tax;
my $rounding = $form->round_amount(
- $form->round_amount($netamount + $tax, 2, 1) - $form->round_amount($netamount + $tax, 2), 2
+ $form->round_amount($grossamount, 2, 1) - $form->round_amount($grossamount, 2),
+ 2
);
my $rnd_accno = $rounding == 0 ? 0
: $rounding > 0 ? $form->{rndgain_accno}
- : $form->{rndloss_accno};
- $form->{amount}{ $form->{id} }{ $form->{AR} } = $form->round_amount($netamount + $tax, 2, 1);
- $form->{paid} =
- $form->round_amount($form->{paid} * $form->{exchangerate} + $diff, 2);
+ : $form->{rndloss_accno}
+ ;
+ $form->{amount}{ $form->{id} }{ $form->{AR} } = $form->round_amount($grossamount, 2, 1);
+ $form->{paid} = $form->round_amount(
+ $form->{paid} * $form->{exchangerate} + $diff,
+ 2
+ );
# reverse AR
$form->{amount}{ $form->{id} }{ $form->{AR} } *= -1;
if ($form->{storno}) {
$query =
qq!UPDATE ar SET
- paid = paid + amount,
+ paid = amount,
storno = 't',
intnotes = ? || intnotes
WHERE id = ?!;
parts_id => $part->id,
bin_id => $bin_id);
if ($error == 1) {
- push @errors, $::locale->text('Part "#1" has chargenumber or best before date set. So it cannot be transfered automaticaly.',
+ push @errors, $::locale->text('Part "#1" has chargenumber or best before date set. So it cannot be transfered automatically.',
$part->description);
}
my $form_unit_obj = SL::DB::Unit->new(name => $unit)->load;
my ($table, $field) = split m/\./, $column;
next if !$form->{"${field}_${i}"};
$where .= qq| AND lower(${column}) ILIKE ?|;
- push @values, '%' . $form->{"${field}_${i}"} . '%';
+ push @values, like($form->{"${field}_${i}"});
}
my (%mm_by_id);
my $mm_query = qq|
SELECT parts_id, model FROM makemodel LEFT JOIN parts ON parts.id = parts_id WHERE NOT parts.obsolete AND model ILIKE ?;
|;
- my $mm_results = selectall_hashref_query($::form, $dbh, $mm_query, '%' . $form->{"partnumber_$i"} . '%');
+ my $mm_results = selectall_hashref_query($::form, $dbh, $mm_query, like($form->{"partnumber_$i"}));
my @mm_ids = map { $_->{parts_id} } @$mm_results;
push @{$mm_by_id{ $_->{parts_id} } ||= []}, $_ for @$mm_results;