Revision 87b04b66
Von Jan Büren vor fast 3 Jahren hinzugefügt
SL/IS.pm | ||
---|---|---|
796 | 796 |
my $basefactor; |
797 | 797 |
my $baseqty; |
798 | 798 |
|
799 |
if ($form->{type} eq 'invoice_for_advance_payment') { |
|
800 |
$form->{"income_accno_$i"} = SL::DB::Chart->new(id => $::instance_conf->get_advance_payment_clearing_chart_id)->load->accno; |
|
801 |
} |
|
802 |
|
|
803 | 799 |
$form->{"marge_percent_$i"} = $form->parse_amount($myconfig, $form->{"marge_percent_$i"}) * 1; |
804 | 800 |
$form->{"marge_absolut_$i"} = $form->parse_amount($myconfig, $form->{"marge_absolut_$i"}) * 1; |
805 | 801 |
$form->{"lastcost_$i"} = $form->parse_amount($myconfig, $form->{"lastcost_$i"}) * 1; |
... | ... | |
1034 | 1030 |
} |
1035 | 1031 |
} |
1036 | 1032 |
|
1037 |
if ($form->{type} eq 'invoice_for_advance_payment') { |
|
1038 |
# invoice for advance payment show tax but does not account it. |
|
1039 |
# tax has to be accounted on payment |
|
1040 |
foreach my $item (split(/ /, $form->{taxaccounts})) { |
|
1041 |
delete $form->{amount}{ $form->{id} }{$item}; |
|
1042 |
} |
|
1043 |
|
|
1044 |
$tax = 0; |
|
1045 |
} |
|
1046 |
|
|
1047 | 1033 |
# Invoice Summary includes Rounding |
1048 | 1034 |
my $grossamount = $netamount + $tax; |
1049 | 1035 |
my $rounding = $form->round_amount( |
... | ... | |
1073 | 1059 |
# entsprechend auch beim Bestimmen des Steuerschlüssels in Taxkey.pm berücksichtigen |
1074 | 1060 |
my $taxdate = $form->{tax_point} ||$form->{deliverydate} || $form->{invdate}; |
1075 | 1061 |
|
1062 |
# better type? maybe define Invoice->invoice_type |
|
1063 |
if ($form->{type} ne 'invoice_for_advance_payment') { |
|
1064 |
my $invoices_for_advance_payment = $self->_get_invoices_for_advance_payment($form->{convert_from_ar_ids} || $form->{id}); |
|
1065 |
if (scalar @$invoices_for_advance_payment > 0) { |
|
1066 |
# reverse booking for invoices for advance payment |
|
1067 |
my $clearing_chart = SL::DB::Chart->new(id => $::instance_conf->get_advance_payment_clearing_chart_id)->load; |
|
1068 |
die "No Clearing Chart for Advance Payment" unless ref $clearing_chart eq 'SL::DB::Chart'; |
|
1069 |
foreach my $invoice_for_advance_payment (@$invoices_for_advance_payment) { |
|
1070 |
# delete ? post twice case ? |
|
1071 |
# TODO: helper table acc_trans_advance_payment |
|
1072 |
# trans_id for final invoice connects to acc_trans_id here |
|
1073 |
# my $booking = SL::DB::AccTrans->new( ...) |
|
1074 |
# TODO: If final_invoice change (delete storno) delete all connectin acc_trans entries, if |
|
1075 |
# period is not closed |
|
1076 |
# $booking->id, $self->id in helper table |
|
1077 |
$form->{amount}->{$invoice_for_advance_payment->id}->{$clearing_chart->accno} = -1 * $invoice_for_advance_payment->netamount; |
|
1078 |
$form->{memo} ->{$invoice_for_advance_payment->id}->{$clearing_chart->accno} = 'reverse booking by final invoice'; |
|
1079 |
# AR |
|
1080 |
$form->{amount}->{$invoice_for_advance_payment->id}->{$form->{AR}} = $invoice_for_advance_payment->netamount; |
|
1081 |
$form->{memo} ->{$invoice_for_advance_payment->id}->{$form->{AR}} = 'reverse booking by final invoice'; |
|
1082 |
} |
|
1083 |
} |
|
1084 |
} |
|
1085 |
if ($form->{type} eq 'invoice_for_advance_payment') { |
|
1086 |
# sanity and decomplex, allow only one tax rate |
|
1087 |
my $clearing_chart = SL::DB::Chart->new(id => $::instance_conf->get_advance_payment_clearing_chart_id)->load; |
|
1088 |
die "No Clearing Chart for Advance Payment" unless ref $clearing_chart eq 'SL::DB::Chart'; |
|
1076 | 1089 |
|
1077 |
# reverse booking for invoices for advance payment
|
|
1078 |
my $invoices_for_advance_payment = $self->_get_invoices_for_advance_payment($form->{convert_from_ar_ids} || $form->{id});
|
|
1079 |
foreach my $invoice_for_advance_payment (@$invoices_for_advance_payment) { |
|
1080 |
my $transactions = SL::DB::Manager::AccTransaction->get_all(query => [ trans_id => $invoice_for_advance_payment->id ], sort_by => 'acc_trans_id ASC');
|
|
1081 |
foreach my $transaction (@$transactions) {
|
|
1082 |
$form->{amount}->{$invoice_for_advance_payment->id}->{$transaction->chart->accno} = -1 * $transaction->amount;
|
|
1083 |
$form->{memo} ->{$invoice_for_advance_payment->id}->{$transaction->chart->accno} = 'reverse booking by final invoice';
|
|
1090 |
my @current_taxaccounts = (split(/ /, $form->{taxaccounts}));
|
|
1091 |
die 'Wrong Call, cannot post invoice for advance payment with more than one tax' if (scalar @current_taxaccounts > 1);
|
|
1092 |
|
|
1093 |
my @trans_ids = keys %{ $form->{amount} };
|
|
1094 |
if (scalar @trans_ids > 1) {
|
|
1095 |
require Data::Dumper;
|
|
1096 |
die "Invalid state for advance payment more than one trans_id " . Dumper($form->{amount});
|
|
1084 | 1097 |
} |
1098 |
|
|
1099 |
# get gross and move to clearing chart - delete everything else |
|
1100 |
# 1. gross |
|
1101 |
my $gross = $form->{amount}{$trans_ids[0]}{$form->{AR}}; |
|
1102 |
# 2. destroy |
|
1103 |
undef $form->{amount}{$trans_ids[0]}; |
|
1104 |
# 3. rebuild |
|
1105 |
$form->{amount}{$trans_ids[0]}{$form->{AR}} = $gross; |
|
1106 |
$form->{amount}{$trans_ids[0]}{$clearing_chart->accno} = $gross * -1; |
|
1107 |
# 4. no cogs, hopefully not commonly used at all |
|
1108 |
undef $form->{amount_cogs}; |
|
1085 | 1109 |
} |
1086 | 1110 |
|
1087 | 1111 |
foreach my $trans_id (keys %{ $form->{amount_cogs} }) { |
Auch abrufbar als: Unified diff
Anzahlungsrechnung: Nur eine Mehrwertsteuer erlauben. Rückbuchungen nur Netto