Get a valid CashDiary for today from the given POS, it will return:
            - None: if no CashDiary is available today and older one was already closed
            - New CashDiary: if no CashDiary is available today but there is an older one which it was opened
            - Existing CashDiary: if a CashDiary is available today (open or close)

def find(pos, user):
        '''
        Get a valid CashDiary for today from the given POS, it will return:
            - None: if no CashDiary is available today and older one was already closed
            - New CashDiary: if no CashDiary is available today but there is an older one which it was opened
            - Existing CashDiary: if a CashDiary is available today (open or close)
        '''

        # Get checkpoint
        ck = dateparse.parse_time(getattr(settings, "CASHDIARY_CLOSES_AT", '03:00'))
        year = timezone.now().year
        month = timezone.now().month
        day = timezone.now().day
        hour = ck.hour
        minute = ck.minute
        second = ck.second
        checkpoint = timezone.datetime(year, month, day, hour, minute, second)

        # Get
        cashdiary = CashDiary.objects.filter(pos=pos, opened_date__gte=checkpoint).order_by("-opened_date").first()
        if not cashdiary:
            # No cashdiary found for today, check older one
            oldercashdiary = CashDiary.objects.filter(pos=pos, opened_date__lt=checkpoint).order_by("-opened_date").first()
            if oldercashdiary:
                if oldercashdiary.closed_user:
                    cashdiary = None
                else:
                    # Older cashdiary is not closed, we have to close it and open a new one
                    amount_cash = oldercashdiary.amount_cash()
                    amount_cards = oldercashdiary.amount_cards()
                    # The older cashdiary is still opened, we have to close it and create a new one
                    oldercashdiary.closed_cash = amount_cash
                    oldercashdiary.closed_cards = amount_cards
                    oldercashdiary.closed_user = user
                    oldercashdiary.closed_date = timezone.now()
                    oldercashdiary.save()
                    # Open new cashdiary
                    cashdiary = CashDiary()
                    cashdiary.pos = pos
                    cashdiary.opened_cash = amount_cash
                    cashdiary.opened_cards = amount_cards
                    cashdiary.opened_user = user
                    cashdiary.opened_date = timezone.now()
                    cashdiary.save()
            else:
                # initial new cashdiary
                cashdiary = CashDiary()
                cashdiary.pos = pos
                cashdiary.opened_cash = Decimal('0')
                cashdiary.opened_cards = Decimal('0')
                cashdiary.opened_user = user
                cashdiary.opened_date = timezone.now()
                cashdiary.save()

        # Return the found CashDiary
        return cashdiary