Class: Spree::Kashflow::SyncRefundJob
- Inherits:
-
BaseJob
- Object
- BaseJob
- Spree::Kashflow::SyncRefundJob
- Defined in:
- app/jobs/spree/kashflow/sync_refund_job.rb
Overview
Posts a refund to KashFlow as a credit note, linked to the original invoice
via applyCreditNoteToInvoice.
A resumable state machine, the same way as SyncOrderJob: posting the credit note and linking it to the original invoice are two separate calls, each with its own marker written the instant it succeeds (Metafields::REFUND_CREDIT_NOTE_NUMBER and Metafields::REFUND_CREDIT_NOTE_LINKED_AT), and each guarded independently in #sync. A rerun resumes at the first unfinished step.
Instance Method Summary collapse
Instance Method Details
#perform(refund_id) ⇒ void
This method returns an undefined value.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/jobs/spree/kashflow/sync_refund_job.rb', line 33 def perform(refund_id) refund = Spree::Refund.find_by(id: refund_id) return if refund.nil? order = refund.order integration = Spree::Integrations::Kashflow.active.find_by(store: order.store) return if integration.nil? return if credit_note_posted?(refund) && credit_note_linked?(refund) sync(refund, order, integration) rescue Spree::Kashflow::Error => e Metafields.write(order, Metafields::ORDER_SYNC_ERROR, e.) raise end |