Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions workers/main/src/services/TargetUnit/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ export const TARGET_UNITS_QUERY = `SELECT
JOIN users AS u ON u.id = te.user_id
WHERE g.type = 'Group'
AND cv.customized_type = 'Principal' and cv.value = ?
AND te.spent_on BETWEEN DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 7 DAY)
AND DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY)
AND te.spent_on BETWEEN
DATE_FORMAT(
DATE_SUB(
DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY),
INTERVAL (MONTH(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY))-1)%3 MONTH
),
'%Y-%m-01'
)
AND DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) + 1 DAY)
) t
GROUP BY
group_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,8 @@ export class WeeklyFinancialReportRepository
}

private composeWeeklyReportTitle(currentDate: Date): string {
const periodStart = new Date(
currentDate.getFullYear(),
currentDate.getMonth(),
currentDate.getDate() - ((currentDate.getDay() + 6) % 7) - 7,
)
const quarter = Math.floor(currentDate.getMonth() / 3);
const periodStart = new Date(currentDate.getFullYear(), quarter * 3, 1)
.toISOString()
.slice(0, 10);
Comment thread
anatolyshipitz marked this conversation as resolved.
const periodEnd = new Date(
Expand Down