mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 15:54:31 -04:00
Working on Rappen Rounding
This commit is contained in:
parent
1feff63c1b
commit
95a5cbb5a1
@ -169,26 +169,21 @@ class CheckData extends Command
|
|||||||
|
|
||||||
private function checkCompanyTokens()
|
private function checkCompanyTokens()
|
||||||
{
|
{
|
||||||
// CompanyUser::whereDoesntHave('token', function ($query){
|
|
||||||
// return $query->where('is_system', 1);
|
|
||||||
// })->cursor()->each(function ($cu){
|
|
||||||
// if ($cu->user) {
|
|
||||||
// $this->logMessage("Creating missing company token for user # {$cu->user->id} for company id # {$cu->company->id}");
|
|
||||||
// (new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
|
|
||||||
// } else {
|
|
||||||
// $this->logMessage("Dangling User ID # {$cu->id}");
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
CompanyUser::query()->cursor()->each(function ($cu) {
|
CompanyUser::query()->cursor()->each(function ($cu) {
|
||||||
|
|
||||||
if (CompanyToken::where('user_id', $cu->user_id)->where('company_id', $cu->company_id)->where('is_system', 1)->doesntExist()) {
|
if (CompanyToken::where('user_id', $cu->user_id)->where('company_id', $cu->company_id)->where('is_system', 1)->doesntExist()) {
|
||||||
$this->logMessage("Creating missing company token for user # {$cu->user_id} for company id # {$cu->company_id}");
|
|
||||||
|
|
||||||
if ($cu->company && $cu->user) {
|
if ($cu->company && $cu->user) {
|
||||||
|
$this->logMessage("Creating missing company token for user # {$cu->user_id} for company id # {$cu->company_id}");
|
||||||
(new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
|
(new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
|
||||||
} else {
|
}
|
||||||
// $cu->forceDelete();
|
|
||||||
|
if (!$cu->user) {
|
||||||
|
$this->logMessage("No user found for company user - removing company user");
|
||||||
|
$cu->forceDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -482,6 +477,14 @@ class CheckData extends Command
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->logMessage("No contact present, so cannot add invitation for {$entity_key} - {$entity->id}");
|
$this->logMessage("No contact present, so cannot add invitation for {$entity_key} - {$entity->id}");
|
||||||
|
|
||||||
|
try{
|
||||||
|
$entity->service()->createInvitations()->save();
|
||||||
|
}
|
||||||
|
catch(\Exception $e){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -246,6 +246,8 @@ class InvoiceSum
|
|||||||
|
|
||||||
if ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
|
if ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
|
||||||
if ($this->invoice->amount != $this->invoice->balance) {
|
if ($this->invoice->amount != $this->invoice->balance) {
|
||||||
|
// $paid_to_date = $this->invoice->amount - $this->invoice->balance;
|
||||||
|
|
||||||
$this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision) - $this->invoice->paid_to_date; //21-02-2024 cannot use the calculated $paid_to_date here as it could send the balance backward.
|
$this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision) - $this->invoice->paid_to_date; //21-02-2024 cannot use the calculated $paid_to_date here as it could send the balance backward.
|
||||||
} else {
|
} else {
|
||||||
$this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision);
|
$this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user