bill item price issue solved..
This commit is contained in:
parent
db0d424de2
commit
5b7d70fae7
@ -154,6 +154,12 @@ abstract class DocumentForm extends Component
|
||||
|
||||
/** @var bool */
|
||||
public $hideAmount;
|
||||
|
||||
/** @var bool */
|
||||
public $isSalePrice;
|
||||
|
||||
/** @var bool */
|
||||
public $isPurchasePrice;
|
||||
/** Items Component End */
|
||||
|
||||
/**
|
||||
@ -183,7 +189,8 @@ abstract class DocumentForm extends Component
|
||||
string $textItems = '', string $textQuantity = '', string $textPrice = '', string $textAmount = '',
|
||||
bool $hideItems = false, bool $hideName = false, bool $hideDescription = false, bool $hideQuantity = false,
|
||||
bool $hidePrice = false, bool $hideDiscount = false, bool $hideAmount = false,
|
||||
bool $hideEditItemColumns = false
|
||||
bool $hideEditItemColumns = false,
|
||||
bool $isSalePrice = false, bool $isPurchasePrice = false
|
||||
/** Items Component End */
|
||||
) {
|
||||
$this->type = $type;
|
||||
@ -249,6 +256,8 @@ abstract class DocumentForm extends Component
|
||||
$this->hideAmount = $this->getHideAmount($type, $hideAmount);
|
||||
|
||||
$this->hideEditItemColumns = $hideEditItemColumns;
|
||||
$this->isSalePrice = $isSalePrice;
|
||||
$this->isPurchasePrice = $isPurchasePrice;
|
||||
/** Items Component End */
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class SelectItemButton extends Component
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $type = 'sale', bool $isSale = true, bool $isPurchase = false)
|
||||
public function __construct(string $type = 'sale', bool $isSale = false, bool $isPurchase = false)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->isSale = $isSale;
|
||||
@ -36,13 +36,10 @@ class SelectItemButton 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);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$price = $item->sale_price;
|
||||
|
||||
if ($this->type == 'purchase' || $this->isPurchase) {
|
||||
$price = $item->purchase_price;
|
||||
}
|
||||
$price = $item->{$price_type . '_price'};
|
||||
|
||||
$item->price = $price;
|
||||
}
|
||||
@ -51,4 +48,30 @@ class SelectItemButton extends Component
|
||||
|
||||
return view('components.select-item-button', compact('items', 'price'));
|
||||
}
|
||||
|
||||
protected function getPriceType($type, $is_sale, $is_purchase)
|
||||
{
|
||||
if (!empty($is_sale)) {
|
||||
return 'sale';
|
||||
}
|
||||
|
||||
if (!empty($is_sale)) {
|
||||
return 'purchase';
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$type = 'purchase';
|
||||
break;
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
default:
|
||||
$type = 'sale';
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,11 @@
|
||||
@stack('add_item_td_start')
|
||||
<tr id="addItem">
|
||||
<td class="text-right border-bottom-0" colspan="{{ '7' }}">
|
||||
<x-select-item-button type="{{ $type }}" />
|
||||
<x-select-item-button
|
||||
type="{{ $type }}"
|
||||
is-sale="{{ $isSalePrice }}"
|
||||
is-purchase="{{ $isPurchasePrice }}"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
@stack('add_item_td_end')
|
||||
|
Loading…
x
Reference in New Issue
Block a user