def payment_history(self): try: journals = Journal.find_all_by_order(self) ret = '<table cellpadding="0" cellspacing="10" border="0"><tr><td><u>Date</u></td><td><u>Method</u></td><td><u>Note</u></td><td><u>Amount</u></td></tr>' for j in journals: ret += """<tr> <td>{dt}</td><td nowrap>{meth}</td><td>{note}</td><td align="right">{amt}</td> </tr> """.format( dt=util.slash_date(j.create_dt), amt=util.money(j.amount), meth=j.method, note=j.note ) ret += '<tr><td colspan="4"><hr></td></tr>' ret += ( '<tr><td><i>Total Payments Applied</i></td><td colspan="2"> </td><td align="right">%s</td></tr>' % util.money(self.total_payments_applied(), True) ) ret += "</table>" return ret except Exception as exc: # pragma: no cover log.debug(exc)
def cancel(self, reason, by_customer=False): self.cancel_dt = datetime.datetime.date(datetime.datetime.now()) for oitem in self.active_items: prod = oitem.product InventoryJournal.create_new(prod, "Cancelled Order", oitem.quantity, oitem) oitem.delete_dt = util.today() oitem.save() journals = Journal.find_all_by_order(self) for j in journals: j.delete_dt = util.today() j.save() msg = "Order Canceled" if not by_customer else "Order Cancelled by Customer" Status.add( self.customer, self, Status.find_event(self.customer.campaign.company.enterprise_id, self, "CREATED"), "%s : %s" % (msg, reason), ) self.save()