def get_subtasks_payments(subtask_ids: Iterable[str]) -> List[Payment]: return list( Payment.select( Payment.subtask, Payment.value, Payment.details, Payment.status, ).where(Payment.subtask.in_(subtask_ids), ))
def get_newest_payment(num=30): """ Return specific number of recently modified payments :param num: number of payments to return :return: """ query = Payment.select().order_by( Payment.modified_date.desc()).limit(num) return query.execute()
def test_create(self): p = Payment(payee="DEF", subtask="xyz", value=5, status=PaymentStatus.awaiting) self.assertEquals(p.save(force_insert=True), 1) with self.assertRaises(IntegrityError): Payment.create(payee="DEF", subtask="xyz", value=5, status=PaymentStatus.awaiting) Payment.create(payee="DEF", subtask="xyz2", value=4, status=PaymentStatus.confirmed) Payment.create(payee="DEF2", subtask="xyz4", value=5, status=PaymentStatus.sent) self.assertEqual(3, len([payment for payment in Payment.select()]))