Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from isahuerga/master
Browse files Browse the repository at this point in the history
Exclude Taxes
  • Loading branch information
davfaulk authored May 31, 2021
2 parents 5a976b7 + ed36449 commit 1691557
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions easy_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Resources:
CURRENT_MONTH:
Ref: CurrentMonth
INC_SUPPORT: 'false'
INC_TAX: 'true'
Events:
MonthlyEvent:
Properties:
Expand Down
13 changes: 11 additions & 2 deletions src/lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@
else:
INC_SUPPORT = False

#Default include taxes
INC_TAX = os.environ.get('INC_TAX')
if INC_TAX == "false":
INC_TAX = False
else:
INC_TAX = True

TAG_VALUE_FILTER = os.environ.get('TAG_VALUE_FILTER') or '*'
TAG_KEY = os.environ.get('TAG_KEY')

Expand Down Expand Up @@ -245,7 +252,7 @@ def addLinkedReports(self, Name='RI_{}',PaymentOption='PARTIAL_UPFRONT'):
pass

def addReport(self, Name="Default",GroupBy=[{"Type": "DIMENSION","Key": "SERVICE"},],
Style='Total', NoCredits=True, CreditsOnly=False, RefundOnly=False, UpfrontOnly=False, IncSupport=False):
Style='Total', NoCredits=True, CreditsOnly=False, RefundOnly=False, UpfrontOnly=False, IncSupport=False, IncTax=True):
type = 'chart' #other option table
results = []
if not NoCredits:
Expand All @@ -272,6 +279,8 @@ def addReport(self, Name="Default",GroupBy=[{"Type": "DIMENSION","Key": "SERVICE
Dimensions={"Dimensions": {"Key": "RECORD_TYPE","Values": ["Refund",]}}
if UpfrontOnly:
Dimensions={"Dimensions": {"Key": "RECORD_TYPE","Values": ["Upfront",]}}
if "Not" in Dimensions and (not INC_TAX or not IncTax): #If filtering Record_Types and Tax excluded
Dimensions["Not"]["Dimensions"]["Values"].append("Tax")

tagValues = None
if TAG_KEY:
Expand Down Expand Up @@ -423,7 +432,7 @@ def generateExcel(self):

def main_handler(event=None, context=None):
costexplorer = CostExplorer(CurrentMonth=False)
#Default addReport has filter to remove Support / Credits / Refunds / UpfrontRI
#Default addReport has filter to remove Support / Credits / Refunds / UpfrontRI / Tax
#Overall Billing Reports
costexplorer.addReport(Name="Total", GroupBy=[],Style='Total',IncSupport=True)
costexplorer.addReport(Name="TotalChange", GroupBy=[],Style='Change')
Expand Down
3 changes: 2 additions & 1 deletion src/sam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ Resources:
ACCOUNT_LABEL: !Ref AccountLabel
CURRENT_MONTH: !Ref CurrentMonth
INC_SUPPORT: 'false'
Events:
INC_TAX: 'true'
Events:
MonthlyEvent:
Properties:
Schedule: !Sub cron(0 1 ${DayOfMonth} * ? *)
Expand Down

0 comments on commit 1691557

Please sign in to comment.