1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Working on Rappen Rounding

This commit is contained in:
David Bomba 2024-03-25 12:23:20 +11:00
parent 1feff63c1b
commit 95a5cbb5a1
2 changed files with 19 additions and 14 deletions

View File

@ -169,26 +169,21 @@ class CheckData extends Command
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) {
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) {
$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 {
// $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 {
$this->logMessage("No contact present, so cannot add invitation for {$entity_key} - {$entity->id}");
try{
$entity->service()->createInvitations()->save();
}
catch(\Exception $e){
}
}
try {

View File

@ -246,6 +246,8 @@ class InvoiceSum
if ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
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.
} else {
$this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision);