mirror of
https://github.com/chenasraf/cospend-nc.git
synced 2026-05-17 17:38:10 +00:00
clarify entity attr init value, generated insert sql query does not include cols if value is equal to initial attr one
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
@@ -48,10 +48,10 @@ use OCP\AppFramework\Db\Entity;
|
||||
* @method void setDeleted(int $deleted) */
|
||||
class Bill extends Entity implements \JsonSerializable {
|
||||
|
||||
protected string $what = '';
|
||||
protected string $what = '...';
|
||||
protected ?string $comment = null;
|
||||
protected int $payerId = 0;
|
||||
protected float $amount = 0;
|
||||
protected float $amount = -1;
|
||||
protected int $timestamp = 0;
|
||||
protected string $repeat = 'n';
|
||||
protected int $repeatAllActive = 0;
|
||||
|
||||
@@ -13,15 +13,15 @@ use OCP\AppFramework\Db\Entity;
|
||||
/**
|
||||
* @method void setProjectId(string $projectId)
|
||||
* @method string getProjectId()
|
||||
* @method void setName(string|null $name)
|
||||
* @method string|null getName()
|
||||
* @method void setExchangeRate(float|null $exchangeRate)
|
||||
* @method float|null getExchangeRate()
|
||||
* @method void setName(string $name)
|
||||
* @method string getName()
|
||||
* @method void setExchangeRate(float $exchangeRate)
|
||||
* @method float getExchangeRate()
|
||||
*/
|
||||
class Currency extends Entity implements \JsonSerializable {
|
||||
protected string $projectId = '';
|
||||
protected ?string $name = null;
|
||||
protected ?float $exchangeRate = null;
|
||||
protected string $name = '';
|
||||
protected float $exchangeRate = -999;
|
||||
|
||||
public function __construct() {
|
||||
$this->addType('project_id', 'string');
|
||||
|
||||
@@ -36,7 +36,7 @@ class Invitation extends Entity implements \JsonSerializable {
|
||||
protected int $state = self::STATE_PENDING;
|
||||
protected string $accessToken = '';
|
||||
protected string $remoteProjectId = '';
|
||||
protected string $remoteProjectName = '';
|
||||
protected string $remoteProjectName = '...';
|
||||
protected string $remoteServerUrl = '';
|
||||
protected string $inviterCloudId = '';
|
||||
protected string $inviterDisplayName = '';
|
||||
|
||||
@@ -29,8 +29,8 @@ use OCP\IAvatarManager;
|
||||
* @method void setActivated(int $activated)
|
||||
* @method int getLastChanged()
|
||||
* @method void setLastChanged(int $lastChanged)
|
||||
* @method string getColor()
|
||||
* @method void setColor(string $color)
|
||||
* @method string|null getColor()
|
||||
* @method void setColor(string|null $color)
|
||||
* @method string|null getUserId()
|
||||
* @method void setUserId(string|null $userId)
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ class Member extends Entity implements \JsonSerializable {
|
||||
|
||||
protected string $projectId = '';
|
||||
protected string $name = '';
|
||||
protected float $weight = 0;
|
||||
protected float $weight = -1;
|
||||
protected int $activated = 1;
|
||||
protected int $lastChanged = 0;
|
||||
protected ?string $color = null;
|
||||
|
||||
@@ -980,14 +980,7 @@ class LocalProjectService implements IProjectService {
|
||||
$newBill->setComment($comment);
|
||||
}
|
||||
$newBill->setTimestamp($dateTs);
|
||||
// TODO figure out why it is problematic to insert a bill with an amount of 0
|
||||
// this does not happen when inserting a currency with a 0 exchange rate
|
||||
// it is apparently related with the fact that the methods accept null (even if the db column is set to NOTNULL)
|
||||
if ($amount === 0.0) {
|
||||
$newBill->setAmount(1);
|
||||
} else {
|
||||
$newBill->setAmount($amount);
|
||||
}
|
||||
$newBill->setAmount($amount);
|
||||
$newBill->setPayerId($payer);
|
||||
$newBill->setRepeat($repeat);
|
||||
$newBill->setRepeatAllActive($repeatAllActive);
|
||||
@@ -1003,12 +996,6 @@ class LocalProjectService implements IProjectService {
|
||||
|
||||
$insertedBillId = $createdBill->getId();
|
||||
|
||||
// TODO remove this after figuring it out
|
||||
if ($amount === 0.0) {
|
||||
$createdBill->setAmount(0);
|
||||
$this->billMapper->update($createdBill);
|
||||
}
|
||||
|
||||
// insert bill owers
|
||||
foreach ($owerIds as $owerId) {
|
||||
$billOwer = new BillOwer();
|
||||
|
||||
Reference in New Issue
Block a user