def status_update(self): payout = BankWirePayOut.get(Id=self.poid) if self.status == payout.status: return self.status self.status = payout.status self.execution_date = payout['ExecutionDate'] self.save() return self.status
def record_payout_refund(db, payout_refund): orig_payout = BankWirePayOut.get(payout_refund.InitialTransactionId) e_origin = db.one("SELECT * FROM exchanges WHERE id = %s" % (orig_payout.Tag,)) e_refund_id = db.one("SELECT id FROM exchanges WHERE refund_ref = %s", (e_origin.id,)) if e_refund_id: # Already recorded return e_refund_id amount, fee, vat = -e_origin.amount, -e_origin.fee, -e_origin.vat assert payout_refund.DebitedFunds == Money(int(amount * 100), 'EUR') assert payout_refund.Fees == Money(int(fee * 100), 'EUR') route = ExchangeRoute.from_id(e_origin.route) participant = Participant.from_id(e_origin.participant) return db.one(""" INSERT INTO exchanges (amount, fee, vat, participant, status, route, note, refund_ref) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) RETURNING id """, (amount, fee, vat, participant.id, 'created', route.id, None, e_origin.id))
def record_payout_refund(db, payout_refund): orig_payout = BankWirePayOut.get(payout_refund.InitialTransactionId) e_origin = db.one("SELECT * FROM exchanges WHERE id = %s", (orig_payout.Tag,)) e_refund_id = db.one("SELECT id FROM exchanges WHERE refund_ref = %s", (e_origin.id,)) if e_refund_id: # Already recorded return e_refund_id amount, fee, vat = -e_origin.amount, -e_origin.fee, -e_origin.vat assert payout_refund.DebitedFunds / 100 == amount assert payout_refund.Fees / 100 == fee route = ExchangeRoute.from_id(e_origin.route) participant = Participant.from_id(e_origin.participant) remote_id = payout_refund.Id wallet_id = e_origin.wallet_id return db.one(""" INSERT INTO exchanges (amount, fee, vat, participant, status, route, note, refund_ref, remote_id, wallet_id) VALUES (%s, %s, %s, %s, 'created', %s, NULL, %s, %s, %s) RETURNING id """, (amount, fee, vat, participant.id, route.id, e_origin.id, remote_id, wallet_id))
def record_payout_refund(db, payout_refund): orig_payout = BankWirePayOut.get(payout_refund.InitialTransactionId) e_origin = db.one("SELECT * FROM exchanges WHERE id = %s", (orig_payout.Tag,)) e_refund_id = db.one("SELECT id FROM exchanges WHERE refund_ref = %s", (e_origin.id,)) if e_refund_id: # Already recorded return e_refund_id amount, fee, vat = -e_origin.amount, -e_origin.fee, -e_origin.vat assert payout_refund.DebitedFunds / 100 == amount assert payout_refund.Fees / 100 == fee participant = Participant.from_id(e_origin.participant) route = ExchangeRoute.from_id(participant, e_origin.route) remote_id = payout_refund.Id wallet_id = e_origin.wallet_id return db.one(""" INSERT INTO exchanges (amount, fee, vat, participant, status, route, note, refund_ref, remote_id, wallet_id) VALUES (%s, %s, %s, %s, 'created', %s, NULL, %s, %s, %s) RETURNING id """, (amount, fee, vat, participant.id, route.id, e_origin.id, remote_id, wallet_id))