added search on supplier listings
This commit is contained in:
parent
eabc4e04fb
commit
653f495a70
3 changed files with 31 additions and 0 deletions
10
README.md
10
README.md
|
@ -59,6 +59,16 @@ To import ward data, get the ward data csv and then run the following command:
|
|||
--args '[ "/path/to/ward/csv" ]'
|
||||
```
|
||||
|
||||
# Setting up Entity Postcodes
|
||||
|
||||
Assuming you have imported codepoint open, then to properly assign all
|
||||
postcodes:
|
||||
|
||||
```shell script
|
||||
./script/pear-local_loop minion job \
|
||||
--enqueue entity_postcode_lookup
|
||||
```
|
||||
|
||||
## Example PostgreSQL setup
|
||||
|
||||
```
|
||||
|
|
|
@ -64,6 +64,7 @@ sub post_lcc_suppliers {
|
|||
$v->optional('page')->number;
|
||||
$v->optional('sort_by');
|
||||
$v->optional('sort_dir');
|
||||
$v->optional('search');
|
||||
|
||||
my $order_by = [
|
||||
{ -asc => 'organisation.name' },
|
||||
|
@ -85,6 +86,12 @@ sub post_lcc_suppliers {
|
|||
my $lcc_suppliers = $c->schema->resultset('Entity')->search(
|
||||
{
|
||||
'sales.buyer_id' => $user->entity->id,
|
||||
( $v->param('search') ? (
|
||||
'-or' => [
|
||||
{ 'organisation.name' => { 'like' => $v->param('search') . '%' } },
|
||||
{ 'organisation.postcode' => { 'like' => $v->param('search') . '%' } },
|
||||
]
|
||||
) : () ),
|
||||
},
|
||||
{
|
||||
join => [ 'sales', 'organisation' ],
|
||||
|
|
|
@ -23,4 +23,18 @@ SELECT "value",
|
|||
FROM "transactions"
|
||||
/);
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
"buyer",
|
||||
"Pear::LocalLoop::Schema::Result::Entity",
|
||||
{ id => "buyer_id" },
|
||||
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
|
||||
);
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
"seller",
|
||||
"Pear::LocalLoop::Schema::Result::Entity",
|
||||
{ id => "seller_id" },
|
||||
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
|
||||
);
|
||||
|
||||
1;
|
||||
|
|
Reference in a new issue