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

@@ -18,14 +18,14 @@ class BatteriesService extends BaseService
}
$battery = $this->Database->batteries($batteryId);
$batteryChargeCylcesCount = $this->Database->battery_charge_cycles()->where('battery_id = :1 AND undone = 0', $batteryId)->count();
$batteryChargeCyclesCount = $this->Database->battery_charge_cycles()->where('battery_id = :1 AND undone = 0', $batteryId)->count();
$batteryLastChargedTime = $this->Database->battery_charge_cycles()->where('battery_id = :1 AND undone = 0', $batteryId)->max('tracked_time');
$nextChargeTime = $this->Database->batteries_current()->where('battery_id', $batteryId)->min('next_estimated_charge_time');
return array(
'battery' => $battery,
'last_charged' => $batteryLastChargedTime,
'charge_cycles_count' => $batteryChargeCylcesCount,
'charge_cycles_count' => $batteryChargeCyclesCount,
'next_estimated_charge_time' => $nextChargeTime
);
}
@@ -43,7 +43,7 @@ class BatteriesService extends BaseService
));
$logRow->save();
return true;
return $this->Database->lastInsertId();
}
private function BatteryExists($batteryId)

View File

@@ -63,7 +63,7 @@ class ChoresService extends BaseService
));
$logRow->save();
return true;
return $this->Database->lastInsertId();
}
private function ChoreExists($choreId)

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()