# add paid transactions
for my $i (1 .. $form->{paidaccounts}) {
+
+ if ($form->{"acc_trans_id_$i"} && $payments_only && ($::lx_office_conf{features}->{payments_changeable} == 0)) {
+ next;
+ }
+
if ($form->{"paid_$i"} != 0) {
my $project_id = conv_i($form->{"paid_project_id_$i"});
$old_form = save_form();
# Delete all entries in acc_trans from prior payments.
- $self->_delete_payments($form, $dbh);
+ if ($::lx_office_conf{features}->{payments_changeable} != 0) {
+ $self->_delete_payments($form, $dbh);
+ }
# Save the new payments the user made before cleaning up $form.
- my $payments_re = '^datepaid_\d+$|^gldate_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^paid_project_id_\d+$|^AP_paid_\d+$|^paidaccounts$';
+ my $payments_re = '^datepaid_\d+$|^gldate_\d+$|^acc_trans_id_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^paid_project_id_\d+$|^AP_paid_\d+$|^paidaccounts$';
map { $payments{$_} = $form->{$_} } grep m/$payments_re/, keys %{ $form };
# Clean up $form so that old content won't tamper the results.
if ($key eq "AP_paid") {
$j++;
$form->{"AP_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
+ $form->{"acc_trans_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{acc_trans_id};
$form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
$form->{"datepaid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{transdate};
$form->{"gldate_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{gldate};
$additional_params->{"conf_parts_image_css"} = $::lx_office_conf{features}->{parts_image_css};
$additional_params->{"conf_parts_listing_images"} = $::lx_office_conf{features}->{parts_listing_images};
$additional_params->{"conf_parts_show_image"} = $::lx_office_conf{features}->{parts_show_image};
+ $additional_params->{"conf_payments_changeable"} = $::lx_office_conf{features}->{payments_changeable};
$additional_params->{"INSTANCE_CONF"} = $::instance_conf;
if (%main::debug_options) {
$query =
qq|SELECT
c.accno, c.description,
- a.source, a.amount, a.memo, a.transdate, a.gldate, a.cleared, a.project_id, a.taxkey,
+ a.acc_trans_id, a.source, a.amount, a.memo, a.transdate, a.gldate, a.cleared, a.project_id, a.taxkey,
p.projectnumber,
t.rate, t.id
FROM acc_trans a
$form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
}
+ print qq|<input type=hidden name="acc_trans_id_$i" value=$form->{"acc_trans_id_$i"}>\n|;
print qq|<input type=hidden name="gldate_$i" value=$form->{"gldate_$i"}>\n|;
- my $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"});
- $form->{"payment_readonly_$i"} = ($changeable)? 0 : 1;
- print qq|<input type=hidden name="payment_readonly_$i" value=$form->{"payment_readonly_$i"}>\n|;
+ my $changeable = 1;
+ if ($::lx_office_conf{features}->{payments_changeable} == 0) {
+ # never
+ $changeable = ($form->{"acc_trans_id_$i"})? 0 : 1;
+ }
+ if ($::lx_office_conf{features}->{payments_changeable} == 2) {
+ # on the same day
+ $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"});
+ }
$exchangerate = qq| |;
if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
$main::auth->assert('general_ledger');
- map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 gldate_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
+ map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
$form->{paidaccounts} = 1;
$form->{rowcount}--;
$form->{invdate} = $form->current_date(\%myconfig);
# Show the picture in the results when you search for parts
parts_listing_images = 0
+# Should payments be changeable after posting (0 = never; 1 = every time; 2 = on the same day)
+payments_changeable = 1
+
[paths]
# path to temporary files (must be writeable by the web server)
userspath = users