$self->netamount( 0);
$self->marge_total(0);
- SL::DB::Manager::Chart->cache_taxkeys(date => $self->deliverydate // $self->transdate);
+ SL::DB::Manager::Chart->cache_taxkeys(date => $self->effective_tax_point);
my $idx = 0;
foreach my $item (@{ $self->items_sorted }) {
$data->{invoicediff} += $sellprice * (1 - $item->discount) * $item->qty * $data->{exchangerate} / $item->price_factor - $linetotal if $self->taxincluded;
- my $taxkey = $part->get_taxkey(date => $self->deliverydate // $self->transdate, is_sales => $data->{is_sales}, taxzone => $self->taxzone_id);
+ my $taxkey = $part->get_taxkey(date => $self->effective_tax_point, is_sales => $data->{is_sales}, taxzone => $self->taxzone_id);
my $tax_rate = $taxkey->tax->rate;
my $tax_amount = undef;
$self->update_attributes(paid => $self->amount);
}
+sub effective_tax_point {
+ my ($self) = @_;
+
+ return $self->tax_point || $self->deliverydate || $self->transdate;
+}
+
1;
__END__
shipvia => { type => 'text' },
storno => { type => 'boolean', default => 'false' },
storno_id => { type => 'integer' },
+ tax_point => { type => 'date' },
taxincluded => { type => 'boolean' },
taxzone_id => { type => 'integer', not_null => 1 },
transaction_description => { type => 'text' },
shippingpoint => { type => 'text' },
shipto_id => { type => 'integer' },
shipvia => { type => 'text' },
+ tax_point => { type => 'date' },
taxincluded => { type => 'boolean' },
taxzone_id => { type => 'integer', not_null => 1 },
transaction_description => { type => 'text' },
shipvia => { type => 'text' },
storno => { type => 'boolean', default => 'false' },
storno_id => { type => 'integer' },
+ tax_point => { type => 'date' },
taxincluded => { type => 'boolean', default => 'false' },
taxzone_id => { type => 'integer', not_null => 1 },
transaction_description => { type => 'text' },
return shift->transdate;
}
+sub effective_tax_point {
+ my ($self) = @_;
+
+ return $self->tax_point || $self->transdate;
+}
+
sub displayable_type {
my $type = shift->type;
$self->update_attributes(paid => $self->amount);
}
+sub effective_tax_point {
+ my ($self) = @_;
+
+ return $self->tax_point || $self->deliverydate || $self->transdate;
+}
+
1;
# Format dates.
$self->format_dates($output_dateformat, $output_longdates,
- qw(invdate orddate quodate pldate duedate reqdate transdate shippingdate deliverydate validitydate paymentdate datepaid
+ qw(invdate orddate quodate pldate duedate reqdate transdate tax_point shippingdate deliverydate validitydate paymentdate datepaid
transdate_oe deliverydate_oe employee_startdate employee_enddate),
grep({ /^(?:datepaid|transdate_oe|reqdate|deliverydate|deliverydate_oe|transdate)_\d+$/ } keys(%{$self})));
# transdate madness.
my $transdate = "";
- if ($form->{type} eq "invoice" or $form->{type} eq "credit_note") {
+ if (($form->{type} eq "invoice") or ($form->{type} eq "credit_note") or ($form->{script} eq 'ir.pl')) {
# use deliverydate for sales and purchase invoice, if it exists
# also use deliverydate for credit notes
- if (!$form->{deliverydate}) {
- $transdate = $form->{invdate};
- } else {
- $transdate = $form->{deliverydate};
- }
- } elsif ($form->{script} eq 'ir.pl') {
- # when a purchase invoice is opened from the report of purchase invoices
- # $form->{type} isn't set, but $form->{script} is, not sure why this is or
- # whether this distinction matters in some other scenario. Otherwise one
- # could probably take out this elsif and add a
- # " or $form->{script} eq 'ir.pl' "
- # to the above if-statement
- if (!$form->{deliverydate}) {
- $transdate = $form->{invdate};
- } else {
- $transdate = $form->{deliverydate};
- }
- } elsif (($form->{type} eq "credit_note") and $form->{deliverydate}) {
- # if credit_note has a deliverydate, use this instead of invdate
- # useful for credit_notes of invoices from an old period with different tax
- # if there is no deliverydate then invdate is used, old default (see next elsif)
- # Falls hier der Stichtag für Steuern anders bestimmt wird,
- # entsprechend auch bei Taxkeys.pm anpassen
- $transdate = $form->{deliverydate};
- } elsif (($form->{type} eq "credit_note") || ($form->{script} eq 'ir.pl')) {
- $transdate = $form->{invdate};
+ $transdate = $form->{tax_point} || $form->{deliverydate} || $form->{invdate};
} else {
- $transdate = $form->{transdate};
+ $transdate = $form->{tax_point} || $form->{transdate};
}
if ($transdate eq "") {
if ($form->{currency} ne $defaultcurrency) && !$exchangerate;
# record acc_trans transactions
- my $taxdate = $form->{deliverydate} ? $form->{deliverydate} : $form->{invdate};
+ my $taxdate = $form->{tax_point} || $form->{deliverydate} || $form->{invdate};
foreach my $trans_id (keys %{ $form->{amount} }) {
foreach my $accno (keys %{ $form->{amount}{$trans_id} }) {
$form->{amount}{$trans_id}{$accno} = $form->round_amount($form->{amount}{$trans_id}{$accno}, 2);
orddate = ?, quodate = ?, vendor_id = ?, amount = ?,
netamount = ?, paid = ?, duedate = ?, deliverydate = ?,
invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?,
- intnotes = ?, storno_id = ?, storno = ?,
+ intnotes = ?, storno_id = ?, storno = ?, tax_point = ?,
cp_id = ?, employee_id = ?, department_id = ?, delivery_term_id = ?,
payment_id = ?,
currency_id = (SELECT id FROM currencies WHERE name = ?),
conv_date($form->{orddate}), conv_date($form->{quodate}), conv_i($form->{vendor_id}), $amount,
$netamount, $form->{paid}, conv_date($form->{duedate}), conv_date($form->{deliverydate}),
'1', $taxzone_id, $restricter->process($form->{notes}), $form->{taxincluded} ? 't' : 'f',
- $form->{intnotes}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f',
+ $form->{intnotes}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f', conv_date($form->{tax_point}),
conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}), conv_i($form->{delivery_term_id}),
conv_i($form->{payment_id}),
$form->{"currency"},
# retrieve invoice
$query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate,
- orddate, quodate, deliverydate, globalproject_id,
+ orddate, quodate, deliverydate, tax_point, globalproject_id,
ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate,
mtime, itime,
intnotes, (SELECT cu.name FROM currencies cu WHERE cu.id=ap.currency_id) AS currency, direct_debit,
delete $ref->{id};
map { $form->{$_} = $ref->{$_} } keys %$ref;
- my $transdate = $form->{invdate} ? $dbh->quote($form->{invdate}) : "current_date";
+ my $transdate = $form->{tax_point} ? $dbh->quote($form->{tax_point}) :$form->{invdate} ? $dbh->quote($form->{invdate}) : "current_date";
my $taxzone_id = $form->{taxzone_id} * 1;
$taxzone_id = SL::DB::Manager::TaxZone->get_default->id unless SL::DB::Manager::TaxZone->find_by(id => $taxzone_id);
$project_id = conv_i($form->{"globalproject_id"});
# entsprechend auch beim Bestimmen des Steuerschlüssels in Taxkey.pm berücksichtigen
- my $taxdate = $form->{deliverydate} ? $form->{deliverydate} : $form->{invdate};
+ my $taxdate = $form->{tax_point} ||$form->{deliverydate} || $form->{invdate};
foreach my $trans_id (keys %{ $form->{amount_cogs} }) {
foreach my $accno (keys %{ $form->{amount_cogs}{$trans_id} }) {
$query = qq|UPDATE ar set
invnumber = ?, ordnumber = ?, quonumber = ?, cusordnumber = ?,
- transdate = ?, orddate = ?, quodate = ?, customer_id = ?,
+ transdate = ?, orddate = ?, quodate = ?, tax_point = ?, customer_id = ?,
amount = ?, netamount = ?, paid = ?,
duedate = ?, deliverydate = ?, invoice = ?, shippingpoint = ?,
shipvia = ?, notes = ?, intnotes = ?,
delivery_term_id = ?
WHERE id = ?|;
@values = ( $form->{"invnumber"}, $form->{"ordnumber"}, $form->{"quonumber"}, $form->{"cusordnumber"},
- conv_date($form->{"invdate"}), conv_date($form->{"orddate"}), conv_date($form->{"quodate"}), conv_i($form->{"customer_id"}),
+ conv_date($form->{"invdate"}), conv_date($form->{"orddate"}), conv_date($form->{"quodate"}), conv_date($form->{tax_point}), conv_i($form->{"customer_id"}),
$amount, $netamount, $form->{"paid"},
conv_date($form->{"duedate"}), conv_date($form->{"deliverydate"}), '1', $form->{"shippingpoint"},
$form->{"shipvia"}, $restricter->process($form->{"notes"}), $form->{"intnotes"},
qq|SELECT
a.invnumber, a.ordnumber, a.quonumber, a.cusordnumber,
a.orddate, a.quodate, a.globalproject_id,
- a.transdate AS invdate, a.deliverydate, a.paid, a.storno, a.storno_id, a.gldate,
+ a.transdate AS invdate, a.deliverydate, a.tax_point, a.paid, a.storno, a.storno_id, a.gldate,
a.shippingpoint, a.shipvia, a.notes, a.intnotes, a.taxzone_id,
a.duedate, a.taxincluded, (SELECT cu.name FROM currencies cu WHERE cu.id=a.currency_id) AS currency, a.shipto_id, a.cp_id,
a.employee_id, a.salesman_id, a.payment_id,
$sth->finish;
map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued);
- my $transdate = $form->{deliverydate} ? $dbh->quote($form->{deliverydate})
+ my $transdate = $form->{tax_point} ? $dbh->quote($form->{tax_point})
+ : $form->{deliverydate} ? $dbh->quote($form->{deliverydate})
: $form->{invdate} ? $dbh->quote($form->{invdate})
: "current_date";
$query =
qq|UPDATE oe SET
ordnumber = ?, quonumber = ?, cusordnumber = ?, transdate = ?, vendor_id = ?,
- customer_id = ?, amount = ?, netamount = ?, reqdate = ?, taxincluded = ?,
+ customer_id = ?, amount = ?, netamount = ?, reqdate = ?, tax_point = ?, taxincluded = ?,
shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, currency_id = (SELECT id FROM currencies WHERE name=?), closed = ?,
delivered = ?, proforma = ?, quotation = ?, department_id = ?, language_id = ?,
taxzone_id = ?, shipto_id = ?, payment_id = ?, delivery_vendor_id = ?, delivery_customer_id = ?,delivery_term_id = ?,
@values = ($form->{ordnumber} || '', $form->{quonumber},
$form->{cusordnumber}, conv_date($form->{transdate}),
conv_i($form->{vendor_id}), conv_i($form->{customer_id}),
- $amount, $netamount, conv_date($reqdate),
+ $amount, $netamount, conv_date($reqdate), conv_date($form->{tax_point}),
$form->{taxincluded} ? 't' : 'f', $form->{shippingpoint},
$form->{shipvia}, $restricter->process($form->{notes}), $form->{intnotes},
$form->{currency}, $form->{closed} ? 't' : 'f',
o.taxincluded, o.shippingpoint, o.shipvia, o.notes, o.intnotes,
(SELECT cu.name FROM currencies cu WHERE cu.id=o.currency_id) AS currency, e.name AS employee, o.employee_id, o.salesman_id,
o.${vc}_id, cv.name AS ${vc}, o.amount AS invtotal,
- o.closed, o.reqdate, o.quonumber, o.department_id, o.cusordnumber,
+ o.closed, o.reqdate, o.tax_point, o.quonumber, o.department_id, o.cusordnumber,
o.mtime, o.itime,
d.description AS department, o.payment_id, o.language_id, o.taxzone_id,
o.delivery_customer_id, o.delivery_vendor_id, o.proforma, o.shipto_id,
map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued);
} # if !@ids
- my $transdate = $form->{transdate} ? $dbh->quote($form->{transdate}) : "current_date";
+ my $transdate = $form->{tax_point} ? $dbh->quote($form->{tax_point}) : $form->{transdate} ? $dbh->quote($form->{transdate}) : "current_date";
$form->{taxzone_id} = 0 unless ($form->{taxzone_id});
unshift @values, ($form->{taxzone_id}) x 2;
# Format dates.
format_dates($output_dateformat, $output_longdates,
- qw(invdate orddate quodate pldate duedate reqdate transdate
+ qw(invdate orddate quodate pldate duedate reqdate transdate tax_point
shippingdate deliverydate validitydate paymentdate
datepaid transdate_oe transdate_do transdate_quo deliverydate_oe dodate
employee_startdate employee_enddate
'Tax deleted!' => 'Steuer gelöscht!',
'Tax number' => 'Steuernummer',
'Tax paid' => 'Vorsteuer',
+ 'Tax point' => 'Leistungsdatum',
'Tax rate' => 'Steuersatz',
'Tax saved!' => 'Steuer gespeichert!',
'Tax zone' => 'Steuerzone',
--- /dev/null
+-- @tag: tax_point
+-- @description: Feld Leistungsdatum in Einkaufs- & Verkaufsbelegen
+-- @depends: release_3_5_6_1
+ALTER TABLE ap ADD COLUMN tax_point DATE;
+ALTER TABLE ar ADD COLUMN tax_point DATE;
+ALTER TABLE oe ADD COLUMN tax_point DATE;
<span id="duedate_fixed"[% IF !payment_terms_obj.auto_calculation %] style="display:none"[% END %]>[% HTML.escape(duedate) %]</span>
</td>
</tr>
+ <tr>
+ <th align="right" nowrap>[% LxERP.t8('Tax point') %]</th>
+ <td nowrap>[% L.date_tag('tax_point', tax_point, id='tax_point') %]</td>
+ </tr>
<tr>
<th align="right">[% 'Delivery Date' | $T8 %]</th>
<td>[% L.date_tag('deliverydate', deliverydate) %]</td>
<span id="duedate_fixed"[% IF !payment_terms_obj.auto_calculation %] style="display:none"[% END %]>[% HTML.escape(duedate) %]</span>
</td>
</tr>
+[%- END %]
+ <tr>
+ <th align="right" nowrap>[% LxERP.t8('Tax point') %]</th>
+ <td nowrap>[% L.date_tag('tax_point', tax_point, id='tax_point') %]</td>
+ </tr>
+[%- IF !is_type_credit_note %]
<tr>
- <th align="right" nowrap>[% 'Delivery Order Number' | $T8 %]</th>
+ <th align="right" nowrap>[% 'Delivery Order Number' | $T8 %]</th>
<td colspan="3"><input size='11' name="donumber" id="donumber" value="[% HTML.escape(donumber) %]"></td>
</tr>
[%- END %]
[% L.date_tag('transdate', transdate, id='transdate') %]
</td>
</tr>
+ <tr>
+ <th align="right" nowrap>[% LxERP.t8('Tax point') %]</th>
+ <td nowrap>[% L.date_tag('tax_point', tax_point, id='tax_point') %]</td>
+ </tr>
<tr>
<th align="right" nowrap>
[%- IF is_sales_quo %]