Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0ff29f06

Von Kivitendo Admin vor mehr als 7 Jahren hinzugefügt

  • ID 0ff29f0620d5dd02242682778d8ea15b030da3e8
  • Vorgänger 25112bf2
  • Nachfolger 47ee7483

t/db_helper/price_tax_calculator.t mit SL::Dev refactored

Unterschiede anzeigen:

t/db_helper/price_tax_calculator.t
10 10
use List::MoreUtils qw(uniq);
11 11
use Support::TestSetup;
12 12
use Test::Exception;
13
use SL::Dev::ALL;
13 14

  
14 15
use SL::DB::Buchungsgruppe;
15 16
use SL::DB::Currency;
......
22 23
use SL::DB::Unit;
23 24
use SL::DB::TaxZone;
24 25

  
25
my ($customer, $currency_id, @parts, $buchungsgruppe, $buchungsgruppe7, $unit, $employee, $tax, $tax7, $taxzone);
26
my ($customer, @parts, $buchungsgruppe, $buchungsgruppe7, $unit, $employee, $tax, $tax7, $taxzone);
26 27

  
27 28
sub clear_up {
28 29
  SL::DB::Manager::Order->delete_all(all => 1);
29 30
  SL::DB::Manager::DeliveryOrder->delete_all(all => 1);
31
  SL::DB::Manager::InvoiceItem->delete_all(all => 1);
30 32
  SL::DB::Manager::Invoice->delete_all(all => 1);
31 33
  SL::DB::Manager::Part->delete_all(all => 1);
32 34
  SL::DB::Manager::Customer->delete_all(all => 1);
......
47 49
  $tax7            = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07)                                              || croak "No tax for 7\%";
48 50
  $taxzone         = SL::DB::Manager::TaxZone->find_by( description => 'Inland')                                           || croak "No taxzone";
49 51

  
50
  $currency_id     = $::instance_conf->get_currency_id;
51

  
52
  $customer     = SL::DB::Customer->new(
52
  $customer     = SL::Dev::CustomerVendor::create_customer(
53 53
    name        => 'Test Customer',
54
    currency_id => $currency_id,
55 54
    taxzone_id  => $taxzone->id,
56 55
    %{ $params{customer} }
57 56
  )->save;
58 57

  
59 58
  @parts = ();
60
  push @parts, SL::DB::Part->new(
59
  push @parts, SL::Dev::Part::create_part(
61 60
    partnumber         => 'T4254',
62 61
    description        => 'Fourty-two fifty-four',
63 62
    lastcost           => 1.93,
64 63
    sellprice          => 2.34,
65
    part_type          => 'part',
66 64
    buchungsgruppen_id => $buchungsgruppe->id,
67 65
    unit               => $unit->name,
68 66
    %{ $params{part1} }
69 67
  )->save;
70 68

  
71
  push @parts, SL::DB::Part->new(
69
  push @parts, SL::Dev::Part::create_part(
72 70
    partnumber         => 'T0815',
73 71
    description        => 'Zero EIGHT fifteeN @ 7%',
74 72
    lastcost           => 5.473,
75 73
    sellprice          => 9.714,
76
    part_type          => 'part',
77 74
    buchungsgruppen_id => $buchungsgruppe7->id,
78 75
    unit               => $unit->name,
79 76
    %{ $params{part2} }
80 77
  )->save;
81 78

  
82
  push @parts, SL::DB::Part->new(
79
  push @parts, SL::Dev::Part::create_part(
83 80
    partnumber         => 'T888',
84 81
    description        => 'Triple 8',
85 82
    lastcost           => 0,
86 83
    sellprice          => 0.6,
87
    part_type          => 'part',
88 84
    buchungsgruppen_id => $buchungsgruppe->id,
89 85
    unit               => $unit->name,
90 86
    %{ $params{part3} }
......
95 91
sub new_invoice {
96 92
  my %params  = @_;
97 93

  
98
  return SL::DB::Invoice->new(
99
    customer_id => $customer->id,
100
    currency_id => $currency_id,
101
    employee_id => $employee->id,
102
    salesman_id => $employee->id,
103
    gldate      => DateTime->today_local->to_kivitendo,
94
  return SL::Dev::Record::create_sales_invoice(
104 95
    taxzone_id  => $taxzone->id,
105
    transdate   => DateTime->today_local->to_kivitendo,
106
    invoice     => 1,
107
    type        => 'invoice',
108 96
    %params,
109 97
  );
110 98
}
......
114 102

  
115 103
  my $part = delete($params{part}) || $parts[0];
116 104

  
117
  return SL::DB::InvoiceItem->new(
118
    parts_id    => $part->id,
119
    lastcost    => $part->lastcost,
120
    sellprice   => $part->sellprice,
121
    description => $part->description,
122
    unit        => $part->unit,
105
  return SL::Dev::Record::create_invoice_item(
106
    part => $part,
123 107
    %params,
124 108
  );
125 109
}
......
127 111
sub test_default_invoice_one_item_19_tax_not_included() {
128 112
  reset_state();
129 113

  
130
  my $item    = new_item(qty => 2.5);
114
  my $item = new_item(qty => 2.5);
131 115
  my $invoice = new_invoice(
132 116
    taxincluded  => 0,
133 117
    invoiceitems => [ $item ],

Auch abrufbar als: Unified diff