Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 773a129c

Von Kivitendo Admin vor fast 8 Jahren hinzugefügt

  • ID 773a129cb1e50ee50265fda01718f241b052c235
  • Vorgänger 828e417c
  • Nachfolger 483bca58

Part Csv Import - Preisgruppenpreisimport testen

Unterschiede anzeigen:

t/controllers/csvimport/parts.t
1
use Test::More tests => 43;
1
use Test::More tests => 47;
2 2

  
3 3
use strict;
4 4

  
......
21 21
use SL::DB::Customer;
22 22
use SL::DB::Language;
23 23
use SL::DB::Warehouse;
24
use SL::DB::Pricegroup;
25
use SL::DB::Price;
24 26
use SL::DB::Bin;
25 27

  
26 28
my ($translation, $bin1_1, $bin1_2, $bin2_1, $bin2_2, $wh1, $wh2, $bugru, $cvarconfig );
29
my ($pg1_id, $pg2_id, $pg3_id);
27 30

  
28 31
Support::TestSetup::login();
29 32

  
......
77 80
    includeable => 0,
78 81
    included_by_default => 0,
79 82
  )->save;
83

  
84
  foreach ( { id => 1, pricegroup => 'A', sortkey => 1 },
85
            { id => 2, pricegroup => 'B', sortkey => 2 },
86
            { id => 3, pricegroup => 'C', sortkey => 3 },
87
            { id => 4, pricegroup => 'D', sortkey => 4 } ) {
88
    SL::DB::Pricegroup->new(%{$_})->save;
89
  }
80 90
}
81 91

  
82 92
$bugru = SL::DB::Manager::Buchungsgruppe->find_by(description => { like => 'Standard%19%' });
......
178 188
#   die Dumper($entry->{errors});
179 189

  
180 190

  
181
##### create part
191
##### create part with prices and 3 pricegroup prices
182 192
$file = \<<EOL;
183
partnumber;sellprice;lastcost;listprice;unit
184
P1000;100.10;90.20;95.30;kg
193
partnumber;sellprice;lastcost;listprice;unit;pricegroup_1;pricegroup_2;pricegroup_3
194
P1000;100.10;90.20;95.30;kg;111.11;122.22;133.33
185 195
EOL
186 196
$entries = test_import($file,$settings1);
187 197
$entry = $entries->[0];
......
192 202
is $entry->{object}->sellprice, '100.1', 'sellprice';
193 203
is $entry->{object}->lastcost,   '90.2', 'lastcost';
194 204
is $entry->{object}->listprice,  '95.3', 'listprice';
205
is $entry->{object}->find_prices( { pricegroup_id => 2 } )->[0]->price,  '122.22000', 'pricegroup_2 price';
195 206

  
196
##### update prices of part
207
##### update prices of part, and price of pricegroup_2, keeping pricegroup_1 and pricegroup_3
197 208
$file = \<<EOL;
198
partnumber;sellprice;lastcost;listprice;unit
199
P1000;110.10;95.20;97.30;kg
209
partnumber;sellprice;lastcost;listprice;unit;pricegroup_2;pricegroup_4
210
P1000;110.10;95.20;97.30;kg;123.45;144.44
200 211
EOL
201 212
$entries = test_import($file,$settings1);
202 213
$entry = $entries->[0];
203 214
is $entry->{object}->sellprice, '110.1', 'updated sellprice';
204 215
is $entry->{object}->lastcost,   '95.2', 'updated lastcost';
205 216
is $entry->{object}->listprice,  '97.3', 'updated listprice';
217
# $entry->{object}->prices currently only contains prices pricegroup_2 and pricegroup_4, reload object from db
218
# printf("%s %s: %s\n", $_->pricegroup_id, $_->pricegroup->pricegroup, $_->price) foreach @{$entry->{object}->prices};
219
$entry->{object}->load;
220
is $entry->{object}->find_prices( { pricegroup_id => 1 } )->[0]->price,  '111.11000', 'pricegroup_1 price didn\'t change';
221
is $entry->{object}->find_prices( { pricegroup_id => 2 } )->[0]->price,  '123.45000', 'pricegroup_2 price was updated';
222
is $entry->{object}->find_prices( { pricegroup_id => 4 } )->[0]->price,  '144.44000', 'pricegroup_4 price was added';
206 223

  
207 224
##### insert parts with warehouse,bin name
208 225

  
......
317 334

  
318 335
sub clear_up {
319 336
  SL::DB::Manager::Part       ->delete_all(all => 1);
337
  SL::DB::Manager::Pricegroup ->delete_all(all => 1);
338
  SL::DB::Manager::Price      ->delete_all(all => 1);
320 339
  SL::DB::Manager::Translation->delete_all(all => 1);
321 340
  SL::DB::Manager::Language   ->delete_all(all => 1);
322 341
  SL::DB::Manager::Bin        ->delete_all(all => 1);

Auch abrufbar als: Unified diff