Skip to content

Commit

Permalink
Merge pull request #4363 from solgenomics/topic/ordering_system_N
Browse files Browse the repository at this point in the history
Make ordering system configurable and add single step submission option
  • Loading branch information
lukasmueller authored Dec 21, 2022
2 parents c004e7d + b74a8be commit bc74731
Show file tree
Hide file tree
Showing 18 changed files with 764 additions and 460 deletions.
32 changes: 19 additions & 13 deletions lib/CXGN/Stock/Catalog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,39 @@ use Data::Dumper;

extends 'CXGN::JSONProp';

# a general human readable description of the stock
has 'description' => ( isa => 'Str', is => 'rw' );

# a list of representative images, given as image_ids
has 'images' => ( isa => 'Maybe[ArrayRef]', is => 'rw' );

# availability status: in_stock, delayed, currently_unavailable ...
has 'availability' => ( isa => 'Str', is => 'rw' );

# list of hashrefs like { stock_center => { name => ..., count_available => ..., delivery_time => } }
has 'order_source' => ( isa => 'ArrayRef', is => 'rw');

# item type such as single accession or a set of 10 accessions
has 'item_type' => ( isa => 'Str', is => 'rw');

# material type such as seed or plant
has 'material_type' => ( isa => 'Str', is => 'rw');

# center that generates clones or seed
has 'material_source' => ( isa => 'Str', is => 'rw');

# item type such as single accession or a set of 10 accessions
has 'item_type' => ( isa => 'Str', is => 'rw');
has 'category' => ( isa => 'Str', is => 'rw' );

has 'species' => ( isa => 'Str', is => 'rw' );

has 'variety' => ( isa => 'Str', is => 'rw', required => 0);

# the breeding program this clones originated from
has 'breeding_program' => ( isa => 'Int', is => 'rw');

#
has 'category' => ( isa => 'Str', is => 'rw' );
has 'additional_info' => ( isa => 'Str', is => 'rw', required => 0 );

has 'contact_person_id' => ( isa => 'Int', is => 'rw') ;

# a general human readable description of the stock
#has 'description' => ( isa => 'Str', is => 'rw' );

# availability status: in_stock, delayed, currently_unavailable ...
#has 'availability' => ( isa => 'Str', is => 'rw' );


sub BUILD {
my $self = shift;
Expand All @@ -42,7 +49,7 @@ sub BUILD {
$self->prop_primary_key('stockprop_id');
$self->prop_type('stock_catalog_json');
$self->cv_name('stock_property');
$self->allowed_fields( [ qw | item_type category description material_source breeding_program availability contact_person_id images | ] );
$self->allowed_fields( [ qw | item_type species variety material_type category material_source additional_info breeding_program contact_person_id images | ] );
$self->parent_table('stock');
$self->parent_primary_key('stock_id');

Expand Down Expand Up @@ -92,7 +99,6 @@ sub get_item_details {
foreach my $field (@fields){
push @item_details, $detail_hash->{$field};
}
# print STDERR "ITEM DETAILS =".Dumper(\@item_details)."\n";

return \@item_details;
}
Expand Down
85 changes: 16 additions & 69 deletions lib/CXGN/Stock/Order.pm
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,23 @@ sub get_orders_from_person_id {
my $order_to_name=$person->get_first_name()." ".$person->get_last_name();

my $orderprop_rs = $people_schema->resultset('SpOrderprop')->search( { sp_order_id => $order_id } );
my $all_items = ();
while (my $item_result = $orderprop_rs->next()){
my @list;
my $item_json = $item_result->value();
my $item_hash = JSON::Any->jsonToObj($item_json);
my $all_items = $item_hash->{'clone_list'};
foreach my $each_item (@$all_items) {
my $item_name = (keys %$each_item)[0];
my $quantity = $each_item->{$item_name}->{'quantity'};
my $comments = $each_item->{$item_name}->{'comments'};
my $additional_info = $each_item->{$item_name}->{'additional_info'};

my $each_item_details;
if ($additional_info && $comments) {
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info. "," . " " . "comments:" . $comments;
} elsif ($additional_info && (!$comments)){
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info;
} elsif ((!$additional_info) && $comments) {
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity . "," . " "."comments:" . $comments;
} else {
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity;
}
push @list, $each_item_details;
}
my @sort_list = sort @list;
$item_list = join("<br>", @sort_list);
$all_items = $item_hash->{'clone_list'};
}

push @orders, [$order_id, $create_date, $item_list, $order_status, $completion_date, $order_to_name, $comments ];
push @orders, {
order_id => $order_id,
create_date => $create_date,
clone_list => $all_items,
order_status => $order_status,
completion_date => $completion_date,
order_to_name => $order_to_name,
comments => $comments
}
}

return \@orders;
Expand All @@ -138,7 +127,6 @@ sub get_orders_to_person_id {
my $item_list;
my $order_id = $result->sp_order_id();
my $order_from_id = $result->order_from_id();
# my $order_to_id = $result->order_to_id();
my $order_status = $result->order_status();
my $create_date = $result->create_date();
my $completion_date = $result->completion_date();
Expand All @@ -147,44 +135,25 @@ sub get_orders_to_person_id {
my $order_from_name=$person->get_first_name()." ".$person->get_last_name();

my $orderprop_rs = $people_schema->resultset('SpOrderprop')->search( { sp_order_id => $order_id } );
my $all_items = ();
while (my $item_result = $orderprop_rs->next()){
my @list;
my $item_json = $item_result->value();
my $item_hash = JSON::Any->jsonToObj($item_json);
my $all_items = $item_hash->{'clone_list'};
foreach my $each_item (@$all_items) {
my $item_name = (keys %$each_item)[0];
my $quantity = $each_item->{$item_name}->{'quantity'};
my $comments = $each_item->{$item_name}->{'comments'};
my $additional_info = $each_item->{$item_name}->{'additional_info'};

my $each_item_details;
if ($additional_info && $comments) {
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info. "," . " " . "comments:" . $comments;
} elsif ($additional_info && (!$comments)){
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info;
} elsif ((!$additional_info) && $comments) {
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity . "," . " "."comments:" . $comments;
} else {
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity;
}
push @list, $each_item_details;
}
my @sort_list = sort @list;
$item_list = join("<br>", @sort_list);
$all_items = $item_hash->{'clone_list'};
}

push @orders, {
order_id => $order_id,
order_from_name => $order_from_name,
create_date => $create_date,
item_list => $item_list,
clone_list => $all_items,
order_status => $order_status,
completion_date => $completion_date,
contact_person_comments => $comments
}
}
# print STDERR "ORDERS =".Dumper(\@orders)."\n";

return \@orders;
}

Expand Down Expand Up @@ -215,30 +184,8 @@ sub get_order_details {
my $item_json = $orderprop_rs->value();
my $item_hash = JSON::Any->jsonToObj($item_json);
my $all_items = $item_hash->{'clone_list'};
my @list;
foreach my $each_item (@$all_items) {
my $item_name = (keys %$each_item)[0];
my $quantity = $each_item->{$item_name}->{'quantity'};
my $comments = $each_item->{$item_name}->{'comments'};
my $additional_info = $each_item->{$item_name}->{'additional_info'};

my $each_item_details;
if ($additional_info && $comments) {
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info. "," . " " . "comments:" . $comments;
} elsif ($additional_info && (!$comments)){
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info;
} elsif ((!$additional_info) && $comments) {
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity . "," . " "."comments:" . $comments;
} else {
$each_item_details = $item_name . "," . " " . "quantity:" . $quantity;
}
push @list, $each_item_details;
}
my @sort_list = sort @list;
my $item_list = join("<br>", @sort_list);

push @order_details, $order_id, $order_from_name, $create_date, $item_list, $order_to_name, $order_status, $comments;
# print STDERR "DETAILS =".Dumper(\@order_details)."\n";
push @order_details, $order_id, $order_from_name, $create_date, $all_items, $order_to_name, $order_status, $comments;

return \@order_details;

Expand Down
Loading

0 comments on commit bc74731

Please sign in to comment.