mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Add journal and undo UI for stock bookings, chore executions and battery charge cycles (closes #63, closes #97)
This commit is contained in:
@@ -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)
|
||||
|
@@ -63,7 +63,7 @@ class ChoresService extends BaseService
|
||||
));
|
||||
$logRow->save();
|
||||
|
||||
return true;
|
||||
return $this->Database->lastInsertId();
|
||||
}
|
||||
|
||||
private function ChoreExists($choreId)
|
||||
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user