Fully added working import and API

This commit is contained in:
Finn 2019-07-10 17:23:27 +01:00
parent aa2d429403
commit efbf8cbad7
No known key found for this signature in database
GPG key ID: 7455B4B17685B598
3 changed files with 34 additions and 22 deletions

View file

@ -27,15 +27,17 @@ sub _row_to_result {
my $address = ( defined $addr2 ? ( $row->{"address line 2"} . ' ' . $addr2) : $row->{"address line 2"} );
$self->external_result->find_or_create_related('organisations', {
external_id => $row->{supplier_id},
return if $self->external_result->organisations->find({external_id => $row->{supplier_id}});
$self->schema->resultset('Entity')->create({
type => 'organisation',
organisation => {
name => $row->{name},
street_name => $row->{"address line 1"},
town => $address,
postcode => $row->{post_code},
country => $row->{country_code},
entity => { type => 'organisation' },
external_reference => [ { external_reference => $self->external_result, external_id => $row->{supplier_id} } ],
}
});
}