Add inventory changes ( tax, net purchase price

This commit is contained in:
2017-01-06 18:24:43 +01:00
parent 6de07dac93
commit f3d00953c8
16 changed files with 547 additions and 287 deletions

View File

@@ -81,7 +81,11 @@ class InventoryItemController extends Controller
['item_count_sold', 'Eladott mennyiség (db)'],
['item_count_in', 'Beszerzett mennyiség (db)'],
['item_count', 'Leltározott mennyiség (db)'],
['item_difference', 'Különbség (db)'],
['item_purchase_price_net', 'Nettó beszerezési ár (Ft)'],
['item_net_stock_money', 'Nettó készlet érték (Ft)'],
['item_stock_missing_count', 'Különbség (db)'],
['item_price_brutto', 'Bruttó eladási ár (Ft)'],
['item_stock_missing_money', 'Leltár hiány (Ft)'],
['item_count_system', 'Rendszer szerinti mennyiség (db)'],
];
$cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'];
@@ -121,11 +125,13 @@ class InventoryItemController extends Controller
// 'name' => 'Verdana'
foreach (range('A', 'I') as $columnID) {
foreach (range('A', 'N') as $columnID) {
$sheet->getColumnDimension($columnID)->setAutoSize(true);
$sheet->getStyle($columnID . '1')->applyFromArray($styleArray);
}
$sheet->freezePane( "N2" );
// Redirect output to a clients web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="leltar.xls"');
@@ -191,32 +197,18 @@ class InventoryItemController extends Controller
{
$model = $this->findModel($id);
$inventory = Inventory::findOne($model->id_inventory);
if (!$inventory->isOpen()) {
throw new NotAcceptableHttpException("A leltár elem nem található");
}
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->recalculateTotalPriceBrutto();
$model->save(false);
\Yii::$app->session->setFlash('success', "Mennyiség elmentve: " . $model->productName . ' - ' .$model->count . ' db');
// $prev = Url::previous("inventory-item-index");
$next = InventoryItem::findNextItemAlphabetical($model->id_inventory_item);
if ( isset($_POST['_next']) && isset($next)){
return $this->redirect(['inventory-item/update', 'id' => $next]);
}else{
return $this->redirect(['index', 'id' => $inventory->id_inventory]);
}
} else {
return $this->render('update', [
'model' => $model,
@@ -226,11 +218,11 @@ class InventoryItemController extends Controller
}
/**
* @param null $idInventory the id of the inventory
* @param integer $id the inventory item id
* @return string
* @throws Exception
* @throws NotAcceptableHttpException
* @throws NotFoundHttpException
*/
public function actionUpdateItem($idInventory = null,$id = null)
{
@@ -269,7 +261,6 @@ class InventoryItemController extends Controller
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->recalculateTotalPriceBrutto();
if ( $model->save(false) ){
\Yii::$app->session->setFlash('success', "Mennyiség elmentve: " . $model->productName . ' - ' .$model->count . ' db');

View File

@@ -123,16 +123,14 @@ class InventoryItemForm extends Model{
$item->price_brutto = $this->product->sale_price;
$item->type = InventoryItem::$TYPE_PRODUCT;
$item->id_product = $this->product->id_product;
$item->tax = $this->product->tax;
$item->purchase_price_net = $this->product->purchase_net_price;
}else{
$item->id_inventory_group = $this->inventoryGroup->id_inventory_group;
$item->type = InventoryItem::$TYPE_INVENTORY_GROUP;
}
$item->id_inventory = $this->inventory->id_inventory;
$item->recalculateTotalPriceBrutto();
if ( !$item->save(false) ){
throw new \Exception("Nem sikerült a leltár végrehajtása");
}

View File

@@ -2,7 +2,6 @@
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\InventoryItem;
@@ -72,8 +71,10 @@ class InventoryItemSearch extends InventoryItem
'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'),
'inventory_item.purchase_price_net as item_purchase_price_net',
'inventory_item.net_stock_money as item_net_stock_money',
'inventory_item.stock_missing_count as item_stock_missing_count',
'inventory_item.stock_missing_money as item_stock_missing_money'
]);
$query->from(InventoryItem::tableName());
@@ -91,11 +92,7 @@ class InventoryItemSearch extends InventoryItem
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$dataProvider = new ActiveDataProvider(
['query' => $query ,
@@ -117,12 +114,20 @@ class InventoryItemSearch extends InventoryItem
['inventory.name', 'inventory_name'],
['inventory_prev_name', 'inventory_prev_name'],
['item_price_brutto', 'item_price_brutto'],
['item_total_price_brutto', 'item_total_price_brutto'],
['item_purchase_price_net', 'item_purchase_price_net'],
['item_stock_missing_count', 'item_stock_missing_count'],
['item_stock_missing_money', 'item_stock_missing_money'],
])
,
]
]
);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
$query->where('0=1');
return $dataProvider;
}
if ( !empty($this->item_type) && is_numeric($this->item_id) ){

View File

@@ -115,18 +115,24 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
[
'attribute' => 'inventory_prev_name',
'label' => 'Utolsó leltár',
'contentOptions' => ['class' => 'col-b']
'contentOptions' => ['class' => '']
],
[
'attribute' => 'item_count_system',
'label' => 'Rendszer szerinti mennyiség (db)',
'contentOptions' => ['class' => 'numeric']
],
[
'attribute' => 'item_purchase_price_net',
'label' => 'Nettó beszerezési ár',
'contentOptions' => ['class' => 'numeric']
],
[
'attribute' => 'item_count',
'label' => 'Leltározott mennyiség (db)',
'contentOptions' => ['class' => 'numeric col-b']
'contentOptions' => ['class' => 'numeric ']
],
[
@@ -138,7 +144,7 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
[
'attribute' => 'item_count_in',
'label' => 'Beszerzett mennyiség (db)',
'contentOptions' => ['class' => 'numeric col-b' ]
'contentOptions' => ['class' => 'numeric ' ]
],
[
@@ -148,9 +154,9 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
],
[
'attribute' => 'item_difference',
'attribute' => 'item_stock_missing_count',
'label' => 'Különbség (db)',
'contentOptions' => ['class' => 'numeric col-b']
'contentOptions' => ['class' => 'numeric ']
],
[
@@ -159,13 +165,12 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
'contentOptions' => ['class' => 'numeric']
],
[
'attribute' => 'item_total_price_brutto',
'label' => 'Összeg (Ft)',
'contentOptions' => ['class' => 'numeric col-b']
],
'attribute' => 'item_stock_missing_money',
'label' => 'Leltár hiány (Ft)',
'contentOptions' => ['class' => 'numeric ']
]
];
if ($model->isOpen()) {
$columns[] = ['class' => 'yii\grid\ActionColumn',
'template' => '{update}',
@@ -187,6 +192,28 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );');
];
}
$i = 0;
foreach ($columns as $col){
$value = "";
if ( !isset($col["contentOptions"])){
$col["contentOptions"] = [];
}
if ( isset($col["contentOptions"]["class"])){
$value = $col["contentOptions"]["class"];
}
if ( $i % 2 == 1){
$columns[$i]["contentOptions"]["class"] = $value . " col-b";
}else{
$columns[$i]["contentOptions"]["class"] = $value . " col-a";
}
$i++;
}
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => $columns

View File

@@ -40,6 +40,8 @@ $inventory_groups = ['' => ''] + ArrayHelper::map($inventory_groups, "id_invent
<?= $form->field($model, 'profit_margins')->textInput() ?>
<?= $form->field($model, 'tax')->textInput() ?>
<?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/product', "Active") ]) ?>
<?= $form->field($model, 'description')->textarea(['maxlength' => true])->hint( Yii::t( 'common/product', "Max 255 character")) ?>

View File

@@ -37,7 +37,8 @@ $this->params['breadcrumbs'][] = $this->title;
'product_number',
'barcode',
'sale_price',
[
'tax',
[
'attribute' => 'status',
'value' => 'statusHuman',

View File

@@ -29,6 +29,7 @@ $this->params['breadcrumbs'][] = $this->title;
'purchase_price',
'sale_price',
'profit_margins',
'tax',
'statusHuman',
'stock',
[