diff --git a/backend/controllers/InventoryItemController.php b/backend/controllers/InventoryItemController.php
index 166c642..627898a 100644
--- a/backend/controllers/InventoryItemController.php
+++ b/backend/controllers/InventoryItemController.php
@@ -183,9 +183,14 @@ class InventoryItemController extends Controller
throw new NotAcceptableHttpException("A leltár elem nem található");
}
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ if ($model->load(Yii::$app->request->post()) && $model->validate()) {
+
+ $model->recalculateTotalPriceBrutto();
+
+ $model->save(false);
$prev = Url::previous("inventory-item-index");
+
if ( isset($prev)){
return $this->redirect($prev);
}else{
diff --git a/backend/models/InventoryItemForm.php b/backend/models/InventoryItemForm.php
index d818c48..48a1a68 100644
--- a/backend/models/InventoryItemForm.php
+++ b/backend/models/InventoryItemForm.php
@@ -119,6 +119,7 @@ class InventoryItemForm extends Model{
$item->id_user = \Yii::$app->user->id;
if ( $this->type == 'product'){
+ $item->price_brutto = $this->product->sale_price;
$item->type = InventoryItem::$TYPE_PRODUCT;
$item->id_product = $this->product->id_product;
}else{
@@ -127,6 +128,10 @@ class InventoryItemForm extends Model{
}
$item->id_inventory = $this->inventory->id_inventory;
+
+ $model->recalculateTotalPriceBrutto();
+
+
if ( !$item->save(false) ){
throw new \Exception("Nem sikerült a leltár végrehajtása");
}
diff --git a/backend/models/InventoryItemSearch.php b/backend/models/InventoryItemSearch.php
index b49fb49..f9f52f5 100644
--- a/backend/models/InventoryItemSearch.php
+++ b/backend/models/InventoryItemSearch.php
@@ -71,6 +71,8 @@ class InventoryItemSearch extends InventoryItem
'inventory.created_at as inventory_created_at',
'inventory_prev.id_inventory as inventory_prev_id_inventory',
'inventory_prev.name as inventory_prev_name',
+ 'inventory_item.price_brutto as item_price_brutto',
+ 'inventory_item.total_price_brutto as item_total_price_brutto',
new Expression('(coalesce(inventory_item.count,0) - ( coalesce(inventory_item.count_prev,0) + coalesce(inventory_item.count_in,0) - coalesce(inventory_item.count_sold,0) )) as item_difference'),
]);
@@ -114,6 +116,8 @@ class InventoryItemSearch extends InventoryItem
['inventory.id_inventory', 'inventory_id_inventory'],
['inventory.name', 'inventory_name'],
['inventory_prev_name', 'inventory_prev_name'],
+ ['item_price_brutto', 'item_price_brutto'],
+ ['item_total_price_brutto', 'item_total_price_brutto'],
])
,
]
diff --git a/backend/views/inventory-item/index.php b/backend/views/inventory-item/index.php
index 71df795..8619897 100644
--- a/backend/views/inventory-item/index.php
+++ b/backend/views/inventory-item/index.php
@@ -22,6 +22,22 @@ $options['products'] = $productOptions;
$this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
?>
+
+
+
= Html::encode($this->title) ?>
@@ -86,56 +102,61 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
'item_created_at',
- 'label' => 'Létrehozva',
- 'format' => 'datetime'
- ],
[
'attribute' => 'item_name',
'label' => 'Név',
- ],
- [
- 'attribute' => 'user_username',
- 'label' => 'Felhasználó',
-
],
[
'attribute' => 'inventory_prev_name',
'label' => 'Utolsó leltár'
-
],
[
'attribute' => 'item_count_system',
'label' => 'Rendszer szerinti mennyiség (db)',
+ 'contentOptions' => ['class' => 'numeric']
],
[
'attribute' => 'item_count',
'label' => 'Leltározott mennyiség (db)',
+ 'contentOptions' => ['class' => 'numeric']
],
[
'attribute' => 'item_count_prev',
- 'label' => 'Előzö leltár (db)'
+ 'label' => 'Előzö leltár (db)',
+ 'contentOptions' => ['class' => 'numeric']
],
[
'attribute' => 'item_count_in',
- 'label' => 'Beszerzett mennyiség (db)'
+ 'label' => 'Beszerzett mennyiség (db)',
+ 'contentOptions' => ['class' => 'numeric']
],
[
'attribute' => 'item_count_sold',
'label' => 'Eladott mennyiség (db)',
+ 'contentOptions' => ['class' => 'numeric']
],
[
'attribute' => 'item_difference',
'label' => 'Különbség (db)',
+ 'contentOptions' => ['class' => 'numeric']
],
+ [
+ 'attribute' => 'item_price_brutto',
+ 'label' => 'Eladási ár (Ft)',
+ 'contentOptions' => ['class' => 'numeric']
+ ],
+ [
+ 'attribute' => 'item_total_price_brutto',
+ 'label' => 'Összeg (Ft)',
+ 'contentOptions' => ['class' => 'numeric']
+ ],
];
diff --git a/common/messages/hu/common/procurement.php b/common/messages/hu/common/procurement.php
index d18cb17..7707c4c 100644
--- a/common/messages/hu/common/procurement.php
+++ b/common/messages/hu/common/procurement.php
@@ -33,7 +33,7 @@ return [
'Procurement' => 'Beszerzés',
'Procurements' => 'Beszerzések',
'Product name, product number or barcode' => 'Termék neve, termék száma vagy vonalkód',
- 'Purchase Price' => 'Beszerzési ár',
+ 'Purchase Price' => 'Bevételezési ár(össz.)',
'Search' => 'Keresés',
'Stock' => 'Beszerzés előtti raktárkészlet',
'Update' => 'Módosítás',
diff --git a/common/models/InventoryItem.php b/common/models/InventoryItem.php
index 80060c1..651d90c 100644
--- a/common/models/InventoryItem.php
+++ b/common/models/InventoryItem.php
@@ -24,6 +24,8 @@ use common\components\ProductAwareBehavior;
* @property integer $id_user
* @property integer $id_inventory_item_prev
* @property integer $id_user
+ * @property integer $price_brutto
+ * @property integer $total_price_brutto
* @property string $created_at
* @property string $updated_at
*/
@@ -155,6 +157,20 @@ class InventoryItem extends BaseFitnessActiveRecord
}
+ public function recalculateTotalPriceBrutto(){
+ $diff = $this->difference;
+ if (!isset($diff) || !is_numeric($diff)){
+ $diff = 0;
+ }
+
+ $price = $this->price_brutto;
+ if (!isset($price) || !is_numeric($price)){
+ $price = 0;
+ }
+
+ $this->total_price_brutto = $price * $diff;
+ }
+
public function afterSave($insert, $changedAttributes){
if ( !$insert ){
// if ( $this->type == 'product'){
diff --git a/console/migrations/m160404_053858_alter__table__inventory_item_add__price__brutto.php b/console/migrations/m160404_053858_alter__table__inventory_item_add__price__brutto.php
new file mode 100644
index 0000000..97a9bd1
--- /dev/null
+++ b/console/migrations/m160404_053858_alter__table__inventory_item_add__price__brutto.php
@@ -0,0 +1,31 @@
+addColumn("inventory_item", "price_brutto", "int default 0");
+ $this->addColumn("inventory_item", "total_price_brutto", "int default 0");
+ }
+
+ public function down()
+ {
+ echo "m160404_053858_alter__table__inventory_item_add__price__brutto cannot be reverted.\n";
+
+ return false;
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}