import requests
from .models import saldoModel
import datetime

def get_saldo(request):
    try:
        Saldo = saldoModel.objects.first()
    except:        
        pass
    if not Saldo :
        Saldo = saldoModel.objects.create(saldo=1)
        Saldo.save()
    
    #r = requests.get('https://app2.comercio-digital.mx/x3/saldo?usr=SCT050708AD1&pwd=0dcu2SwCv')
    #print('resp:',r.text, dir(r))    
    return {
        'saldo':Saldo.saldo,
        'fecha': datetime.date.today()
        }