Merge pull request #1864 from SevanNerse/master
minor bug fixed on reflect recurring transactions to reports
This commit is contained in:
commit
2af751d836
@ -383,7 +383,6 @@ abstract class Report
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'quarterly':
|
case 'quarterly':
|
||||||
$start = $end = '';
|
|
||||||
$quarters = $this->getFinancialQuarters($this->year);
|
$quarters = $this->getFinancialQuarters($this->year);
|
||||||
|
|
||||||
foreach ($quarters as $quarter) {
|
foreach ($quarters as $quarter) {
|
||||||
|
@ -50,8 +50,8 @@ trait DateTime
|
|||||||
$start = Date::parse($year . '-01-01')->startOfDay()->format('Y-m-d H:i:s');
|
$start = Date::parse($year . '-01-01')->startOfDay()->format('Y-m-d H:i:s');
|
||||||
$end = Date::parse($year . '-12-31')->endOfDay()->format('Y-m-d H:i:s');
|
$end = Date::parse($year . '-12-31')->endOfDay()->format('Y-m-d H:i:s');
|
||||||
} else {
|
} else {
|
||||||
$start = $financial_start->format('Y-m-d H:i:s');
|
$start = $financial_start->startOfDay()->format('Y-m-d H:i:s');
|
||||||
$end = $financial_start->addYear(1)->subDays(1)->format('Y-m-d H:i:s');
|
$end = $financial_start->addYear(1)->subDays(1)->endOfDay()->format('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->whereBetween($field, [$start, $end]);
|
return $query->whereBetween($field, [$start, $end]);
|
||||||
@ -121,7 +121,7 @@ trait DateTime
|
|||||||
{
|
{
|
||||||
$start = $this->getFinancialStart($year);
|
$start = $this->getFinancialStart($year);
|
||||||
|
|
||||||
return CarbonPeriod::create($start, $start->copy()->addYear()->subDay());
|
return CarbonPeriod::create($start, $start->copy()->addYear()->subDay()->endOfDay());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFinancialQuarters($year = null)
|
public function getFinancialQuarters($year = null)
|
||||||
@ -130,7 +130,7 @@ trait DateTime
|
|||||||
$start = $this->getFinancialStart($year);
|
$start = $this->getFinancialStart($year);
|
||||||
|
|
||||||
for ($i = 0; $i < 4; $i++) {
|
for ($i = 0; $i < 4; $i++) {
|
||||||
$quarters[] = CarbonPeriod::create($start->copy()->addQuarters($i), $start->copy()->addQuarters($i + 1)->subDay());
|
$quarters[] = CarbonPeriod::create($start->copy()->addQuarters($i), $start->copy()->addQuarters($i + 1)->subDay()->endOfDay());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $quarters;
|
return $quarters;
|
||||||
|
@ -3,12 +3,17 @@
|
|||||||
namespace App\Utilities;
|
namespace App\Utilities;
|
||||||
|
|
||||||
use App\Models\Document\Document;
|
use App\Models\Document\Document;
|
||||||
|
use App\Traits\DateTime;
|
||||||
use Date;
|
use Date;
|
||||||
|
|
||||||
class Recurring
|
class Recurring
|
||||||
{
|
{
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
public static function reflect(&$items, $issued_date_field)
|
public static function reflect(&$items, $issued_date_field)
|
||||||
{
|
{
|
||||||
|
$financial_year = (new static)->getFinancialYear();
|
||||||
|
|
||||||
foreach ($items as $key => $item) {
|
foreach ($items as $key => $item) {
|
||||||
// @todo cache recurrings
|
// @todo cache recurrings
|
||||||
if (!$item->recurring || !empty($item->parent_id)) {
|
if (!$item->recurring || !empty($item->parent_id)) {
|
||||||
@ -18,18 +23,17 @@ class Recurring
|
|||||||
foreach ($item->recurring->getRecurringSchedule(false) as $schedule) {
|
foreach ($item->recurring->getRecurringSchedule(false) as $schedule) {
|
||||||
$issued = Date::parse($item->$issued_date_field);
|
$issued = Date::parse($item->$issued_date_field);
|
||||||
$start = $schedule->getStart();
|
$start = $schedule->getStart();
|
||||||
|
$start_date = Date::parse($start->format('Y-m-d'));
|
||||||
if ($issued->format('Y') != $start->format('Y')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($issued->format('Y-m') == $start->format('Y-m')) && ($issued->format('d') >= $start->format('d'))) {
|
if (($issued->format('Y-m') == $start->format('Y-m')) && ($issued->format('d') >= $start->format('d'))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$clone = clone $item;
|
if ($start_date->lessThan($financial_year->getStartDate()) || $start_date->greaterThan($financial_year->getEndDate())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$start_date = Date::parse($start->format('Y-m-d'));
|
$clone = clone $item;
|
||||||
|
|
||||||
if ($clone instanceof Document) {
|
if ($clone instanceof Document) {
|
||||||
// Days between invoiced/billed and due date
|
// Days between invoiced/billed and due date
|
||||||
|
Loading…
x
Reference in New Issue
Block a user