Skip to content

Commit 0d02aa7

Browse files
committed
improved consumptionDetailByCycle()
1 parent 724a66b commit 0d02aa7

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

simyo/simyo.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,45 @@ def consumptionDetailByCycle(billCycleCount=1):
244244
date = epoch2date(day['date'])
245245
totalCharge = float(day['totalCharge'])
246246
print "{0} charge: {1}".format(date, totalCharge)
247-
if 'data' in day:
248-
print "\tdata: {0:.2f} MB ({1} EUR)".format(day['data']['count']/1024.0/1024.0, float(day['data']['chargeTotal']))
249-
else:
250-
print "\tdata: 0 MB (0 EUR)"
247+
248+
# regular
251249
if 'voice' in day:
252250
hms = datetime.timedelta(seconds=day['voice']['count'])
253251
print "\tvoice: {0} ({1} EUR)".format (hms, float(day['voice']['chargeTotal']))
254252
else:
255-
print "\tvoice: 0:00:00 (0 EUR)"
253+
print "\tvoice: 0:00:00 (0.0 EUR)"
256254
if 'sms' in day:
257255
print "\tsms: {0} ({1} EUR)".format (day['sms']['count'], float(day['sms']['chargeTotal']))
258256
else:
259-
print "\tsms: 0 (0 EUR)"
257+
print "\tsms: 0 (0.0 EUR)"
258+
if 'mms' in day:
259+
print "\tmms: {0} ({1} EUR)".format (day['mms']['count'], float(day['mms']['chargeTotal']))
260+
if 'data' in day:
261+
print "\tdata: {0:.2f} MB ({1} EUR)".format(day['data']['count']/1024.0/1024.0, float(day['data']['chargeTotal']))
262+
else:
263+
print "\tdata: 0 MB (0.0 EUR)"
264+
265+
# premium
266+
if 'voicePremium' in day:
267+
hms = datetime.timedelta(seconds=day['voicePremium']['count'])
268+
print "\tPREMIUM incoming voice: {0} ({1} EUR)".format (hms, float(day['voicePremium']['chargeTotal']))
269+
if 'smsPremium' in day:
270+
print "\tPREMIUM sms: {0} ({1} EUR)".format (day['smsPremium']['count'], float(day['smsPremium']['chargeTotal']))
271+
272+
# roaming
273+
if 'voiceIngoingRoaming' in day:
274+
hms = datetime.timedelta(seconds=day['voiceIngoingRoaming']['count'])
275+
print "\tROAMING incoming voice: {0} ({1} EUR)".format (hms, float(day['voiceIngoingRoaming']['chargeTotal']))
276+
if 'voiceOutgoingRoaming' in day:
277+
hms = datetime.timedelta(seconds=day['voiceOutgoingRoaming']['count'])
278+
print "\tROAMING outgoing voice: {0} ({1} EUR)".format (hms, float(day['voiceOutgoingRoaming']['chargeTotal']))
279+
if 'smsRoaming' in day:
280+
print "\tROAMING sms: {0} ({1} EUR)".format (day['smsRoaming']['count'], float(day['smsRoaming']['chargeTotal']))
281+
if 'mmsRoaming' in day:
282+
print "\tROAMING mms: {0} ({1} EUR)".format (day['mmsRoaming']['count'], float(day['mmsRoaming']['chargeTotal']))
283+
if 'dataRoaming' in day:
284+
print "\tROAMING data: {0:.2f} MB ({1} EUR)".format(day['dataRoaming']['count']/1024.0/1024.0, float(day['dataRoaming']['chargeTotal']))
285+
260286

261287
def frequentNumbers():
262288
month=billCycle # Parameter month is mandatory

0 commit comments

Comments
 (0)