use SL::IO;
use SL::TransNumber;
use SL::DB::Default;
+use SL::DB::Draft;
use SL::DB::Tax;
use SL::DB::TaxZone;
use SL::TransNumber;
use SL::DB;
+use SL::Presenter::Part qw(type_abbreviation classification_abbreviation);
use Data::Dumper;
use strict;
}
my $tax_rate = $taxrate * 100;
push(@{ $form->{TEMPLATE_ARRAYS}->{tax_rate} }, qq|$tax_rate|);
- if ($form->{"assembly_$i"}) {
+ if ($form->{"part_type_$i"} eq 'assembly') {
$sameitem = "";
# get parts and push them onto the stack
'trans_id' => $form->{customer_id});
map { $form->{"vc_cvar_$_->{name}"} = $_->{value} } @{ $custom_variables };
+ if ($form->{cp_id}) {
+ $custom_variables = CVar->get_custom_variables(dbh => $dbh,
+ module => 'Contacts',
+ trans_id => $form->{cp_id});
+ $form->{"cp_cvar_$_->{name}"} = $_->{value} for @{ $custom_variables };
+ }
+
$form->{cp_greeting} = GenericTranslations->get('dbh' => $dbh,
'translation_type' => 'greetings::' . ($form->{cp_gender} eq 'f' ? 'female' : 'male'),
'language_id' => $language_id,
next if $payments_only;
- if ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"}) {
+ if ($form->{"inventory_accno_$i"} || $form->{"part_type_$i"} eq 'assembly') {
- if ($form->{"assembly_$i"}) {
+ if ($form->{"part_type_$i"} eq 'assembly') {
# record assembly item as allocated
&process_assembly($dbh, $myconfig, $form, $position, $form->{"id_$i"}, $baseqty);
# need the current dbh to get the not yet committed mtime
$form->new_lastmtime('ar', $provided_dbh);
- $form->{name} = $form->{customer};
- $form->{name} =~ s/--\Q$form->{customer_id}\E//;
-
# add shipto
if (!$form->{shipto_id}) {
$form->add_shipto($dbh, $form->{id}, "AR");
do_query($form, $dbh, $query, @orphaned_ids);
}
+ if ($form->{draft_id}) {
+ SL::DB::Manager::Draft->delete_all(where => [ id => delete($form->{draft_id}) ]);
+ }
+
# safety check datev export
if ($::instance_conf->get_datev_check_on_sales_invoice) {
- my $transdate = $::form->{invdate} ? DateTime->from_lxoffice($::form->{invdate}) : undef;
- $transdate ||= DateTime->today;
my $datev = SL::DATEV->new(
- exporttype => DATEV_ET_BUCHUNGEN,
- format => DATEV_FORMAT_KNE,
dbh => $dbh,
trans_id => $form->{id},
);
- $datev->export;
+ $datev->generate_datev_data;
if ($datev->errors) {
die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors;
my $payment_id;
# get customer
+ my $where = '';
+ if ($cid) {
+ $where .= 'AND c.id = ?';
+ push @values, $cid;
+ }
$query =
qq|SELECT
c.id AS customer_id, c.name AS customer, c.discount as customer_discount, c.creditlimit,
FROM customer c
LEFT JOIN business b ON (b.id = c.business_id)
LEFT JOIN currencies cu ON (c.currency_id=cu.id)
- WHERE c.id = ?|;
- push @values, $cid;
+ WHERE 1 = 1 $where|;
$ref = selectfirst_hashref_query($form, $dbh, $query, @values);
delete $ref->{salesman_id} if !$ref->{salesman_id};
push @{ $ref->{matches} ||= [] }, $::locale->text('EAN') . ': ' . $ref->{ean};
}
- $ref->{type_and_classific} = $::request->presenter->type_abbreviation($ref->{part_type}).
- $::request->presenter->classification_abbreviation($ref->{classification_id});
+ $ref->{type_and_classific} = type_abbreviation($ref->{part_type}) .
+ classification_abbreviation($ref->{classification_id});
if (! $ref->{used_for_sale} ) {
$has_wrong_pclass = PCLASS_NOTFORSALE ;
next;
}
$ref->{onhand} *= 1;
-
push @{ $form->{item_list} }, $ref;
}
$sth->finish;