Revision 101b9705
Von Moritz Bunkus vor fast 8 Jahren hinzugefügt
bin/mozilla/ap.pl | ||
---|---|---|
114 | 114 |
$::form->{AP_chart_id} = $template->ar_ap_chart_id; |
115 | 115 |
$::form->{transdate} = $today->to_kivitendo; |
116 | 116 |
$::form->{duedate} = $today->to_kivitendo; |
117 |
$::form->{rowcount} = @{ $template->items } + 1;
|
|
117 |
$::form->{rowcount} = @{ $template->items }; |
|
118 | 118 |
$::form->{paidaccounts} = 1; |
119 | 119 |
$::form->{$_} = $template->$_ for qw(department_id ordnumber taxincluded notes); |
120 | 120 |
|
... | ... | |
152 | 152 |
|
153 | 153 |
flash('info', $::locale->text("The record template '#1' has been loaded.", $template->template_name)); |
154 | 154 |
|
155 |
update(); |
|
155 |
update( |
|
156 |
keep_rows_without_amount => 1, |
|
157 |
dont_add_new_row => 1, |
|
158 |
); |
|
156 | 159 |
} |
157 | 160 |
|
158 | 161 |
sub save_record_template { |
... | ... | |
165 | 168 |
$js->dialog->close('#record_template_dialog'); |
166 | 169 |
|
167 | 170 |
my @items = grep { |
168 |
$_->{chart_id} && (($_->{tax_id} // '') ne '') && ($_->{amount1} != 0)
|
|
171 |
$_->{chart_id} && (($_->{tax_id} // '') ne '') |
|
169 | 172 |
} map { |
170 | 173 |
+{ chart_id => $::form->{"AP_amount_chart_id_${_}"}, |
171 | 174 |
amount1 => $::form->parse_amount(\%::myconfig, $::form->{"amount_${_}"}), |
... | ... | |
584 | 587 |
} |
585 | 588 |
|
586 | 589 |
sub update { |
590 |
my %params = @_; |
|
591 |
|
|
587 | 592 |
$main::lxdebug->enter_sub(); |
588 | 593 |
|
589 | 594 |
my $form = $main::form; |
... | ... | |
605 | 610 |
my (@a, $j, $totaltax); |
606 | 611 |
for my $i (1 .. $form->{rowcount}) { |
607 | 612 |
$form->{"amount_$i"} = $form->parse_amount(\%myconfig, $form->{"amount_$i"}); |
608 |
if ($form->{"amount_$i"}) { |
|
613 |
if ($form->{"amount_$i"} || $params{keep_rows_without_amount}) {
|
|
609 | 614 |
push @a, {}; |
610 | 615 |
$j = $#a; |
611 | 616 |
my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); |
... | ... | |
632 | 637 |
IR->get_vendor(\%::myconfig, $form); |
633 | 638 |
} |
634 | 639 |
|
635 |
$form->{rowcount} = $count + 1;
|
|
640 |
$form->{rowcount} = $count + ($params{dont_add_new_row} ? 0 : 1);
|
|
636 | 641 |
|
637 | 642 |
$form->{invtotal} = |
638 | 643 |
($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax; |
... | ... | |
658 | 663 |
$form->{oldinvtotal} = $form->{invtotal}; |
659 | 664 |
$form->{oldtotalpaid} = $totalpaid; |
660 | 665 |
|
661 |
&display_form;
|
|
666 |
display_form();
|
|
662 | 667 |
|
663 | 668 |
$main::lxdebug->leave_sub(); |
664 | 669 |
} |
bin/mozilla/ar.pl | ||
---|---|---|
112 | 112 |
$::form->{AR_chart_id} = $template->ar_ap_chart_id; |
113 | 113 |
$::form->{transdate} = $today->to_kivitendo; |
114 | 114 |
$::form->{duedate} = $today->to_kivitendo; |
115 |
$::form->{rowcount} = @{ $template->items } + 1;
|
|
115 |
$::form->{rowcount} = @{ $template->items }; |
|
116 | 116 |
$::form->{paidaccounts} = 1; |
117 | 117 |
$::form->{$_} = $template->$_ for qw(department_id ordnumber taxincluded employee_id notes); |
118 | 118 |
|
... | ... | |
150 | 150 |
|
151 | 151 |
flash('info', $::locale->text("The record template '#1' has been loaded.", $template->template_name)); |
152 | 152 |
|
153 |
update(); |
|
153 |
update( |
|
154 |
keep_rows_without_amount => 1, |
|
155 |
dont_add_new_row => 1, |
|
156 |
); |
|
154 | 157 |
} |
155 | 158 |
|
156 | 159 |
sub save_record_template { |
... | ... | |
163 | 166 |
$js->dialog->close('#record_template_dialog'); |
164 | 167 |
|
165 | 168 |
my @items = grep { |
166 |
$_->{chart_id} && (($_->{tax_id} // '') ne '') && ($_->{amount1} != 0)
|
|
169 |
$_->{chart_id} && (($_->{tax_id} // '') ne '') |
|
167 | 170 |
} map { |
168 | 171 |
+{ chart_id => $::form->{"AR_amount_chart_id_${_}"}, |
169 | 172 |
amount1 => $::form->parse_amount(\%::myconfig, $::form->{"amount_${_}"}), |
... | ... | |
567 | 570 |
} |
568 | 571 |
|
569 | 572 |
sub update { |
573 |
my %params = @_; |
|
570 | 574 |
$main::lxdebug->enter_sub(); |
571 | 575 |
|
572 | 576 |
$main::auth->assert('ar_transactions'); |
... | ... | |
591 | 595 |
|
592 | 596 |
for my $i (1 .. $form->{rowcount}) { |
593 | 597 |
$form->{"amount_$i"} = $form->parse_amount(\%myconfig, $form->{"amount_$i"}); |
594 |
if ($form->{"amount_$i"}) { |
|
598 |
if ($form->{"amount_$i"} || $params{keep_rows_without_amount}) {
|
|
595 | 599 |
push @a, {}; |
596 | 600 |
my $j = $#a; |
597 | 601 |
my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); |
... | ... | |
606 | 610 |
} |
607 | 611 |
|
608 | 612 |
$form->redo_rows(\@flds, \@a, $count, $form->{rowcount}); |
609 |
$form->{rowcount} = $count + 1;
|
|
613 |
$form->{rowcount} = $count + ($params{dont_add_new_row} ? 0 : 1);
|
|
610 | 614 |
map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount}); |
611 | 615 |
|
612 | 616 |
$form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'buy'); |
... | ... | |
641 | 645 |
$form->{oldinvtotal} = $form->{invtotal}; |
642 | 646 |
$form->{oldtotalpaid} = $form->{totalpaid}; |
643 | 647 |
|
644 |
&display_form;
|
|
648 |
display_form();
|
|
645 | 649 |
|
646 | 650 |
$main::lxdebug->leave_sub(); |
647 | 651 |
} |
bin/mozilla/gl.pl | ||
---|---|---|
105 | 105 |
$::form->{title} = "Add"; |
106 | 106 |
$::form->{transdate} = $today->to_kivitendo; |
107 | 107 |
$::form->{duedate} = $today->to_kivitendo; |
108 |
$::form->{rowcount} = @{ $template->items } + 1;
|
|
108 |
$::form->{rowcount} = @{ $template->items }; |
|
109 | 109 |
$::form->{paidaccounts} = 1; |
110 | 110 |
$::form->{$_} = $template->$_ for qw(department_id taxincluded ob_transaction cb_transaction reference description); |
111 | 111 |
$::form->{$_} = $dummy_form->{$_} for qw(closedto revtrans previous_id previous_gldate); |
... | ... | |
139 | 139 |
|
140 | 140 |
flash('info', $::locale->text("The record template '#1' has been loaded.", $template->template_name)); |
141 | 141 |
|
142 |
update(); |
|
142 |
update( |
|
143 |
keep_rows_without_amount => 1, |
|
144 |
dont_add_new_row => 1, |
|
145 |
); |
|
143 | 146 |
} |
144 | 147 |
|
145 | 148 |
sub save_record_template { |
... | ... | |
152 | 155 |
$js->dialog->close('#record_template_dialog'); |
153 | 156 |
|
154 | 157 |
my @items = grep { |
155 |
$_->{chart_id} && (($_->{tax_id} // '') ne '') && (($_->{amount1} != 0) || ($_->{amount2} != 0))
|
|
158 |
$_->{chart_id} && (($_->{tax_id} // '') ne '') |
|
156 | 159 |
} map { |
157 | 160 |
+{ chart_id => $::form->{"accno_id_${_}"}, |
158 | 161 |
amount1 => $::form->parse_amount(\%::myconfig, $::form->{"debit_${_}"}), |
... | ... | |
628 | 631 |
} |
629 | 632 |
|
630 | 633 |
sub update { |
634 |
my %params = @_; |
|
635 |
|
|
631 | 636 |
$main::lxdebug->enter_sub(); |
632 | 637 |
|
633 | 638 |
$main::auth->assert('gl_transactions'); |
... | ... | |
653 | 658 |
qw(accno debit credit projectnumber fx_transaction source memo tax taxchart); |
654 | 659 |
|
655 | 660 |
for my $i (1 .. $form->{rowcount}) { |
661 |
$form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) for qw(debit credit tax); |
|
656 | 662 |
|
657 |
unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) { |
|
658 |
for (qw(debit credit tax)) { |
|
659 |
$form->{"${_}_$i"} = |
|
660 |
$form->parse_amount(\%myconfig, $form->{"${_}_$i"}); |
|
661 |
} |
|
663 |
next if !$form->{"debit_$i"} && !$form->{"credit_$i"} && !$params{keep_rows_without_amount}; |
|
664 |
|
|
665 |
push @a, {}; |
|
666 |
$debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1"; |
|
667 |
if ($debitcredit) { |
|
668 |
$debitcount++; |
|
669 |
} else { |
|
670 |
$creditcount++; |
|
671 |
} |
|
662 | 672 |
|
663 |
push @a, {}; |
|
664 |
$debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1"; |
|
673 |
if (($debitcount >= 2) && ($creditcount == 2)) { |
|
674 |
$form->{"credit_$i"} = 0; |
|
675 |
$form->{"tax_$i"} = 0; |
|
676 |
$creditcount--; |
|
677 |
$form->{creditlock} = 1; |
|
678 |
} |
|
679 |
if (($creditcount >= 2) && ($debitcount == 2)) { |
|
680 |
$form->{"debit_$i"} = 0; |
|
681 |
$form->{"tax_$i"} = 0; |
|
682 |
$debitcount--; |
|
683 |
$form->{debitlock} = 1; |
|
684 |
} |
|
685 |
if (($creditcount == 1) && ($debitcount == 2)) { |
|
686 |
$form->{creditlock} = 1; |
|
687 |
} |
|
688 |
if (($creditcount == 2) && ($debitcount == 1)) { |
|
689 |
$form->{debitlock} = 1; |
|
690 |
} |
|
691 |
if ($debitcredit && $credittax) { |
|
692 |
$form->{"taxchart_$i"} = "$notax_id--0.00"; |
|
693 |
} |
|
694 |
if (!$debitcredit && $debittax) { |
|
695 |
$form->{"taxchart_$i"} = "$notax_id--0.00"; |
|
696 |
} |
|
697 |
$amount = |
|
698 |
($form->{"debit_$i"} == 0) |
|
699 |
? $form->{"credit_$i"} |
|
700 |
: $form->{"debit_$i"}; |
|
701 |
my $j = $#a; |
|
702 |
if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) { |
|
703 |
$form->{"taxchart_$i"} = "$notax_id--0.00"; |
|
704 |
$form->{"tax_$i"} = 0; |
|
705 |
} |
|
706 |
my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); |
|
707 |
my $iswithouttax = grep { $_->{id} == $taxkey } @{ $zerotaxes }; |
|
708 |
if (!$iswithouttax) { |
|
665 | 709 |
if ($debitcredit) { |
666 |
$debitcount++;
|
|
710 |
$debittax = 1;
|
|
667 | 711 |
} else { |
668 |
$creditcount++; |
|
669 |
} |
|
670 |
|
|
671 |
if (($debitcount >= 2) && ($creditcount == 2)) { |
|
672 |
$form->{"credit_$i"} = 0; |
|
673 |
$form->{"tax_$i"} = 0; |
|
674 |
$creditcount--; |
|
675 |
$form->{creditlock} = 1; |
|
676 |
} |
|
677 |
if (($creditcount >= 2) && ($debitcount == 2)) { |
|
678 |
$form->{"debit_$i"} = 0; |
|
679 |
$form->{"tax_$i"} = 0; |
|
680 |
$debitcount--; |
|
681 |
$form->{debitlock} = 1; |
|
682 |
} |
|
683 |
if (($creditcount == 1) && ($debitcount == 2)) { |
|
684 |
$form->{creditlock} = 1; |
|
685 |
} |
|
686 |
if (($creditcount == 2) && ($debitcount == 1)) { |
|
687 |
$form->{debitlock} = 1; |
|
688 |
} |
|
689 |
if ($debitcredit && $credittax) { |
|
690 |
$form->{"taxchart_$i"} = "$notax_id--0.00"; |
|
691 |
} |
|
692 |
if (!$debitcredit && $debittax) { |
|
693 |
$form->{"taxchart_$i"} = "$notax_id--0.00"; |
|
694 |
} |
|
695 |
$amount = |
|
696 |
($form->{"debit_$i"} == 0) |
|
697 |
? $form->{"credit_$i"} |
|
698 |
: $form->{"debit_$i"}; |
|
699 |
my $j = $#a; |
|
700 |
if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) { |
|
701 |
$form->{"taxchart_$i"} = "$notax_id--0.00"; |
|
702 |
$form->{"tax_$i"} = 0; |
|
712 |
$credittax = 1; |
|
703 | 713 |
} |
704 |
my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); |
|
705 |
my $iswithouttax = grep { $_->{id} == $taxkey } @{ $zerotaxes }; |
|
706 |
if (!$iswithouttax) { |
|
707 |
if ($debitcredit) { |
|
708 |
$debittax = 1; |
|
709 |
} else { |
|
710 |
$credittax = 1; |
|
711 |
} |
|
712 |
}; |
|
713 |
my ($tmpnetamount,$tmpdiff); |
|
714 |
($tmpnetamount,$form->{"tax_$i"},$tmpdiff) = $form->calculate_tax($amount,$rate,$form->{taxincluded} *= 1,2); |
|
714 |
}; |
|
715 |
my ($tmpnetamount,$tmpdiff); |
|
716 |
($tmpnetamount,$form->{"tax_$i"},$tmpdiff) = $form->calculate_tax($amount,$rate,$form->{taxincluded} *= 1,2); |
|
715 | 717 |
|
716 |
for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} } |
|
717 |
$count++; |
|
718 |
} |
|
718 |
for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} } |
|
719 |
$count++; |
|
719 | 720 |
} |
720 | 721 |
|
721 | 722 |
for my $i (1 .. $count) { |
... | ... | |
727 | 728 |
for (@flds) { delete $form->{"${_}_$i"} } |
728 | 729 |
} |
729 | 730 |
|
730 |
$form->{rowcount} = $count + 1;
|
|
731 |
$form->{rowcount} = $count + ($params{dont_add_new_row} ? 0 : 1);
|
|
731 | 732 |
|
732 |
&display_form;
|
|
733 |
display_form();
|
|
733 | 734 |
$main::lxdebug->leave_sub(); |
734 | 735 |
|
735 | 736 |
} |
sql/Pg-upgrade2/convert_drafts_to_record_templates.pl | ||
---|---|---|
123 | 123 |
|
124 | 124 |
# $tax_id may be 0 as there's an entry in tax with id = 0. |
125 | 125 |
# $chart_id must not be 0 as there's no entry in chart with id = 0. |
126 |
# No $amount means empty row. |
|
127 |
next unless $amount && $chart_id && (($tax_id // '') ne ''); |
|
126 |
next unless $chart_id && (($tax_id // '') ne ''); |
|
128 | 127 |
|
129 | 128 |
@values = ( |
130 | 129 |
# record_template_id, |
... | ... | |
198 | 197 |
|
199 | 198 |
# $tax_id may be 0 as there's an entry in tax with id = 0. |
200 | 199 |
# $chart_id must not be 0 as there's no entry in chart with id = 0. |
201 |
# No $amount means empty row. |
|
202 |
next unless $amount && $chart_id && (($tax_id // '') ne ''); |
|
200 |
next unless $chart_id && (($tax_id // '') ne ''); |
|
203 | 201 |
|
204 | 202 |
@values = ( |
205 | 203 |
# record_template_id, |
... | ... | |
271 | 269 |
|
272 | 270 |
# $tax_id may be 0 as there's an entry in tax with id = 0. |
273 | 271 |
# $chart_id must not be 0 as there's no entry in chart with id = 0. |
274 |
# No $debit and no $credit means empty row. |
|
275 |
next unless ($debit || $credit) && $chart_id && (($tax_id // '') ne ''); |
|
272 |
next unless $chart_id && (($tax_id // '') ne ''); |
|
276 | 273 |
|
277 | 274 |
@values = ( |
278 | 275 |
# record_template_id, |
... | ... | |
323 | 320 |
$self->clean_drafts; |
324 | 321 |
$self->finish_statements; |
325 | 322 |
|
326 |
# die "boom!"; |
|
327 |
|
|
328 | 323 |
return 1; |
329 | 324 |
} |
330 | 325 |
|
Auch abrufbar als: Unified diff
Belegvorlagen: Zeilen ohne Betrag beibehalten