AR->get_transdate(\%myconfig, $form);
$form->{initial_transdate} = $form->{transdate};
- &create_links;
+ create_links(dont_save => 1);
$form->{transdate} = $form->{initial_transdate};
&display_form;
$main::lxdebug->leave_sub();
$form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
$form->{title} = "Edit";
- &create_links;
+ create_links();
&display_form;
$main::lxdebug->leave_sub();
$main::auth->assert('general_ledger');
+ my %params = @_;
my $form = $main::form;
my %myconfig = %main::myconfig;
- my ($duedate, $taxincluded);
-
$form->create_links("AR", \%myconfig, "customer");
- $duedate = $form->{duedate};
- $taxincluded = $form->{taxincluded};
- my $id = $form->{id};
+ my %saved;
+ if (!$params{dont_save}) {
+ %saved = map { ($_ => $form->{$_}) } qw(direct_debit id taxincluded);
+ $saved{duedate} = $form->{duedate} if $form->{duedate};
+ }
+
IS->get_customer(\%myconfig, \%$form);
- $form->{taxincluded} = $taxincluded;
- $form->{id} = $id;
- $form->{duedate} = $duedate if $duedate;
+ $form->{$_} = $saved{$_} for keys %saved;
$form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
$form->{rowcount} = 1;
$taxcharts{$item->{id}} = $item;
}
- $::request->{layout}->focus("#customer");
-
my $follow_up_vc = $form->{customer};
$follow_up_vc =~ s/--.*?//;
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)";
gldate => $form->{"gldate_$i"},
};
+ # default account for current assets (i.e. 1801 - SKR04) if no account is selected
+ $form->{accno_arap} = IS->get_standard_accno_current_assets(\%myconfig, \%$form);
+
$payment->{selectAR_paid} =
NTI($cgi->popup_menu('-name' => "AR_paid_$i",
'-id' => "AR_paid_$i",
'-values' => \@AR_paid_values,
'-labels' => \%chart_labels,
- '-default' => $payment->{AR_paid}));
+ '-default' => $payment->{AR_paid} || $form->{accno_arap}));
for my $i (1 .. $form->{rowcount}) {
$form->{"amount_$i"} = $form->parse_amount(\%myconfig, $form->{"amount_$i"});
- $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
if ($form->{"amount_$i"}) {
push @a, {};
my $j = $#a;
my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
- if ($taxkey > 1) {
- if ($form->{taxincluded}) {
- $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
- } else {
- $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
- }
- } else {
- $form->{"tax_$i"} = 0;
- }
- $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
+
+ my $tmpnetamount;
+ ($tmpnetamount,$form->{"tax_$i"}) = $form->calculate_tax($form->{"amount_$i"},$rate,$form->{taxincluded},2);
$totaltax += $form->{"tax_$i"};
map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
+
+ $form->error($locale->text('Cannot post transaction above the maximum future booking date!'))
+ if ($form->date_max_future($transdate, \%myconfig));
$form->error($locale->text('Cannot post transaction for a closed period!')) if ($form->date_closed($form->{"transdate"}, \%myconfig));
$form->error($locale->text('Zero amount posting!'))
sub search {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger | invoice_edit');
+ $main::auth->assert('invoice_edit');
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
my $cgi = $::request->{cgi};
- my ($customer, $department);
- my ($jsscript, $button1, $button2);
-
# setup customer selection
$form->all_vc(\%myconfig, "customer", "AR");
$form->{title} = $locale->text('AR Transactions');
- $form->{jsscript} = 1;
# Auch in Rechnungsübersicht nach Kundentyp filtern - jan
$form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 },
"departments" => "ALL_DEPARTMENTS",
"customers" => "ALL_VC",
"business_types" => "ALL_BUSINESS_TYPES");
- $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
+ $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
$form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
# constants and subs for template
- $form->{jsscript} = 1;
$form->{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
$form->header;
sub ar_transactions {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger | invoice_edit');
+ $main::auth->assert('invoice_edit');
my $form = $main::form;
my %myconfig = %main::myconfig;
my $report = SL::ReportGenerator->new(\%myconfig, $form);
@columns =
- qw(transdate id type invnumber ordnumber name netamount tax amount paid
+ qw(transdate id type invnumber ordnumber cusordnumber name netamount tax amount paid
datepaid due duedate transaction_description notes salesman employee shippingpoint shipvia
marge_total marge_percent globalprojectnumber customernumber country ustid taxzone payment_terms charts customertype);
my @hidden_variables = map { "l_${_}" } @columns;
- push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber transaction_description notes project_id transdatefrom transdateto employee_id salesman_id business_id);
+ push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber cusordnumber transaction_description notes project_id transdatefrom transdateto employee_id salesman_id business_id);
$href = build_std_url('action=ar_transactions', grep { $form->{$_} } @hidden_variables);
'type' => { 'text' => $locale->text('Type'), },
'invnumber' => { 'text' => $locale->text('Invoice'), },
'ordnumber' => { 'text' => $locale->text('Order'), },
+ 'cusordnumber' => { 'text' => $locale->text('Customer Order Number'), },
'name' => { 'text' => $locale->text('Customer'), },
'netamount' => { 'text' => $locale->text('Amount'), },
'tax' => { 'text' => $locale->text('Tax'), },
'customertype' => { 'text' => $locale->text('Customer type'), },
);
- foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid employee shippingpoint shipvia transaction_description)) {
+ foreach my $name (qw(id transdate duedate invnumber ordnumber cusordnumber name datepaid employee shippingpoint shipvia transaction_description)) {
my $sortdir = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir};
$column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir";
}
if ($form->{customer}) {
push @options, $locale->text('Customer') . " : $form->{customer}";
}
+ if ($form->{cp_name}) {
+ push @options, $locale->text('Contact Person') . " : $form->{cp_name}";
+ }
if ($form->{department}) {
my ($department) = split /--/, $form->{department};
push @options, $locale->text('Department') . " : $department";
if ($form->{ordnumber}) {
push @options, $locale->text('Order Number') . " : $form->{ordnumber}";
}
+ if ($form->{cusordnumber}) {
+ push @options, $locale->text('Customer Order Number') . " : $form->{cusordnumber}";
+ }
if ($form->{notes}) {
push @options, $locale->text('Notes') . " : $form->{notes}";
}
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
- $form->{snumbers} = "ordnumber_$form->{ordnumber}";
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{addition} = "STORNO";
$form->save_history;
}