-
- $form->{title} |
-
-
-
-
-
-
-
-
-
- | . $locale->text('Vendor') . qq| |
- $vendor |
-
-
-
- {terms}>
-
-
- |
-
-
-
- | . $locale->text('Credit Limit') . qq| |
- $form->{creditlimit} |
- | . $locale->text('Remaining') . qq| |
- $form->{creditremaining} |
- {creditlimit}>
- {creditremaining}>
-
-
- |
-
- | . $locale->text('Currency') . qq| |
- |
-
- {defaultcurrency}>
- {fxgain_accno}>
- {fxloss_accno}>
- $exchangerate
-
- $department
- $taxincluded
-
- |
-
-
- |
-
-
- |
-
-
-
-
-$jsscript
-
-
-
- {rowcount}>
-
-
-
-
- |
- . $locale->text('Account') . qq| |
- |
- . $locale->text('Amount') . qq| |
- |
- . $locale->text('Tax') . qq| |
- |
- . $locale->text('Korrektur') . qq| |
- |
- . $locale->text('Taxkey') . qq| |
- |
- . $locale->text('Project') . qq| |
-
-|;
+ my $follow_up_vc = $form->{vendor};
+ $follow_up_vc =~ s/--.*?//;
+ my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)";
+
+ $form->{javascript} .= qq||;
+ $form->{javascript} .= qq||;
+ $form->{javascript} .= qq||;
- $amount = $locale->text('Amount');
- $project = $locale->text('Project');
+ $form->header();
- for $i (1 .. $form->{rowcount}) {
+ for my $i (1 .. $form->{rowcount}) {
# format amounts
- $form->{"amount_$i"} =
- $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
+ $form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
$form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
- $selectAP_amount = $selectAP_amount_unquoted;
- $re_amount = quotemeta($form->{"AP_amount_$i"});
- $selectAP_amount =~
- s/option value=\"${re_amount}\"/option value=\"$form->{"AP_amount_$i"}\" selected/;
- $tax = $taxchart;
- $tax_selected = $form->{"taxchart_$i"};
- $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
- $tax =
- qq| | |;
-
- my $korrektur = $form->{"korrektur_$i"} ? 'checked' : '';
-
- print qq|
-
- |
- {"amount_$i"}> |
- {"tax_$i"}> |
- |
- $tax
-
- {"project_id_$i"}>
- |
-
-|;
- $amount = "";
- $project = "";
+
+ my $selected_accno_full;
+ my ($accno_row) = split(/--/, $form->{"AP_amount_$i"});
+ my $item = $charts{$accno_row};
+ $selected_accno_full = "$item->{accno}--$item->{tax_id}";
+
+ my $selected_taxchart = $form->{"taxchart_$i"};
+ my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
+ my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AP_amount_$i"});
+
+ if ($previous_accno &&
+ ($previous_accno eq $selected_accno) &&
+ ($previous_tax_id ne $selected_tax_id)) {
+ my $item = $taxcharts{$selected_tax_id};
+ $selected_taxchart = "$item->{id}--$item->{rate}";
+ }
+
+ $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
+
+ $form->{'selected_accno_full_'. $i} = $selected_accno_full;
+
+ $form->{'selected_taxchart_'. $i} = $selected_taxchart;
}
- $taxlabel =
- ($form->{taxincluded})
- ? $locale->text('Tax Included')
- : $locale->text('Tax');
+ $form->{AP_amount_value_title_sub} = sub {
+ my $item = shift;
+ return [
+ $item->{accno} .'--'. $item->{tax_id},
+ $item->{accno} .'--'. $item->{description},
+ ];
+ };
+
+ $form->{taxchart_value_title_sub} = sub {
+ my $item = shift;
+ return [
+ $item->{id} .'--'. $item->{rate},
+ $item->{taxdescription} .' '. ($item->{rate} * 100) .' %',
+ ];
+ };
+ $form->{AP_paid_value_title_sub} = sub {
+ my $item = shift;
+ return [
+ $item->{accno},
+ $item->{accno} .'--'. $item->{description}
+ ];
+ };
+
+ $form->{APselected_value_title_sub} = sub {
+ my $item = shift;
+ return [
+ $item->{accno},
+ $item->{accno} .'--'. $item->{description}
+ ];
+ };
+
+ $form->{invtotal_unformatted} = $form->{invtotal};
$form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
- print qq|
-
-
-
- |
-
-
- |
-
- $form->{invtotal} |
-
- {oldinvtotal}>
- {oldtotalpaid}>
-
-
-
- |
-
-
-
-
- |
-
-
-
-
-
- | . $locale->text('Notes') . qq| |
- $notes |
-
-
- |
-
-
-
-
-
- | . $locale->text('Payments') . qq| |
-
-|;
+ $form->{totalpaid} = 0;
- if ($form->{currency} eq $form->{defaultcurrency}) {
- @column_index = qw(datepaid source memo paid AP_paid);
- } else {
- @column_index = qw(datepaid source memo paid exchangerate AP_paid);
+ if ( $form->{'paid_'. $form->{paidaccounts}} ) {
+ $form->{paidaccounts}++;
}
- $column_data{datepaid} = "" . $locale->text('Date') . " | ";
- $column_data{paid} = "" . $locale->text('Amount') . " | ";
- $column_data{exchangerate} = "" . $locale->text('Exch') . " | ";
- $column_data{AP_paid} = "" . $locale->text('Account') . " | ";
- $column_data{source} = "" . $locale->text('Source') . " | ";
- $column_data{memo} = "" . $locale->text('Memo') . " | ";
-
- print "
-
-";
- map { print "$column_data{$_}\n" } @column_index;
- print "
-
-";
-
- my @triggers = ();
- $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
- for $i (1 .. $form->{paidaccounts}) {
- print "
-
-";
-
- $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
- $form->{"selectAP_paid_$i"} =~
- s/option value=\"$form->{"AP_paid_$i"}\">/option value=\"$form->{"AP_paid_$i"}\" selected>/;
+ # default account for current assets (i.e. 1801 - SKR04)
+ $form->{accno_arap} = IS->get_standard_accno_current_assets(\%myconfig, \%$form);
+
+ for my $i (1 .. $form->{paidaccounts}) {
+ $form->{totalpaid} += $form->{"paid_$i"};
# format amounts
if ($form->{"paid_$i"}) {
- $form->{"paid_$i"} =
- $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
+ $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
}
- $form->{"exchangerate_$i"} =
- $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
-
- $exchangerate = qq| |;
- if ($form->{currency} ne $form->{defaultcurrency}) {
- if ($form->{"forex_$i"}) {
- $exchangerate =
- qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
- } else {
- $exchangerate =
- qq|{"exchangerate_$i"}>|;
- }
+ if ($form->{"exchangerate_$i"} == 0) {
+ $form->{"exchangerate_$i"} = "";
+ } else {
+ $form->{"exchangerate_$i"} =
+ $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
}
- $exchangerate .= qq|
-{"forex_$i"}>
-|;
+ my $changeable = 1;
+ if (SL::DB::Default->get->payments_changeable == 0) {
+ # never
+ $changeable = ($form->{"acc_trans_id_$i"})? 0 : 1;
+ }
+ if (SL::DB::Default->get->payments_changeable == 2) {
+ # on the same day
+ $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"});
+ }
- $column_data{"paid_$i"} =
- qq|{"paid_$i"}> | |;
- $column_data{"AP_paid_$i"} =
- qq| | |;
- $column_data{"exchangerate_$i"} = qq|$exchangerate | |;
- $column_data{"datepaid_$i"} =
- qq|{"datepaid_$i"}>
- | |;
- $column_data{"source_$i"} =
- qq| | |;
- $column_data{"memo_$i"} =
- qq| | |;
-
- map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
-
- print "
-
-";
- push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
+ $form->{'paidaccount_changeable_'. $i} = $changeable;
+
+ $form->{'labelpaid_project_id_'. $i} = $project_labels{$form->{'paid_project_id_'. $i}};
}
- map { $form->{$_} =~ s/\"/"/g } qw(selectAP_paid);
- print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
- qq|
- {paidaccounts}>
-
-
-
- |
-
-
-
|
-
-
-|;
- $lxdebug->leave_sub();
+ $form->{paid_missing} = $form->{invtotal_unformatted} - $form->{totalpaid};
+
+ print $form->parse_html_template('ap/form_header');
+
+ $main::lxdebug->leave_sub();
}
sub form_footer {
- $lxdebug->enter_sub();
+ $::lxdebug->enter_sub;
+ $::auth->assert('general_ledger');
- print qq|
+ my $num_due;
+ my $num_follow_ups;
+ if ($::form->{id}) {
+ my $follow_ups = FU->follow_ups('trans_id' => $::form->{id});
-