-
- $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
-
- |
-
-
- |
-
-
- |
-
-
-
- {rowcount}>
-
-
-
- |
-
-
-
-
-
- |.$locale->text('Payments').qq| |
-
-|;
+ $form->{javascript} .= qq||;
+ $form->{javascript} .= qq||;
+ $form->{javascript} .= qq||;
+ $form->header();
- 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);
- }
+ for my $i (1 .. $form->{rowcount}) {
- $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 "
-
-";
-
- $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>/;
-
-
# format amounts
- $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"}>|;
- }
+ $form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
+ $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
+
+ 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}";
}
- $exchangerate .= qq|
-{"forex_$i"}>
-|;
+ $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
+
+ $form->{'selected_accno_full_'. $i} = $selected_accno_full;
- $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 "
-
-";
+ $form->{'selected_taxchart_'. $i} = $selected_taxchart;
}
- map { $form->{$_} =~ s/\"/"/g } qw(selectAP_paid);
- print qq|
- {paidaccounts}>
-
-
-
- |
-
-
-
|
-
-
-|;
- $lxdebug->leave_sub();
-}
+ $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);
+ $form->{totalpaid} = 0;
-sub form_footer {
- $lxdebug->enter_sub();
+ if ( $form->{'paid_'. $form->{paidaccounts}} ) {
+ $form->{paidaccounts}++;
+ }
+ 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);
+ }
+ if ($form->{"exchangerate_$i"} == 0) {
+ $form->{"exchangerate_$i"} = "";
+ } else {
+ $form->{"exchangerate_$i"} =
+ $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
+ }
- print qq|
+ 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"});
+ }
-