869 |
869 |
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
|
870 |
870 |
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
|
871 |
871 |
|
872 |
|
print qq|<input class="submit" type="submit" name="action" id="update_button" value="|
|
873 |
|
. $locale->text('Update') . qq|">
|
874 |
|
|;
|
|
872 |
# ToDO: insert a global check for stornos, so that a storno is only possible a limited time after saving it
|
|
873 |
print qq|<input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|">|;
|
|
874 |
if $form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar');
|
|
875 |
|
|
876 |
print qq|<input class="submit" type="submit" name="action" id="update_button" value="| . $locale->text('Update') . qq|">\n|;
|
875 |
877 |
if ($form->{id}) {
|
876 |
878 |
if ($form->{radier}) {
|
877 |
879 |
print qq|
|
878 |
|
<input class=submit type=submit name=action value="|
|
879 |
|
. $locale->text('Post') . qq|">
|
880 |
|
<input class=submit type=submit name=action value="|
|
881 |
|
. $locale->text('Delete') . qq|">
|
882 |
|
|;
|
|
880 |
<input class=submit type=submit name=action value="| . $locale->text('Post') . qq|">
|
|
881 |
<input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|"> |;
|
883 |
882 |
}
|
884 |
883 |
if ($transdate > $closedto) {
|
885 |
884 |
print qq|
|
886 |
|
<input class=submit type=submit name=action value="|
|
887 |
|
. $locale->text('Use As Template') . qq|">
|
888 |
|
|;
|
|
885 |
<input class=submit type=submit name=action value="| . $locale->text('Use As Template') . qq|"> |;
|
889 |
886 |
}
|
890 |
887 |
print qq|
|
891 |
|
<input class=submit type=submit name=action value="|
|
892 |
|
. $locale->text('Post Payment') . qq|">
|
893 |
|
|;
|
|
888 |
<input class=submit type=submit name=action value="| . $locale->text('Post Payment') . qq|"> |;
|
894 |
889 |
|
895 |
890 |
} else {
|
896 |
891 |
if ($transdate > $closedto) {
|
897 |
|
print qq|<input class=submit type=submit name=action value="|
|
898 |
|
. $locale->text('Post') . qq|"> | .
|
899 |
|
NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
|
900 |
|
'-class' => 'submit'));
|
|
892 |
print qq|<input class=submit type=submit name=action value="| . $locale->text('Post') . qq|"> | .
|
|
893 |
NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit'));
|
901 |
894 |
}
|
902 |
895 |
}
|
903 |
896 |
|
... | ... | |
907 |
900 |
}
|
908 |
901 |
# button for saving history
|
909 |
902 |
if($form->{id} ne "") {
|
910 |
|
print qq|
|
911 |
|
<input type=button class=submit onclick=set_history_window(|
|
912 |
|
. $form->{id}
|
913 |
|
. qq|); name=history id=history value=|
|
914 |
|
. $locale->text('history')
|
915 |
|
. qq|>|;
|
|
903 |
print qq|<input type=button class=submit onclick=set_history_window($form->{id}); name=history id=history value=| . $locale->text('history') . qq|>|;
|
916 |
904 |
}
|
917 |
905 |
# /button for saving history
|
918 |
906 |
print "
|
... | ... | |
1058 |
1046 |
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
|
1059 |
1047 |
$form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
|
1060 |
1048 |
|
1061 |
|
my $zero_amount_posting = 1;
|
1062 |
|
for $i (1 .. $form->{rowcount}) {
|
1063 |
|
if ($form->parse_amount(\%myconfig, $form->{"amount_$i"})) {
|
1064 |
|
$zero_amount_posting = 0;
|
1065 |
|
last;
|
1066 |
|
}
|
1067 |
|
}
|
1068 |
|
|
1069 |
|
$form->error($locale->text('Zero amount posting!')) if $zero_amount_posting;
|
|
1049 |
$form->error($locale->text('Zero amount posting!'))
|
|
1050 |
unless grep $_*1, map $form->parse_amount(\%myconfig, $form->{"amount_$_"}), 1..$form->{rowcount};
|
1070 |
1051 |
|
1071 |
1052 |
$form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
|
1072 |
1053 |
if ($form->{currency} ne $form->{defaultcurrency});
|
... | ... | |
1083 |
1064 |
if ($datepaid <= $closedto);
|
1084 |
1065 |
|
1085 |
1066 |
if ($form->{currency} ne $form->{defaultcurrency}) {
|
1086 |
|
$form->{"exchangerate_$i"} = $form->{exchangerate}
|
1087 |
|
if ($transdate == $datepaid);
|
1088 |
|
$form->isblank("exchangerate_$i",
|
1089 |
|
$locale->text('Exchangerate for payment missing!'));
|
|
1067 |
$form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid);
|
|
1068 |
$form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!'));
|
1090 |
1069 |
}
|
1091 |
1070 |
}
|
1092 |
1071 |
}
|
... | ... | |
1104 |
1083 |
if (AR->post_transaction(\%myconfig, \%$form)) {
|
1105 |
1084 |
# saving the history
|
1106 |
1085 |
if(!exists $form->{addition} && $form->{id} ne "") {
|
1107 |
|
$form->{snumbers} = qq|invnumber_| . $form->{invnumber};
|
1108 |
|
$form->{addition} = "POSTED";
|
1109 |
|
$form->save_history($form->dbconnect(\%myconfig));
|
|
1086 |
$form->{snumbers} = "invnumber_$form->{invnumber}";
|
|
1087 |
$form->{addition} = "POSTED";
|
|
1088 |
$form->save_history($form->dbconnect(\%myconfig));
|
1110 |
1089 |
}
|
1111 |
1090 |
# /saving the history
|
1112 |
1091 |
remove_draft() if $form->{remove_draft};
|
... | ... | |
1671 |
1650 |
$column_data{invnumber} =
|
1672 |
1651 |
"<td><a href=$module?action=edit&id=$ar->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
|
1673 |
1652 |
|
1674 |
|
my $is_storno = $ar->{storno} && ($ar->{invnumber} =~ /^Storno zu/);
|
|
1653 |
my $is_storno = $ar->{storno} && IS->is_storno(\%myconfig, $form, 'ar'); #($ar->{invnumber} =~ /^Storno zu/); # ToDO: fix this
|
1675 |
1654 |
my $has_storno = $ar->{storno} && !$is_storno;
|
1676 |
1655 |
|
1677 |
1656 |
$column_data{type} = "<td>" .
|
... | ... | |
1805 |
1784 |
|
1806 |
1785 |
$lxdebug->leave_sub();
|
1807 |
1786 |
}
|
|
1787 |
|
|
1788 |
|
|
1789 |
sub storno {
|
|
1790 |
$lxdebug->enter_sub();
|
|
1791 |
|
|
1792 |
if (IS->has_storno(\%myconfig, $form, 'ar')) {
|
|
1793 |
$form->{title} = $locale->text("Cancel Accounts Receivables Transaction");
|
|
1794 |
$form->error($locale->text("Transaction has already been cancelled!"));
|
|
1795 |
}
|
|
1796 |
|
|
1797 |
# ToDO:
|
|
1798 |
# - nicht anzeigen wenn neue rechnung
|
|
1799 |
# - nicht anzeigen wenn schons toniert
|
|
1800 |
# - nicht anziegen wenn zahlungen da
|
|
1801 |
|
|
1802 |
|
|
1803 |
# my %keep_keys = map { $_, 1 } qw(login password id stylesheet);
|
|
1804 |
# map { delete $form->{$_} unless $keep_keys{$_} } keys %{ $form };
|
|
1805 |
# prepare_transaction();
|
|
1806 |
|
|
1807 |
# negate amount/taxes
|
|
1808 |
for my $i (1 .. $form->{rowcount}) {
|
|
1809 |
$form->{"amount_$i"} *= -1;
|
|
1810 |
$form->{"tax_$i"} *= -1;
|
|
1811 |
}
|
|
1812 |
|
|
1813 |
# format things
|
|
1814 |
for my $i (1 .. $form->{rowcount}) {
|
|
1815 |
for (qw(amount tax)) {
|
|
1816 |
$form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) if $form->{"${_}_$i"};
|
|
1817 |
}
|
|
1818 |
}
|
|
1819 |
|
|
1820 |
$form->{storno} = 1;
|
|
1821 |
$form->{storno_id} = $form->{id};
|
|
1822 |
$form->{id} = 0;
|
|
1823 |
|
|
1824 |
$form->{invnumber} = "Storno-" . $form->{invnumber};
|
|
1825 |
|
|
1826 |
post();
|
|
1827 |
|
|
1828 |
# saving the history
|
|
1829 |
if(!exists $form->{addition} && $form->{id} ne "") {
|
|
1830 |
$form->{snumbers} = "ordnumber_$form->{ordnumber}";
|
|
1831 |
$form->{addition} = "STORNO";
|
|
1832 |
$form->save_history($form->dbconnect(\%myconfig));
|
|
1833 |
}
|
|
1834 |
# /saving the history
|
|
1835 |
|
|
1836 |
$lxdebug->leave_sub();
|
|
1837 |
|
|
1838 |
}
|
Stornomoeglichkeit fuer Debitorenrechnungen
(plus die ueblichen Codekosmetika)