Add journal and undo UI for stock bookings, chore executions and battery charge cycles (closes #63, closes #97)

This commit is contained in:
Bernd Bestel
2018-10-27 17:26:00 +02:00
parent fe83e2fa6f
commit 364f6b2051
28 changed files with 541 additions and 92 deletions

View File

@@ -47,8 +47,8 @@ class StockService extends BaseService
$product = $this->Database->products($productId);
$productStockAmount = $this->Database->stock()->where('product_id', $productId)->sum('amount');
$productLastPurchased = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_PURCHASE)->max('purchased_date')->where('undone', 0);
$productLastUsed = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->max('used_date')->where('undone', 0);
$productLastPurchased = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_PURCHASE)->where('undone', 0)->max('purchased_date');
$productLastUsed = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone', 0)->max('used_date');
$nextBestBeforeDate = $this->Database->stock()->where('product_id', $productId)->min('best_before_date');
$quPurchase = $this->Database->quantity_units($product->qu_id_purchase);
$quStock = $this->Database->quantity_units($product->qu_id_stock);
@@ -113,6 +113,8 @@ class StockService extends BaseService
));
$logRow->save();
$returnValue = $this->Database->lastInsertId();
$stockRow = $this->Database->stock()->createRow(array(
'product_id' => $productId,
'amount' => $amount,
@@ -123,7 +125,7 @@ class StockService extends BaseService
));
$stockRow->save();
return true;
return $returnValue;
}
else
{
@@ -197,7 +199,7 @@ class StockService extends BaseService
}
}
return true;
return $this->Database->lastInsertId();
}
else
{
@@ -226,7 +228,7 @@ class StockService extends BaseService
$this->ConsumeProduct($productId, $amountToRemove, false, self::TRANSACTION_TYPE_INVENTORY_CORRECTION);
}
return true;
return $this->Database->lastInsertId();
}
public function AddMissingProductsToShoppingList()