Пример #1
0
    def get(self):
        details_fields = {
            'id': fields.Integer(),
            'paymentType': fields.String,
            'paymentTypeName': fields.String,
            'receivedBy': fields.String,
            'serviceName': fields.String,
            'patientName': fields.String,
            'amount': fields.String,
            'paymentDateTime': fields.DateTime(dt_format='iso8601')
        }

        result_fields = {
            'details': fields.Nested(details_fields),
            'total': fields.String,
        }

        qParser = reqparse.RequestParser()

        qParser.add_argument('fromDate', type=dateInput, default=None)
        qParser.add_argument('toDate', type=dateInput, default=None)
        qParser.add_argument('user_id', type=int, default=None)

        args = qParser.parse_args()

        fromDate = args.get('fromDate')
        toDate = args.get('toDate')
        user_id = args.get('user_id')

        report = IncomeDetailsReport()
        report.filterDateRange(fromDate, toDate)
        report.filterByUser(user_id)

        result = report.result()
        return marshal(result, result_fields)
Пример #2
0
    def test_income_details_report(self):

        report = IncomeDetailsReport()
        # datetime.date(2016, 3, 12)
        report.filterDateRange(datetime.date.today(), datetime.datetime.now() )
        result = report.result()
        # print(result)
        self.assertEquals(result['total'], 1900)

        # expected = {'total': 0, 'details': [{'paymentTypeName': 'CASH', 'paymentType': 1, 'id': 1, 'amount': 100, 'receivedBy': 'user one receive', 'createdBy_id': 2}, {'paymentTypeName': 'CASH', 'paymentType': 1, 'id': 2, 'amount': 50, 'receivedBy': 'user one receive', 'createdBy_id': 2}, {'paymentTypeName': 'CASH', 'paymentType': 1, 'id': 3, 'amount': 50, 'receivedBy': 'user one receive', 'createdBy_id': 2}, {'paymentTypeName': 'CASH', 'paymentType': 1, 'id': 4, 'amount': 100, 'receivedBy': 'user one receive', 'createdBy_id': 2}, {'paymentTypeName': 'VISA', 'paymentType': 2, 'id': 5, 'amount': 100, 'receivedBy': 'user one receive', 'createdBy_id': 2}, {'paymentTypeName': 'CASH', 'paymentType': 1, 'id': 6, 'amount': 1000, 'receivedBy': 'user one receive', 'createdBy_id': 2}, {'paymentTypeName': 'VISA', 'paymentType': 2, 'id': 7, 'amount': 500, 'receivedBy': 'user one receive', 'createdBy_id': 2}]}
        for detail in result['details']:
            self.assertIs(type(detail['id']) , int)
            self.assertTrue(detail['id'] > 0 )
            self.assertIs(type(detail['paymentType']), int)
            self.assertIn(detail['paymentType'], [1,2] )

            self.assertIs(type(detail['receivedBy']), str)
            self.assertEquals(detail['receivedBy'], 'user one receive')
            self.assertEquals(detail['serviceName'], 'service 1 s')
            self.assertEquals(detail['patientName'], 'patient 1 z')


            self.assertIs(type(detail['paymentTypeName']), str)
            self.assertIn(detail['paymentTypeName'], ['CASH', 'VISA'] )

            self.assertIs(type(detail['paymentType']), int)
Пример #3
0
    def test_defaultDate_report(self):

        report = IncomeDetailsReport()
        # datetime.date(2016, 3, 12)
        report.filterDateRange()
        result = report.result()
        # print(result)
        expected = {'total':1900 ,'details': [{"paymentType": 1,"paymentTypeName":"CASH","amount":1300},{"paymentType": 2,"paymentTypeName":"VISA","amount":600}]}
        self.assertEquals(result['total'], 1900)

        for detail in result['details']:
            self.assertIs(type(detail['id']) , int)
            self.assertTrue(detail['id'] > 0 )
            self.assertIs(type(detail['paymentType']), int)
            self.assertIn(detail['paymentType'], [1,2] )

            self.assertIs(type(detail['receivedBy']), str)
            self.assertEquals(detail['receivedBy'], 'user one receive')
            self.assertEquals(detail['serviceName'], 'service 1 s')
            self.assertEquals(detail['patientName'], 'patient 1 z')

            self.assertIs(type(detail['paymentTypeName']), str)
            self.assertIn(detail['paymentTypeName'], ['CASH', 'VISA'] )

            self.assertIs(type(detail['paymentType']), int)
Пример #4
0
    def get(self):

        details_fields = {
            "id": fields.Integer(),
            "paymentType": fields.String,
            "paymentTypeName": fields.String,
            "receivedBy": fields.String,
            "serviceName": fields.String,
            "patientName": fields.String,
            "amount": fields.String,
            "paymentDateTime": fields.DateTime(dt_format="iso8601"),
        }

        result_fields = {"details": fields.Nested(details_fields), "total": fields.String}

        qParser = reqparse.RequestParser()

        qParser.add_argument("fromDate", type=dateInput, default=None)
        qParser.add_argument("toDate", type=dateInput, default=None)
        qParser.add_argument("user_id", type=int, default=None)

        args = qParser.parse_args()

        fromDate = args.get("fromDate")
        toDate = args.get("toDate")
        user_id = args.get("user_id")

        report = IncomeDetailsReport()
        report.filterDateRange(fromDate, toDate)
        report.filterByUser(user_id)

        result = report.result()
        return marshal(result, result_fields)