Merge pull request #2836 from CihanSenturk/Sales-/-Purchases-price-disable-scenario

Scenario of disable sale/purchase price done
This commit is contained in:
Cüneyt Şentürk 2022-12-19 12:38:35 +03:00 committed by GitHub
commit aae36e738b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -88,6 +88,11 @@ class Item extends Model
return $query->where($billing . '_price', '=', null);
}
public function scopePriceType($query, $price_type)
{
return $query->whereNotNull($price_type . '_price');
}
/**
* Get the item id.
*

View File

@ -39,9 +39,10 @@ class ItemButton extends Component
*/
public function render()
{
$items = Item::enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
$price_type = $this->getPriceType($this->type, $this->isSale, $this->isPurchase);
$items = Item::priceType($price_type)->enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
foreach ($items as $item) {
$price = $item->{$price_type . '_price'};

View File

@ -315,7 +315,7 @@ export default {
},
async fetchMatchedItems() {
await window.axios.get(url + '/common/items?search="' + this.search + '" enabled:1 limit:10')
await window.axios.get(url + '/common/items?search="' + this.search + '" not ' + this.price + ':NULL enabled:1 limit:10')
.then(response => {
this.item_list = [];
let items = response.data.data;