Add inventory changes ( tax, net purchase price
This commit is contained in:
@@ -54,7 +54,6 @@ class InventoryConsoleController extends Controller{
|
||||
|
||||
$item->count_sold = $products;
|
||||
|
||||
$item->recalculateTotalPriceBrutto();
|
||||
|
||||
echo $item->price_brutto . " - ". $item->productName ."\n";
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m170103_172147_alter__product__add__column__tax extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn("product", "tax", "int default 27");
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m170103_172147_alter__product__add__column__tax cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m170103_175608_alter__product__add__column__purchase_net_price extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn("product", "purchase_net_price", "int default 0");
|
||||
$this->execute("update product set purchase_net_price = purchase_price - FLOOR( purchase_price * tax / 100 )");
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m170103_175608_alter__product__add__column__purchase_net_price cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m170104_054306_alter__table__product__set_products__tax__18 extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->execute("update product set tax = 18 where name = 'Zabcsók';");
|
||||
$this->execute("update product set tax = 18 where name = 'Mabaker zabszelet';");
|
||||
$this->execute("update product set purchase_net_price = purchase_price - FLOOR( purchase_price * tax / 100 )");
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m170104_054306_alter__table__product__set_products__tax__18 cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m170104_063931_alter__table__inventory__item__add__tax__net_stock_valu__sotck_missing extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn("inventory_item", "tax", "int default 0");
|
||||
$this->addColumn("inventory_item", "net_stock_money", "int default 0");
|
||||
$this->addColumn("inventory_item", "purchase_price_net", "int default 0");
|
||||
$this->addColumn("inventory_item", "stock_missing_money", "int default 0");
|
||||
$this->addColumn("inventory_item", "stock_missing_count", "int default 0");
|
||||
|
||||
|
||||
$sql = "UPDATE inventory_item AS i
|
||||
INNER JOIN product AS p ON p.id_product = i.id_product
|
||||
SET
|
||||
i.tax = p.tax,
|
||||
i.purchase_price_net = p.purchase_net_price,
|
||||
i.net_stock_money = i.count * p.purchase_net_price,
|
||||
i.stock_missing_count = (coalesce(i.count,0) - ( coalesce(i.count_prev,0) + coalesce(i.count_in,0) - coalesce(i.count_sold,0) )),
|
||||
i.stock_missing_money = i.price_brutto * (coalesce(i.count,0) - ( coalesce(i.count_prev,0) + coalesce(i.count_in,0) - coalesce(i.count_sold,0) ))
|
||||
WHERE i.id_inventory_group is null ";
|
||||
|
||||
|
||||
$this->execute($sql);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m170104_063931_alter__table__inventory__item__add__tax__net_stock_valu__sotck_missing cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user