Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0b36b225

Von Moritz Bunkus vor etwa 4 Jahren hinzugefügt

  • ID 0b36b2259c1300ee5360a9c8d5aee1f321abd364
  • Vorgänger 0882a283
  • Nachfolger 142ea3bf

Einkauf/Verkauf: Feld »Leistungsdatum« für Steuerberechnung

Unterschiede anzeigen:

SL/DB/Helper/PriceTaxCalculator.pm
54 54
  $self->netamount(  0);
55 55
  $self->marge_total(0);
56 56

  
57
  SL::DB::Manager::Chart->cache_taxkeys(date => $self->deliverydate // $self->transdate);
57
  SL::DB::Manager::Chart->cache_taxkeys(date => $self->effective_tax_point);
58 58

  
59 59
  my $idx = 0;
60 60
  foreach my $item (@{ $self->items_sorted }) {
......
110 110

  
111 111
  $data->{invoicediff} += $sellprice * (1 - $item->discount) * $item->qty * $data->{exchangerate} / $item->price_factor - $linetotal if $self->taxincluded;
112 112

  
113
  my $taxkey     = $part->get_taxkey(date => $self->deliverydate // $self->transdate, is_sales => $data->{is_sales}, taxzone => $self->taxzone_id);
113
  my $taxkey     = $part->get_taxkey(date => $self->effective_tax_point, is_sales => $data->{is_sales}, taxzone => $self->taxzone_id);
114 114
  my $tax_rate   = $taxkey->tax->rate;
115 115
  my $tax_amount = undef;
116 116

  
SL/DB/Invoice.pm
609 609
  $self->update_attributes(paid => $self->amount);
610 610
}
611 611

  
612
sub effective_tax_point {
613
  my ($self) = @_;
614

  
615
  return $self->tax_point || $self->deliverydate || $self->transdate;
616
}
617

  
612 618
1;
613 619

  
614 620
__END__
SL/DB/MetaSetup/Invoice.pm
51 51
  shipvia                   => { type => 'text' },
52 52
  storno                    => { type => 'boolean', default => 'false' },
53 53
  storno_id                 => { type => 'integer' },
54
  tax_point                 => { type => 'date' },
54 55
  taxincluded               => { type => 'boolean' },
55 56
  taxzone_id                => { type => 'integer', not_null => 1 },
56 57
  transaction_description   => { type => 'text' },
SL/DB/MetaSetup/Order.pm
44 44
  shippingpoint           => { type => 'text' },
45 45
  shipto_id               => { type => 'integer' },
46 46
  shipvia                 => { type => 'text' },
47
  tax_point               => { type => 'date' },
47 48
  taxincluded             => { type => 'boolean' },
48 49
  taxzone_id              => { type => 'integer', not_null => 1 },
49 50
  transaction_description => { type => 'text' },
SL/DB/MetaSetup/PurchaseInvoice.pm
39 39
  shipvia                 => { type => 'text' },
40 40
  storno                  => { type => 'boolean', default => 'false' },
41 41
  storno_id               => { type => 'integer' },
42
  tax_point               => { type => 'date' },
42 43
  taxincluded             => { type => 'boolean', default => 'false' },
43 44
  taxzone_id              => { type => 'integer', not_null => 1 },
44 45
  transaction_description => { type => 'text' },
SL/DB/Order.pm
144 144
  return shift->transdate;
145 145
}
146 146

  
147
sub effective_tax_point {
148
  my ($self) = @_;
149

  
150
  return $self->tax_point || $self->transdate;
151
}
152

  
147 153
sub displayable_type {
148 154
  my $type = shift->type;
149 155

  
SL/DB/PurchaseInvoice.pm
214 214
  $self->update_attributes(paid => $self->amount);
215 215
}
216 216

  
217
sub effective_tax_point {
218
  my ($self) = @_;
219

  
220
  return $self->tax_point || $self->deliverydate || $self->transdate;
221
}
222

  
217 223
1;
218 224

  
219 225

  
SL/Form.pm
3229 3229

  
3230 3230
  # Format dates.
3231 3231
  $self->format_dates($output_dateformat, $output_longdates,
3232
                      qw(invdate orddate quodate pldate duedate reqdate transdate shippingdate deliverydate validitydate paymentdate datepaid
3232
                      qw(invdate orddate quodate pldate duedate reqdate transdate tax_point shippingdate deliverydate validitydate paymentdate datepaid
3233 3233
                         transdate_oe deliverydate_oe employee_startdate employee_enddate),
3234 3234
                      grep({ /^(?:datepaid|transdate_oe|reqdate|deliverydate|deliverydate_oe|transdate)_\d+$/ } keys(%{$self})));
3235 3235

  
SL/IC.pm
739 739

  
740 740
  # transdate madness.
741 741
  my $transdate = "";
742
  if ($form->{type} eq "invoice" or $form->{type} eq "credit_note") {
742
  if (($form->{type} eq "invoice") or ($form->{type} eq "credit_note") or ($form->{script} eq 'ir.pl')) {
743 743
    # use deliverydate for sales and purchase invoice, if it exists
744 744
    # also use deliverydate for credit notes
745
    if (!$form->{deliverydate}) {
746
      $transdate = $form->{invdate};
747
    } else {
748
      $transdate = $form->{deliverydate};
749
    }
750
  } elsif ($form->{script} eq 'ir.pl') {
751
    # when a purchase invoice is opened from the report of purchase invoices
752
    # $form->{type} isn't set, but $form->{script} is, not sure why this is or
753
    # whether this distinction matters in some other scenario. Otherwise one
754
    # could probably take out this elsif and add a
755
    # " or $form->{script} eq 'ir.pl' "
756
    # to the above if-statement
757
    if (!$form->{deliverydate}) {
758
      $transdate = $form->{invdate};
759
    } else {
760
      $transdate = $form->{deliverydate};
761
    }
762
  } elsif (($form->{type} eq "credit_note") and $form->{deliverydate}) {
763
    # if credit_note has a deliverydate, use this instead of invdate
764
    # useful for credit_notes of invoices from an old period with different tax
765
    # if there is no deliverydate then invdate is used, old default (see next elsif)
766
    # Falls hier der Stichtag für Steuern anders bestimmt wird,
767
    # entsprechend auch bei Taxkeys.pm anpassen
768
    $transdate = $form->{deliverydate};
769
  } elsif (($form->{type} eq "credit_note") || ($form->{script} eq 'ir.pl')) {
770
    $transdate = $form->{invdate};
745
    $transdate = $form->{tax_point} || $form->{deliverydate} || $form->{invdate};
771 746
  } else {
772
    $transdate = $form->{transdate};
747
    $transdate = $form->{tax_point} || $form->{transdate};
773 748
  }
774 749

  
775 750
  if ($transdate eq "") {
SL/IR.pm
549 549
    if ($form->{currency} ne $defaultcurrency) && !$exchangerate;
550 550

  
551 551
# record acc_trans transactions
552
  my $taxdate = $form->{deliverydate} ? $form->{deliverydate} : $form->{invdate};
552
  my $taxdate = $form->{tax_point} || $form->{deliverydate} || $form->{invdate};
553 553
  foreach my $trans_id (keys %{ $form->{amount} }) {
554 554
    foreach my $accno (keys %{ $form->{amount}{$trans_id} }) {
555 555
      $form->{amount}{$trans_id}{$accno} = $form->round_amount($form->{amount}{$trans_id}{$accno}, 2);
......
735 735
                orddate      = ?, quodate     = ?, vendor_id     = ?, amount       = ?,
736 736
                netamount    = ?, paid        = ?, duedate       = ?, deliverydate = ?,
737 737
                invoice      = ?, taxzone_id  = ?, notes         = ?, taxincluded  = ?,
738
                intnotes     = ?, storno_id   = ?, storno        = ?,
738
                intnotes     = ?, storno_id   = ?, storno        = ?, tax_point    = ?,
739 739
                cp_id        = ?, employee_id = ?, department_id = ?, delivery_term_id = ?,
740 740
                payment_id   = ?,
741 741
                currency_id = (SELECT id FROM currencies WHERE name = ?),
......
746 746
      conv_date($form->{orddate}), conv_date($form->{quodate}),     conv_i($form->{vendor_id}),               $amount,
747 747
                $netamount,                  $form->{paid},        conv_date($form->{duedate}),     conv_date($form->{deliverydate}),
748 748
            '1',                             $taxzone_id, $restricter->process($form->{notes}),               $form->{taxincluded} ? 't' : 'f',
749
                $form->{intnotes},           conv_i($form->{storno_id}),     $form->{storno}      ? 't' : 'f',
749
                $form->{intnotes},           conv_i($form->{storno_id}),     $form->{storno}      ? 't' : 'f', conv_date($form->{tax_point}),
750 750
         conv_i($form->{cp_id}),      conv_i($form->{employee_id}), conv_i($form->{department_id}), conv_i($form->{delivery_term_id}),
751 751
         conv_i($form->{payment_id}),
752 752
                $form->{"currency"},
......
1002 1002

  
1003 1003
  # retrieve invoice
1004 1004
  $query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate,
1005
                orddate, quodate, deliverydate, globalproject_id,
1005
                orddate, quodate, deliverydate, tax_point, globalproject_id,
1006 1006
                ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate,
1007 1007
                mtime, itime,
1008 1008
                intnotes, (SELECT cu.name FROM currencies cu WHERE cu.id=ap.currency_id) AS currency, direct_debit,
......
1022 1022
  delete $ref->{id};
1023 1023
  map { $form->{$_} = $ref->{$_} } keys %$ref;
1024 1024

  
1025
  my $transdate  = $form->{invdate} ? $dbh->quote($form->{invdate}) : "current_date";
1025
  my $transdate  = $form->{tax_point} ? $dbh->quote($form->{tax_point}) :$form->{invdate} ? $dbh->quote($form->{invdate}) : "current_date";
1026 1026

  
1027 1027
  my $taxzone_id = $form->{taxzone_id} * 1;
1028 1028
  $taxzone_id = SL::DB::Manager::TaxZone->get_default->id unless SL::DB::Manager::TaxZone->find_by(id => $taxzone_id);
SL/IS.pm
1037 1037

  
1038 1038
  $project_id = conv_i($form->{"globalproject_id"});
1039 1039
  # entsprechend auch beim Bestimmen des Steuerschlüssels in Taxkey.pm berücksichtigen
1040
  my $taxdate = $form->{deliverydate} ? $form->{deliverydate} : $form->{invdate};
1040
  my $taxdate = $form->{tax_point} ||$form->{deliverydate} || $form->{invdate};
1041 1041

  
1042 1042
  foreach my $trans_id (keys %{ $form->{amount_cogs} }) {
1043 1043
    foreach my $accno (keys %{ $form->{amount_cogs}{$trans_id} }) {
......
1312 1312

  
1313 1313
  $query = qq|UPDATE ar set
1314 1314
                invnumber   = ?, ordnumber     = ?, quonumber     = ?, cusordnumber  = ?,
1315
                transdate   = ?, orddate       = ?, quodate       = ?, customer_id   = ?,
1315
                transdate   = ?, orddate       = ?, quodate       = ?, tax_point     = ?, customer_id   = ?,
1316 1316
                amount      = ?, netamount     = ?, paid          = ?,
1317 1317
                duedate     = ?, deliverydate  = ?, invoice       = ?, shippingpoint = ?,
1318 1318
                shipvia     = ?,                    notes         = ?, intnotes      = ?,
......
1327 1327
                delivery_term_id = ?
1328 1328
              WHERE id = ?|;
1329 1329
  @values = (          $form->{"invnumber"},           $form->{"ordnumber"},             $form->{"quonumber"},          $form->{"cusordnumber"},
1330
             conv_date($form->{"invdate"}),  conv_date($form->{"orddate"}),    conv_date($form->{"quodate"}),    conv_i($form->{"customer_id"}),
1330
             conv_date($form->{"invdate"}),  conv_date($form->{"orddate"}),    conv_date($form->{"quodate"}), conv_date($form->{tax_point}), conv_i($form->{"customer_id"}),
1331 1331
                       $amount,                        $netamount,                       $form->{"paid"},
1332 1332
             conv_date($form->{"duedate"}),  conv_date($form->{"deliverydate"}),    '1',                                $form->{"shippingpoint"},
1333 1333
                       $form->{"shipvia"},                                $restricter->process($form->{"notes"}),       $form->{"intnotes"},
......
2012 2012
      qq|SELECT
2013 2013
           a.invnumber, a.ordnumber, a.quonumber, a.cusordnumber,
2014 2014
           a.orddate, a.quodate, a.globalproject_id,
2015
           a.transdate AS invdate, a.deliverydate, a.paid, a.storno, a.storno_id, a.gldate,
2015
           a.transdate AS invdate, a.deliverydate, a.tax_point, a.paid, a.storno, a.storno_id, a.gldate,
2016 2016
           a.shippingpoint, a.shipvia, a.notes, a.intnotes, a.taxzone_id,
2017 2017
           a.duedate, a.taxincluded, (SELECT cu.name FROM currencies cu WHERE cu.id=a.currency_id) AS currency, a.shipto_id, a.cp_id,
2018 2018
           a.employee_id, a.salesman_id, a.payment_id,
......
2055 2055
    $sth->finish;
2056 2056
    map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued);
2057 2057

  
2058
    my $transdate = $form->{deliverydate} ? $dbh->quote($form->{deliverydate})
2058
    my $transdate = $form->{tax_point}    ? $dbh->quote($form->{tax_point})
2059
                  : $form->{deliverydate} ? $dbh->quote($form->{deliverydate})
2059 2060
                  : $form->{invdate}      ? $dbh->quote($form->{invdate})
2060 2061
                  :                         "current_date";
2061 2062

  
SL/OE.pm
743 743
  $query =
744 744
    qq|UPDATE oe SET
745 745
         ordnumber = ?, quonumber = ?, cusordnumber = ?, transdate = ?, vendor_id = ?,
746
         customer_id = ?, amount = ?, netamount = ?, reqdate = ?, taxincluded = ?,
746
         customer_id = ?, amount = ?, netamount = ?, reqdate = ?, tax_point = ?, taxincluded = ?,
747 747
         shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, currency_id = (SELECT id FROM currencies WHERE name=?), closed = ?,
748 748
         delivered = ?, proforma = ?, quotation = ?, department_id = ?, language_id = ?,
749 749
         taxzone_id = ?, shipto_id = ?, payment_id = ?, delivery_vendor_id = ?, delivery_customer_id = ?,delivery_term_id = ?,
......
754 754
  @values = ($form->{ordnumber} || '', $form->{quonumber},
755 755
             $form->{cusordnumber}, conv_date($form->{transdate}),
756 756
             conv_i($form->{vendor_id}), conv_i($form->{customer_id}),
757
             $amount, $netamount, conv_date($reqdate),
757
             $amount, $netamount, conv_date($reqdate), conv_date($form->{tax_point}),
758 758
             $form->{taxincluded} ? 't' : 'f', $form->{shippingpoint},
759 759
             $form->{shipvia}, $restricter->process($form->{notes}), $form->{intnotes},
760 760
             $form->{currency}, $form->{closed} ? 't' : 'f',
......
1017 1017
           o.taxincluded, o.shippingpoint, o.shipvia, o.notes, o.intnotes,
1018 1018
           (SELECT cu.name FROM currencies cu WHERE cu.id=o.currency_id) AS currency, e.name AS employee, o.employee_id, o.salesman_id,
1019 1019
           o.${vc}_id, cv.name AS ${vc}, o.amount AS invtotal,
1020
           o.closed, o.reqdate, o.quonumber, o.department_id, o.cusordnumber,
1020
           o.closed, o.reqdate, o.tax_point, o.quonumber, o.department_id, o.cusordnumber,
1021 1021
           o.mtime, o.itime,
1022 1022
           d.description AS department, o.payment_id, o.language_id, o.taxzone_id,
1023 1023
           o.delivery_customer_id, o.delivery_vendor_id, o.proforma, o.shipto_id,
......
1096 1096
      map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued);
1097 1097
    }    # if !@ids
1098 1098

  
1099
    my $transdate = $form->{transdate} ? $dbh->quote($form->{transdate}) : "current_date";
1099
    my $transdate = $form->{tax_point} ? $dbh->quote($form->{tax_point}) : $form->{transdate} ? $dbh->quote($form->{transdate}) : "current_date";
1100 1100

  
1101 1101
    $form->{taxzone_id} = 0 unless ($form->{taxzone_id});
1102 1102
    unshift @values, ($form->{taxzone_id}) x 2;
bin/mozilla/io.pl
1409 1409

  
1410 1410
  # Format dates.
1411 1411
  format_dates($output_dateformat, $output_longdates,
1412
               qw(invdate orddate quodate pldate duedate reqdate transdate
1412
               qw(invdate orddate quodate pldate duedate reqdate transdate tax_point
1413 1413
                  shippingdate deliverydate validitydate paymentdate
1414 1414
                  datepaid transdate_oe transdate_do transdate_quo deliverydate_oe dodate
1415 1415
                  employee_startdate employee_enddate
locale/de/all
3177 3177
  'Tax deleted!'                => 'Steuer gelöscht!',
3178 3178
  'Tax number'                  => 'Steuernummer',
3179 3179
  'Tax paid'                    => 'Vorsteuer',
3180
  'Tax point'                   => 'Leistungsdatum',
3180 3181
  'Tax rate'                    => 'Steuersatz',
3181 3182
  'Tax saved!'                  => 'Steuer gespeichert!',
3182 3183
  'Tax zone'                    => 'Steuerzone',
sql/Pg-upgrade2/tax_point.sql
1
-- @tag: tax_point
2
-- @description: Feld Leistungsdatum in Einkaufs- & Verkaufsbelegen
3
-- @depends: release_3_5_6_1
4
ALTER TABLE ap ADD COLUMN tax_point DATE;
5
ALTER TABLE ar ADD COLUMN tax_point DATE;
6
ALTER TABLE oe ADD COLUMN tax_point DATE;
templates/webpages/ir/form_header.html
154 154
           <span id="duedate_fixed"[% IF !payment_terms_obj.auto_calculation %] style="display:none"[% END %]>[% HTML.escape(duedate) %]</span>
155 155
          </td>
156 156
        </tr>
157
        <tr>
158
          <th align="right" nowrap>[% LxERP.t8('Tax point') %]</th>
159
          <td nowrap>[% L.date_tag('tax_point', tax_point, id='tax_point') %]</td>
160
        </tr>
157 161
        <tr>
158 162
          <th align="right">[% 'Delivery Date' | $T8 %]</th>
159 163
          <td>[% L.date_tag('deliverydate', deliverydate) %]</td>
templates/webpages/is/form_header.html
238 238
           <span id="duedate_fixed"[% IF !payment_terms_obj.auto_calculation %] style="display:none"[% END %]>[% HTML.escape(duedate) %]</span>
239 239
          </td>
240 240
        </tr>
241
[%- END %]
242
        <tr>
243
          <th align="right" nowrap>[% LxERP.t8('Tax point') %]</th>
244
          <td nowrap>[% L.date_tag('tax_point', tax_point, id='tax_point') %]</td>
245
        </tr>
246
[%- IF !is_type_credit_note %]
241 247
        <tr>
242
        <th align="right" nowrap>[% 'Delivery Order Number' | $T8 %]</th>
248
          <th align="right" nowrap>[% 'Delivery Order Number' | $T8 %]</th>
243 249
          <td colspan="3"><input size='11' name="donumber" id="donumber" value="[% HTML.escape(donumber) %]"></td>
244 250
        </tr>
245 251
[%- END %]
templates/webpages/oe/form_header.html
225 225
                      [% L.date_tag('transdate', transdate, id='transdate') %]
226 226
                    </td>
227 227
                  </tr>
228
                  <tr>
229
                    <th align="right" nowrap>[% LxERP.t8('Tax point') %]</th>
230
                    <td nowrap>[% L.date_tag('tax_point', tax_point, id='tax_point') %]</td>
231
                  </tr>
228 232
                  <tr>
229 233
                    <th align="right" nowrap>
230 234
                     [%- IF is_sales_quo %]

Auch abrufbar als: Unified diff