def post_lost_notover_acc(self): borrhis = fn_db.get("LIT_BORRHIS", "bookinsid", "T_BI8") self.assertEqual(borrhis.overdays, -2) self.assertEqual(borrhis.overprice, 0) self.assertEqual(borrhis.lostprice, 53.6 * 2.0) self.assertEqual(borrhis.overpaycd, None) self.assertEqual(borrhis.lostpaycd, "ACC") self.assertEqual(borrhis.lostnote, "note") self.assertTrue( any( fn_db.db.select( "LIT_BORRLOG", where="bookinsid='T_BI8' and actcd='GIVEBACK'"))) self.assertFalse( any( fn_db.db.select( "LIT_BORRLOG", where="bookinsid='T_BI8' and actcd='OVERDUE'"))) log3 = fn_db.db.select("LIT_BORRLOG", where="bookinsid='T_BI8' and actcd='LOST'")[0] self.assertEqual(log3.actval, 53.6 * 2.0) self.assertEqual(log3.paycd, "ACC") self.assertEqual( fn_db.get("LIM_READER", "readerid", "T_R02").deposit, 100 - 53.6 * 2.0)
def postgiveback_over(self): self.assertEqual(fn_db.get("LIT_BORRNOW", "bookinsid", "T_BI6"), None) borrhis = fn_db.get("LIT_BORRHIS", "bookinsid", "T_BI6") self.assertEqual(borrhis.overdays, self.overdays2) self.assertEqual(borrhis.overprice, self.overdays2 * 0.28) bookins = fn_db.get("LIM_BOOKINS", "bookinsid", "T_BI6") self.assertEqual(bookins.inssts, "0") self.assertEqual(bookins.readerid, "") reader = fn_db.get("LIM_READER", "readerid", "T_R02") self.assertEqual(reader.quantity, 28)
def post_lost_notover_cash(self): borrhis = fn_db.get("LIT_BORRHIS", "bookinsid", "T_BI7") self.assertEqual(borrhis.overdays, -2) self.assertEqual(borrhis.overprice, 0) self.assertEqual(borrhis.lostprice, 23.6 * 2.0) self.assertEqual(borrhis.overpaycd, None) self.assertEqual(borrhis.lostpaycd, "CASH") self.assertEqual(borrhis.lostnote, "note") self.assertTrue( any( fn_db.db.select( "LIT_BORRLOG", where="bookinsid='T_BI7' and actcd='GIVEBACK'"))) self.assertFalse( any( fn_db.db.select( "LIT_BORRLOG", where="bookinsid='T_BI7' and actcd='OVERDUE'"))) log3 = fn_db.db.select("LIT_BORRLOG", where="bookinsid='T_BI7' and actcd='LOST'")[0] self.assertEqual(log3.actval, 23.6 * 2.0) self.assertEqual(log3.paycd, "CASH")
def postborrowe(self): afterquantity = fn_db.get("LIM_READER", "readerid", "T_R01").quantity self.assertEqual(49, afterquantity) bookins = fn_db.get("LIM_BOOKINS", "bookinsid", "T_BI1") self.assertEqual(bookins.inssts, "1") self.assertEqual(bookins.readerid, "T_R01") borrnow = fn_db.db.select("LIT_BORRNOW", where = "readerid=$readerid and bookinsid=$bookinsid", vars = dict(readerid = "T_R01", bookinsid = "T_BI1"))[0] self.assertEqual(borrnow.readerid, "T_R01") self.assertEqual(borrnow.readercardno, "T_C01") self.assertEqual(borrnow.bookinsid, "T_BI1") dtlimit = datetime.datetime.now() + datetime.timedelta(days = 20) self.assertEqual(borrnow.borrexpdt.date(), dtlimit.date())
def post_lost_notover_acc(self): borrhis = fn_db.get("LIT_BORRHIS", "bookinsid", "T_BI8") self.assertEqual(borrhis.overdays, -2) self.assertEqual(borrhis.overprice, 0) self.assertEqual(borrhis.lostprice, 53.6 * 2.0) self.assertEqual(borrhis.overpaycd, None) self.assertEqual(borrhis.lostpaycd, "ACC") self.assertEqual(borrhis.lostnote, "note") self.assertTrue(any(fn_db.db.select("LIT_BORRLOG", where = "bookinsid='T_BI8' and actcd='GIVEBACK'"))) self.assertFalse(any(fn_db.db.select("LIT_BORRLOG", where = "bookinsid='T_BI8' and actcd='OVERDUE'"))) log3 = fn_db.db.select("LIT_BORRLOG", where = "bookinsid='T_BI8' and actcd='LOST'")[0] self.assertEqual(log3.actval, 53.6 * 2.0) self.assertEqual(log3.paycd, "ACC") self.assertEqual(fn_db.get("LIM_READER", "readerid", "T_R02").deposit, 100 - 53.6 * 2.0)
def postgiveback_notover(self): self.assertEqual(fn_db.get("LIT_BORRNOW", "bookinsid", "T_BI5"), None) borrhis = fn_db.get("LIT_BORRHIS", "bookinsid", "T_BI5") self.assertEqual(borrhis.readerid, "T_R02") self.assertEqual(borrhis.readercardno, "T_C02") self.assertEqual(borrhis.bookinsid, "T_BI5") self.assertEqual(borrhis.renewtimes, 1) self.assertEqual(borrhis.borrdt, self.borrdt) self.assertEqual(borrhis.borrexpdt, self.borrexpdt) self.assertEqual(borrhis.overdays, 0 - self.overdays) self.assertEqual(borrhis.overprice, 0) self.assertEqual(borrhis.retdt.date(), datetime.datetime.now().date()) bookins = fn_db.get("LIM_BOOKINS", "bookinsid", "T_BI5") self.assertEqual(bookins.inssts, "0") self.assertEqual(bookins.readerid, "") reader = fn_db.get("LIM_READER", "readerid", "T_R02") self.assertEqual(reader.quantity, 29)
def post_lost_notover_cash(self): borrhis = fn_db.get("LIT_BORRHIS", "bookinsid", "T_BI7") self.assertEqual(borrhis.overdays, -2) self.assertEqual(borrhis.overprice, 0) self.assertEqual(borrhis.lostprice, 23.6 * 2.0) self.assertEqual(borrhis.overpaycd, None) self.assertEqual(borrhis.lostpaycd, "CASH") self.assertEqual(borrhis.lostnote, "note") self.assertTrue(any(fn_db.db.select("LIT_BORRLOG", where = "bookinsid='T_BI7' and actcd='GIVEBACK'"))) self.assertFalse(any(fn_db.db.select("LIT_BORRLOG", where = "bookinsid='T_BI7' and actcd='OVERDUE'"))) log3 = fn_db.db.select("LIT_BORRLOG", where = "bookinsid='T_BI7' and actcd='LOST'")[0] self.assertEqual(log3.actval, 23.6 * 2.0) self.assertEqual(log3.paycd, "CASH")
def deface_acc(self): fn_db.db.delete("LIT_BORRLOG", where="borrhisid='T_HIS_deface_acc'") kw = dict(borrhisid="T_HIS_deface_acc", insby="operator", updby="operator", readerid="T_R02", readercardno="T_C02", bookinsid="T_BI1") fn_db.ins("LIT_BORRHIS", **kw) fn_db.upd("LIM_READER", "readerid", "T_R02", deposit=100) model = model_giveback.ModelGiveback() model.deface("operator2", "T_HIS_deface_acc", 12.5, "ACC", "NOTE") self.assertEqual( fn_db.get("LIM_READER", "readerid", "T_R02").deposit, 100 - 12.5) borrhis = model.get_borrhis("T_HIS_deface_acc") self.assertEqual(borrhis.defaceprice, 12.5) self.assertEqual(borrhis.defacepaycd, "ACC") self.assertEqual(borrhis.defacenote, "NOTE") log = fn_db.db.select( "LIT_BORRLOG", where="borrhisid='T_HIS_deface_acc' and actcd='DEFACE'")[0] self.assertEqual(log.paycd, "ACC") self.assertEqual(log.actval, 12.5)