class PatientSummariesReport(object): """total income, total refunds, discounts, ordered price, amount due by certain patient """ def __init__(self): self.patient_id = None self.ordersDetailsReport = OrdersDetailsReport() self.incomeReport = IncomeReport() self.refundsReport = RefundsReport() def filterDateRange(self, startDate=None, endDate=None): startTime = datetime.time(00, 00) endTime = datetime.time(23, 59) self.startDate = startDate if startDate else datetime.date.today() self.endDate = endDate if endDate else datetime.date.today() self.startDate = datetime.datetime.combine(self.startDate, startTime) self.endDate = datetime.datetime.combine(self.endDate, endTime) def filterByPatient(self, patient_id=None): self.patient_id = patient_id def result(self): self.ordersDetailsReport.filterDateRange(self.startDate, self.endDate) self.incomeReport.filterDateRange(self.startDate, self.endDate) self.refundsReport.filterDateRange(self.startDate, self.endDate) self.ordersDetailsReport.filterByPatient(self.patient_id) self.incomeReport.filterByPatient(self.patient_id) self.refundsReport.filterByPatient(self.patient_id) return {"totalPayments": self.incomeReport.result(), "totalRefunds": self.refundsReport.result(), "ordersSummary": self.ordersDetailsReport.result()}
class NetIncomeReport(object): def __init__(self): self.incomReport = IncomeReport() self.refundsReport = RefundsReport() self.category_id = None def filterDateRange(self, startDate=None, endDate=None): startTime = datetime.time(00, 00) endTime = datetime.time(23, 59) self.startDate = startDate if startDate else datetime.date.today() self.endDate = endDate if endDate else datetime.date.today() self.startDate = datetime.datetime.combine(self.startDate, startTime) self.endDate = datetime.datetime.combine(self.endDate, endTime) self.incomReport.filterDateRange(self.startDate, self.endDate) self.refundsReport.filterDateRange(self.startDate, self.endDate) def filterByCategory(self, category_id=None): self.category_id = category_id self.incomReport.filterByCategory(category_id) self.refundsReport.filterByCategory(category_id) def result(self): incomeResult = self.incomReport.result() refundsResult = self.refundsReport.result() netIncome = incomeResult["total"] - refundsResult["refundamount"] result = {'refunds': refundsResult, 'income': incomeResult, 'netIncome': netIncome} return result
def test_defaultDate_report(self): incomeReport = IncomeReport() # datetime.date(2016, 3, 12) incomeReport.filterDateRange() result = incomeReport.result() # print(result) expected = {'total':1900 ,'details': [{"paymentType": 1,"paymentTypeName":"CASH","amount":1300},{"paymentType": 2,"paymentTypeName":"VISA","amount":600}]} self.assertEquals(expected, result)
def get(self): qParser = reqparse.RequestParser() qParser.add_argument("fromDate", type=dateInput, default=None) qParser.add_argument("toDate", type=dateInput, default=None) args = qParser.parse_args() fromDate = args.get("fromDate") toDate = args.get("toDate") incomeReport = IncomeReport() incomeReport.filterDateRange(fromDate, toDate) return incomeReport.result()
def get(self): qParser = reqparse.RequestParser() qParser.add_argument('fromDate', type=dateInput, default=None) qParser.add_argument('toDate', type=dateInput, default=None) qParser.add_argument('category_id', type=int, default=None) args = qParser.parse_args() fromDate = args.get('fromDate') toDate = args.get('toDate') category_id = args.get('category_id') incomeReport = IncomeReport() incomeReport.filterDateRange(fromDate, toDate) incomeReport.filterByCategory(category_id) return incomeReport.result()
def __init__(self): self.incomReport = IncomeReport() self.refundsReport = RefundsReport() self.category_id = None
def __init__(self): self.patient_id = None self.ordersDetailsReport = OrdersDetailsReport() self.incomeReport = IncomeReport() self.refundsReport = RefundsReport()
def __init__(self): self.incomReport = IncomeReport() self.refundsReport = RefundsReport()