-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a12070f
commit 1ca5444
Showing
10 changed files
with
196 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class InvoiceCreatorsController < ParentController | ||
def index | ||
@invoices = Invoice.where(initiator: 'billing_system').order(created_at: :desc) | ||
end | ||
|
||
def new | ||
invoice_number = InvoiceNumberService.call | ||
@invoice = Invoice.new( | ||
invoice_number:, | ||
affiliation: :linkpay, | ||
initiator: 'billing_system' | ||
) | ||
end | ||
|
||
def create | ||
@invoice = Invoice.new | ||
@invoice.invoice_number = params[:invoice][:invoice_number] | ||
@invoice.affiliation = params[:invoice][:affiliation] | ||
@invoice.initiator = params[:invoice][:initiator] | ||
@invoice.transaction_amount = params[:invoice][:transaction_amount] | ||
@invoice.description = params[:invoice][:description] | ||
|
||
ActiveRecord::Base.transaction do | ||
@invoice.save! | ||
|
||
linkpay_params_mutation = params[:linkpay].merge( | ||
invoice_number: @invoice.invoice_number, | ||
transaction_amount: @invoice.transaction_amount, | ||
) | ||
|
||
@linkpay = EverypayLinkGenerator.create(params: linkpay_params_mutation) | ||
@invoice.everypay_response = { | ||
linkpay: @linkpay, | ||
} | ||
|
||
@invoice.save! | ||
end | ||
|
||
redirect_to invoice_creators_path, notice: 'Invoice was successfully created.', status: :see_other | ||
rescue ActiveRecord::RecordInvalid => e | ||
flash.now[:error] = e.message | ||
render :new and return | ||
end | ||
|
||
def show; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<h1 class='text-2xl font-bold text-center'>Invoice data</h1> | ||
|
||
<div class="my-2"> | ||
<%= f.label :invoice_number, class: "text-sm font-bold" %><br> | ||
<%= f.text_field :invoice_number, autofocus: true, required: true, | ||
class: "w-full px-3 py-2 mt-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm bg-gray-200", | ||
placeholder: "", readonly: true %> | ||
</div> | ||
|
||
<div class="my-2"> | ||
<%= f.label :affiliation, class: "text-sm font-bold" %><br> | ||
<%= f.text_field :affiliation, autofocus: true, required: true, | ||
class: "w-full px-3 py-2 mt-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm bg-gray-200", | ||
placeholder: "", readonly: true %> | ||
</div> | ||
|
||
<div class="my-2"> | ||
<%= f.label :initiator, class: "text-sm font-bold" %><br> | ||
<%= f.text_field :initiator, autofocus: true, required: true, | ||
class: "w-full px-3 py-2 mt-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm bg-gray-200", | ||
placeholder: "", readonly: true %> | ||
</div> | ||
|
||
<div class="my-2"> | ||
<%= f.label :transaction_amount, class: "text-sm font-bold" %><br> | ||
<%= f.number_field :transaction_amount, step: '0.01', autofocus: true, required: true, | ||
class: "w-full px-3 py-2 mt-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm", | ||
placeholder: "" %> | ||
</div> | ||
|
||
<div class="my-2"> | ||
<%= f.label :description, class: "text-sm font-bold" %><br> | ||
<%= f.text_area :description, class: "w-full px-3 py-2 mt-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm", rows: 10 %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<h1 class='text-2xl font-bold text-center'>Linkpay data</h1> | ||
|
||
<div class="my-2"> | ||
<%= f.label :customer_name, class: "text-sm font-bold" %><br> | ||
<%= f.text_field :customer_name, autofocus: true, required: true, | ||
class: "w-full px-3 py-2 mt-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm", | ||
placeholder: "" %> | ||
</div> | ||
|
||
<div class="my-2"> | ||
<%= f.label :customer_email, class: "text-sm font-bold" %><br> | ||
<%= f.text_field :customer_email, autofocus: true, required: true, | ||
class: "w-full px-3 py-2 mt-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm", | ||
placeholder: "" %> | ||
</div> | ||
|
||
<div class="my-2"> | ||
<%= f.label :custom_field1, 'description', class: "text-sm font-bold" %><br> | ||
<%= f.text_field :custom_field1, autofocus: true, required: true, | ||
class: "w-full px-3 py-2 mt-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm", | ||
placeholder: "" %> | ||
</div> | ||
|
||
<div class="my-2"> | ||
<%= f.label :custom_field2, class: "text-sm font-bold" %><br> | ||
<%= f.text_field :custom_field2, autofocus: true, required: true, | ||
class: "w-full px-3 py-2 mt-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm bg-gray-200", | ||
placeholder: "" , value: 'billing_system', readonly: true %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<div class="container mx-auto"> | ||
<div class='flex flex-row'> | ||
<%= link_to 'New Invoice', new_invoice_creator_path, | ||
class: 'h-10 py-2 my-1 px-4 border border-transparent text-sm font-semibold rounded-md text-white bg-violet-700 hover:bg-violet-800 transition duration-150 ease-in-out shadow-md cursor-pointer' %> | ||
</div> | ||
|
||
<div> | ||
<table class="min-w-full mt-6"> | ||
<thead> | ||
<tr> | ||
<th class="px-6 py-1 border-b border-gray-200 bg-gray-50 text-left text-xs text-gray-500 uppercase">Invoice number</th> | ||
<th class="px-6 py-1 border-b border-gray-200 bg-gray-50 text-left text-xs text-gray-500 uppercase">Status</th> | ||
<th class="px-6 py-1 border-b border-gray-200 bg-gray-50 text-left text-xs text-gray-500 uppercase">transaction_amount</th> | ||
<th class="px-6 py-1 border-b border-gray-200 bg-gray-50 text-left text-xs text-gray-500 uppercase">Linkpay URL</th> | ||
</tr> | ||
</thead> | ||
<tbody id="invoices"> | ||
<% @invoices.each do |invoice| %> | ||
<tr> | ||
<td class="px-6 py-1 border-b border-gray-200"><%= invoice.invoice_number %></td> | ||
<td class="px-6 py-1 border-b border-gray-200"><%= invoice.status %></td> | ||
<td class="px-6 py-1 border-b border-gray-200"><%= invoice.transaction_amount %></td> | ||
<td class="px-6 py-1 border-b border-gray-200 break-all"><%= invoice.everypay_response["linkpay"] if invoice.everypay_response.present? %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div class="container mx-auto"> | ||
<div class='ml-4 p-6 bg-white'> | ||
<%= form_with url: invoice_creators_path do |form| %> | ||
|
||
<%= form.fields_for @invoice do |f|%> | ||
<%= render 'invoice_creators/invoice_form', f: f %> | ||
<% end %> | ||
|
||
<%= form.fields_for :linkpay do |f| %> | ||
<%= render 'invoice_creators/linkpay_form', f: f %> | ||
<% end %> | ||
|
||
<div class="my-2 text-center"> | ||
<%= form.submit 'Create', class: "h-10 py-2 mt-4 px-4 border border-transparent text-sm font-semibold rounded-md text-white bg-violet-700 hover:bg-violet-800 transition duration-150 ease-in-out shadow-md cursor-pointer" %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ | |
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters