Skip to content

Commit

Permalink
Rename ReceiveDirectPayment operation to CreateDirectReceipt
Browse files Browse the repository at this point in the history
  • Loading branch information
akadusei committed Aug 19, 2024
1 parent 16750f4 commit 58e81e6
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Rename `Bill::SendDirectReceiptEmail` to `Bill::SendFinalizedDirectReceiptEmail`
- Merge mixin presets into their respective main modules
- Rename `ReceivePayment` operation to `CreateReceipt`
- Rename `ReceiveDirectPayment` operation to `CreateDirectReceipt`

### Fixed
- Auto mark invoices as paid only when transaction was newly finalized
Expand Down
4 changes: 2 additions & 2 deletions docs/04-TRANSACTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ The ledger is immutable -- once transactions are recorded, they are never update

---
```crystal
# ->>> src/operations/receive_direct_payment.cr
# ->>> src/operations/create_direct_receipt.cr
class ReceiveDirectPayment < Transaction::SaveOperation
class CreateDirectReceipt < Transaction::SaveOperation
# ...
include Bill::SendFinalizedDirectReceiptEmail
# ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ require "../../spec_helper"
private class SaveTransaction < Transaction::SaveOperation
permit_columns :reference

include Bill::ReceiveDirectPayment
include Bill::CreateDirectReceipt
end

describe Bill::ReceiveDirectPayment do
describe Bill::CreateDirectReceipt do
it "creates receipt transaction" do
description = "New receipt"
amount = 45
Expand Down
2 changes: 1 addition & 1 deletion spec/support/app/src/actions/direct_receipts/new.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class DirectReceipts::New < BrowserAction
include Bill::DirectReceipts::New

get "/direct-receipts/new" do
operation = ReceiveDirectPayment.new
operation = CreateDirectReceipt.new
html NewPage, operation: operation
end
end
3 changes: 3 additions & 0 deletions spec/support/app/src/operations/create_direct_receipt.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class CreateDirectReceipt < Transaction::SaveOperation
include Bill::CreateDirectReceipt
end
3 changes: 0 additions & 3 deletions spec/support/app/src/operations/receive_direct_payment.cr

This file was deleted.

2 changes: 1 addition & 1 deletion spec/support/app/src/pages/direct_receipts/new_page.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
struct DirectReceipts::NewPage < MainLayout
needs operation : ReceiveDirectPayment
needs operation : CreateDirectReceipt

def content
text "DirectReceipts::NewPage"
Expand Down
2 changes: 1 addition & 1 deletion src/bill/actions/api/direct_receipts/create.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Bill::Api::DirectReceipts::Create
# end

def run_operation
ReceiveDirectPayment.create(params) do |operation, transaction|
CreateDirectReceipt.create(params) do |operation, transaction|
if operation.saved?
do_run_operation_succeeded(operation, transaction.not_nil!)
else
Expand Down
2 changes: 1 addition & 1 deletion src/bill/actions/direct_receipts/create.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Bill::DirectReceipts::Create
# end

def run_operation
ReceiveDirectPayment.create(params) do |operation, transaction|
CreateDirectReceipt.create(params) do |operation, transaction|
if operation.saved?
do_run_operation_succeeded(operation, transaction.not_nil!)
else
Expand Down
2 changes: 1 addition & 1 deletion src/bill/actions/direct_receipts/new.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Bill::DirectReceipts::New
macro included
# get "/receipts/new" do
# operation = ReceiveDirectPayment.new
# operation = CreateDirectReceipt.new
# html NewPage, operation: operation
# end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Receives payment without creating a `Receipt` record
module Bill::ReceiveDirectPayment # Transaction::SaveOperation
module Bill::CreateDirectReceipt # Transaction::SaveOperation
macro included
before_save do
set_type
Expand Down
4 changes: 2 additions & 2 deletions src/presets/transaction.cr
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ end
include Bill::RefundPayment
end
{% else %}
class ReceiveDirectPayment < Transaction::SaveOperation
include Bill::ReceiveDirectPayment
class CreateDirectReceipt < Transaction::SaveOperation
include Bill::CreateDirectReceipt
end

class UpdateDirectReceipt < Transaction::SaveOperation
Expand Down

0 comments on commit 58e81e6

Please sign in to comment.