Skip to content

Commit 1bb2b4f

Browse files
Merge pull request #408 from jinyoungmoonDEV/test
fix: fix scheduled cost report logic
2 parents 8beefb6 + 3b64d78 commit 1bb2b4f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/spaceone/cost_analysis/service/cost_report_serivce.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def create_cost_report_by_cost_report_config(self, params: dict) -> None:
7777
params={
7878
"domain_id": cost_report_config_vo.domain_id,
7979
"cost_report_config_id": cost_report_config_vo.cost_report_config_id,
80+
"is_scheduled": True,
8081
}
8182
)
8283
except Exception as e:
@@ -248,6 +249,7 @@ def stat(self, params: CostReportDataStatQueryRequest) -> dict:
248249
def create_cost_report(self, params: dict):
249250
domain_id = params["domain_id"]
250251
cost_report_config_id = params["cost_report_config_id"]
252+
is_scheduled = params.get("is_scheduled", False)
251253

252254
config_vo = self.cost_report_config_mgr.get_cost_report_config(
253255
domain_id, cost_report_config_id
@@ -263,6 +265,9 @@ def create_cost_report(self, params: dict):
263265
metadata["is_last_day"],
264266
current_date,
265267
adjustment_options,
268+
is_scheduled,
269+
cost_report_config_id,
270+
domain_id,
266271
)
267272
)
268273

@@ -510,6 +515,9 @@ def _calculate_report_flags_and_report_month(
510515
is_last_day: bool,
511516
current_date: datetime,
512517
adjustment_options: dict,
518+
is_scheduled: bool = False,
519+
cost_report_config_id: str = None,
520+
domain_id:str = None
513521
) -> Tuple[bool, bool, str]:
514522
create_in_progress_report = False
515523
create_adjusting_report = False
@@ -539,7 +547,14 @@ def _calculate_report_flags_and_report_month(
539547
else:
540548
create_adjusting_report = True
541549
if current_date >= done_date:
542-
self.is_done_report = True
550+
if is_scheduled and self._check_done_cost_report_exist(
551+
domain_id=domain_id,
552+
cost_report_config_id=cost_report_config_id,
553+
report_month=report_month,
554+
):
555+
create_adjusting_report = False
556+
else:
557+
self.is_done_report = True
543558

544559
return create_in_progress_report, create_adjusting_report, report_month
545560

0 commit comments

Comments
 (0)