@@ -5,7 +5,7 @@ module V1
55 class CreditNotesController < Api ::BaseController
66 include CreditNoteIndex
77 def create
8- result = CreditNotes ::CreateService . call (
8+ result = :: CreditNotes ::CreateService . call (
99 invoice : current_organization . invoices . visible . find_by ( id : input_params [ :invoice_id ] ) ,
1010 **input_params
1111 )
@@ -40,12 +40,12 @@ def update
4040 credit_note = current_organization . credit_notes . find_by ( id : params [ :id ] )
4141 return not_found_error ( resource : "credit_note" ) unless credit_note
4242
43- result = CreditNotes ::UpdateService . new ( credit_note :, **update_params ) . call
43+ result = :: CreditNotes ::UpdateService . new ( credit_note :, partial_metadata : true , **update_params ) . call
4444
4545 if result . success?
4646 render (
4747 json : ::V1 ::CreditNoteSerializer . new (
48- credit_note ,
48+ result . credit_note ,
4949 root_name : "credit_note" ,
5050 includes : %i[ items applied_taxes ]
5151 )
@@ -68,7 +68,7 @@ def download_pdf
6868 )
6969 end
7070
71- CreditNotes ::GeneratePdfJob . perform_later ( credit_note )
71+ :: CreditNotes ::GeneratePdfJob . perform_later ( credit_note )
7272
7373 head ( :ok )
7474 end
@@ -86,7 +86,7 @@ def download_xml
8686 )
8787 end
8888
89- CreditNotes ::GenerateXmlJob . perform_later ( credit_note )
89+ :: CreditNotes ::GenerateXmlJob . perform_later ( credit_note )
9090
9191 head ( :ok )
9292 end
@@ -95,7 +95,7 @@ def void
9595 credit_note = current_organization . credit_notes . find_by ( id : params [ :id ] )
9696 return not_found_error ( resource : "credit_note" ) unless credit_note
9797
98- result = CreditNotes ::VoidService . new ( credit_note :) . call
98+ result = :: CreditNotes ::VoidService . new ( credit_note :) . call
9999
100100 if result . success?
101101 render (
@@ -118,7 +118,7 @@ def index
118118 end
119119
120120 def estimate
121- result = CreditNotes ::EstimateService . call (
121+ result = :: CreditNotes ::EstimateService . call (
122122 invoice : current_organization . invoices . visible . find_by ( id : estimate_params [ :invoice_id ] ) ,
123123 items : estimate_params [ :items ]
124124 )
@@ -145,6 +145,7 @@ def input_params
145145 :description ,
146146 :credit_amount_cents ,
147147 :refund_amount_cents ,
148+ metadata : { } ,
148149 items : [
149150 :fee_id ,
150151 :amount_cents
@@ -153,7 +154,7 @@ def input_params
153154 end
154155
155156 def update_params
156- params . require ( :credit_note ) . permit ( :refund_status )
157+ params . require ( :credit_note ) . permit ( :refund_status , metadata : { } )
157158 end
158159
159160 def estimate_params
0 commit comments