move to ajax function for every direct debit xml download

This commit is contained in:
viehlieb 2023-11-28 16:39:24 +01:00
parent 636aad0b3e
commit f98d083647
23 changed files with 158 additions and 128 deletions

View file

@ -86,10 +86,10 @@ class GroupOrderInvoicesController < ApplicationController
end end
end end
def toggle_payed def toggle_paid
@group_order_invoice = GroupOrderInvoice.find(params[:id]) @group_order_invoice = GroupOrderInvoice.find(params[:id])
respond_to do |format| respond_to do |format|
@group_order_invoice.payed = !@group_order_invoice.payed @group_order_invoice.paid = !@group_order_invoice.paid
if @group_order_invoice.save! if @group_order_invoice.save!
format.js format.js
else else
@ -111,11 +111,11 @@ class GroupOrderInvoicesController < ApplicationController
end end
end end
def toggle_all_payed def toggle_all_paid
@order = Order.find(params[:order_id]) @order = Order.find(params[:order_id])
@group_order_invoices = @order.group_orders.map(&:group_order_invoice).compact @group_order_invoices = @order.group_orders.map(&:group_order_invoice).compact
@group_order_invoices.each do |goi| @group_order_invoices.each do |goi|
goi.payed = !ActiveRecord::Type::Boolean.new.deserialize(params[:payed]) goi.paid = !ActiveRecord::Type::Boolean.new.deserialize(params[:paid])
goi.save! goi.save!
end end
respond_to do |format| respond_to do |format|

View file

@ -177,17 +177,21 @@ class OrdersController < ApplicationController
export_allowed = !ordergroups.map(&:sepa_possible?).include?(false) && !group_orders.map { |go| go.group_order_invoice.present? }.include?(false) export_allowed = !ordergroups.map(&:sepa_possible?).include?(false) && !group_orders.map { |go| go.group_order_invoice.present? }.include?(false)
group_order_ids = group_orders.map { |go| go.id if go.group_order_invoice.present? } group_order_ids = group_orders.map { |go| go.id if go.group_order_invoice.present? }
sepa_possible_ordergroup_names = ordergroups.map { |ordergroup| ordergroup.name unless ordergroup.sepa_possible? }.compact_blank sepa_possible_ordergroup_names = ordergroups.map { |ordergroup| ordergroup.name if ordergroup.sepa_possible? }.compact_blank
sepa_not_possible_ordergroup_names = ordergroups.map(&:name) - sepa_possible_ordergroup_names
if export_allowed && group_orders.present? if export_allowed && group_orders.present?
respond_to do |format| respond_to do |format|
format.html do format.html do
group_orders.map(&:group_order_invoice).each(&:mark_sepa_downloaded)
collective_debit = OrderCollectiveDirectDebitXml.new(group_orders) collective_debit = OrderCollectiveDirectDebitXml.new(group_orders)
send_data collective_debit.xml_string, filename: @order.name + '_Sammellastschrift' + '.xml', type: 'text/xml' send_data collective_debit.xml_string, filename: @order.name + '_Sammellastschrift' + '.xml', type: 'text/xml'
group_orders.map(&:group_order_invoice).each(&:mark_sepa_downloaded)
rescue SEPA::Error => e
group_orders.map(&:group_order_invoice).each(&:unmark_sepa_downloaded)
redirect_to finance_order_index_path, alert: e.message
rescue StandardError => e rescue StandardError => e
group_orders.map(&:group_order_invoice).each(&:unmark_sepa_downloaded) group_orders.map(&:group_order_invoice).each(&:unmark_sepa_downloaded)
redirect_to finance_order_index_path, alert: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_possible_ordergroup_names.join(', ')) redirect_to finance_order_index_path, alert: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_not_possible_ordergroup_names.join(', '), error: e.message)
end end
format.xml do format.xml do
group_orders.map(&:group_order_invoice).each(&:mark_sepa_downloaded) group_orders.map(&:group_order_invoice).each(&:mark_sepa_downloaded)
@ -195,17 +199,20 @@ class OrdersController < ApplicationController
send_data collective_debit.xml_string, filename: @order.name + '_Sammellastschrift' + '.xml', type: 'text/xml' send_data collective_debit.xml_string, filename: @order.name + '_Sammellastschrift' + '.xml', type: 'text/xml'
rescue SEPA::Error => e rescue SEPA::Error => e
group_orders.map(&:group_order_invoice).each(&:unmark_sepa_downloaded) group_orders.map(&:group_order_invoice).each(&:unmark_sepa_downloaded)
render json: { error: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_possible_ordergroup_names.join(', ')) } render json: { error: e.message }
rescue StandardError => e
group_orders.map(&:group_order_invoice).each(&:unmark_sepa_downloaded)
render json: { error: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_not_possible_ordergroup_names.join(', '), error: e.message) }
end end
format.js format.js
end end
else else
respond_to do |format| respond_to do |format|
format.html do format.html do
redirect_to finance_order_index_path, alert: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_possible_ordergroup_names.join(', ')) redirect_to finance_order_index_path, alert: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_not_possible_ordergroup_names.join(', '), error: '')
end end
format.xml do format.xml do
render json: { error: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_possible_ordergroup_names.join(', ')) } render json: { error: I18n.t('orders.collective_direct_debit.alert', ordergroup_names: sepa_not_possible_ordergroup_names.join(', '), error: '') }
end end
format.js format.js
end end

View file

@ -5,41 +5,28 @@ class OrderCollectiveDirectDebitXml
def initialize(group_orders) def initialize(group_orders)
batch_booking = group_orders.count > 1 ? true : false batch_booking = group_orders.count > 1 ? true : false
begin sdd = SEPA::DirectDebit.new(
sdd = SEPA::DirectDebit.new( # Name of the initiating party and creditor, in German: "Auftraggeber"
# Name of the initiating party and creditor, in German: "Auftraggeber" # String, max. 70 char
# String, max. 70 char name: FoodsoftConfig[:name],
#TODO: needed from config
name: FoodsoftConfig[:name],
# OPTIONAL: Business Identifier Code (SWIFT-Code) of the creditor # OPTIONAL: Business Identifier Code (SWIFT-Code) of the creditor
# String, 8 or 11 char # String, 8 or 11 char
#TODO: needed - config bic: FoodsoftConfig[:group_order_invoices][:bic],
bic: FoodsoftConfig[:group_order_invoices][:bic],
#'BANKDEFFXXX',
# International Bank Account Number of the creditor # International Bank Account Number of the creditor
# String, max. 34 chars # String, max. 34 chars
#TODO: needed iban: FoodsoftConfig[:group_order_invoices][:iban], # remove spaces
iban: FoodsoftConfig[:group_order_invoices][:iban],
#'DE87200500001234567890',
# Creditor Identifier, in German: Gläubiger-Identifikationsnummer # Creditor Identifier, in German: Gläubiger-Identifikationsnummer
# String, max. 35 chars # String, max. 35 chars
#TODO: needed - config creditor_identifier: FoodsoftConfig[:group_order_invoices][:creditor_identifier],
creditor_identifier: FoodsoftConfig[:group_order_invoices][:creditor_identifier], )
#'DE98ZZZ09999999999'
)
rescue StandardError => e
raise "SEPA Direct Debit XML could not be created: #{e.message}"
end
group_orders.each do |group_order| group_orders.each do |group_order|
# Second: Add transactions
# Second: Add transactions
sdd.add_transaction( sdd.add_transaction(
# Name of the debtor, in German: "Zahlungspflichtiger" # Name of the debtor, in German: "Zahlungspflichtiger"
# String, max. 70 char # String, max. 70 char
#TODO: From ordergroup
name: group_order.ordergroup.name, name: group_order.ordergroup.name,
#Ende zu Ende Referenz #Ende zu Ende Referenz
@ -47,17 +34,14 @@ class OrderCollectiveDirectDebitXml
# OPTIONAL: Business Identifier Code (SWIFT-Code) of the debtor's account # OPTIONAL: Business Identifier Code (SWIFT-Code) of the debtor's account
# String, 8 or 11 char # String, 8 or 11 char
#TODO: needed where does it come from? bic: group_order.ordergroup.sepa_account_holder.bic.gsub(' ', ''),
bic: group_order.ordergroup.sepa_account_holder.bic,
# International Bank Account Number of the debtor's account # International Bank Account Number of the debtor's account
# String, max. 34 chars # String, max. 34 chars
#TODO: needed iban: group_order.ordergroup.sepa_account_holder.iban.gsub(' ', ''),
iban: group_order.ordergroup.sepa_account_holder.iban,
# Amount # Amount
# Number with two decimal digit # Number with two decimal digit
#TODO: needed comesfrom group_order.price
amount: group_order.price, amount: group_order.price,
# OPTIONAL: Currency, EUR by default (ISO 4217 standard) # OPTIONAL: Currency, EUR by default (ISO 4217 standard)
@ -66,22 +50,18 @@ class OrderCollectiveDirectDebitXml
# OPTIONAL: Instruction Identification, will not be submitted to the debtor # OPTIONAL: Instruction Identification, will not be submitted to the debtor
# String, max. 35 char # String, max. 35 char
#TODO: is this neccessary?
#instruction: '12345', #instruction: '12345',
# OPTIONAL: Unstructured remittance information, in German "Verwendungszweck" # OPTIONAL: Unstructured remittance information, in German "Verwendungszweck"
# String, max. 140 char # String, max. 140 char
#TODO: invoice_number + supplier
remittance_information: "#{group_order.group_order_invoice.invoice_number} #{group_order.order.supplier.name}", remittance_information: "#{group_order.group_order_invoice.invoice_number} #{group_order.order.supplier.name}",
# Mandate identifikation, in German "Mandatsreferenz" # Mandate identifikation, in German "Mandatsreferenz"
# String, max. 35 char # String, max. 35 char
#TODO: get it from fsconfig? rather from SEPA
mandate_id: group_order.ordergroup.sepa_account_holder.mandate_id, mandate_id: group_order.ordergroup.sepa_account_holder.mandate_id,
# Mandate Date of signature, in German "Datum, zu dem das Mandat unterschrieben wurde" # Mandate Date of signature, in German "Datum, zu dem das Mandat unterschrieben wurde"
# Date # Date
#TODO: neccessary?? if yes, get it from ordergroup
mandate_date_of_signature: group_order.ordergroup.sepa_account_holder.mandate_date_of_signature, mandate_date_of_signature: group_order.ordergroup.sepa_account_holder.mandate_date_of_signature,
# Local instrument, in German "Lastschriftart" # Local instrument, in German "Lastschriftart"
@ -97,20 +77,18 @@ class OrderCollectiveDirectDebitXml
# 'RCUR' ("Folge-Lastschrift") # 'RCUR' ("Folge-Lastschrift")
# 'OOFF' ("Einmalige Lastschrift") # 'OOFF' ("Einmalige Lastschrift")
# 'FNAL' ("Letztmalige Lastschrift") # 'FNAL' ("Letztmalige Lastschrift")
#TODO: selectable and default RCUR
sequence_type: group_order.group_order_invoice.sepa_sequence_type || 'RCUR', sequence_type: group_order.group_order_invoice.sepa_sequence_type || 'RCUR',
# OPTIONAL: Requested collection date, in German "Fälligkeitsdatum der Lastschrift" # OPTIONAL: Requested collection date, in German "Fälligkeitsdatum der Lastschrift"
# Date # Date
#TODO: two weeks from now?
requested_date: Time.zone.today + 2.days, requested_date: Time.zone.today + 2.days,
# OPTIONAL: Enables or disables batch booking, in German "Sammelbuchung / Einzelbuchung" # OPTIONAL: Enables or disables batch booking, in German "Sammelbuchung / Einzelbuchung"
# True or False # True or False
batch_booking: batch_booking batch_booking: batch_booking
) )
# Last: create XML string # Last: create XML string
end end
@xml_string = sdd.to_xml # Use schema pain.008.001.02 @xml_string = sdd.to_xml # Use schema pain.008.001.02
end end
end end

View file

@ -2,7 +2,19 @@ class SepaAccountHolder < ApplicationRecord
belongs_to :group belongs_to :group
belongs_to :user belongs_to :user
validates_with SEPA::IBANValidator, field_name: :iban, if: -> { iban.present? }
validates_with SEPA::BICValidator, field_name: :bic, if: -> { bic.present? }
before_validation :strip_whitespace_from_bic_and_iban
def all_fields_present? def all_fields_present?
iban.present? && bic.present? && mandate_id.present? && user_id.present? && mandate_date_of_signature.present? && group_id.present? iban.present? && bic.present? && mandate_id.present? && user_id.present? && mandate_date_of_signature.present? && group_id.present?
end end
private
def strip_whitespace_from_bic_and_iban
self.iban = iban&.gsub(/\s+/, "")
self.bic = bic&.gsub(/\s+/, "")
end
end end

View file

@ -121,9 +121,6 @@ class User < ApplicationRecord
settings.messages['send_as_email'] && email.present? settings.messages['send_as_email'] && email.present?
end end
def sepa_possible?
iban.present? && bic.present? && creditor_identifier.present? && mandate_id.present?
end
# Sets the user's password. It will be stored encrypted along with a random salt. # Sets the user's password. It will be stored encrypted along with a random salt.
def set_password def set_password

View file

@ -1,6 +1,6 @@
- if foodsoft_sepa_ready? - if foodsoft_sepa_ready?
= link_to 'Sammellastschrift für alle (.xml)', collective_direct_debit_order_path(id: order.id, mode: 'all'), class: 'btn btn-block' = link_to 'Sammellastschrift für alle (.xml)', collective_direct_debit_order_path(id: order.id, mode: 'all'), class: 'btn btn-block', data: { turbolinks: false }, id: "collective-direct-debit-link-all-#{order.id}"
= link_to 'Sammellastschrift für ausgewählt (.xml)', collective_direct_debit_order_path(id: order.id, mode: 'selected'), class: 'btn btn-block', data: { turbolinks: false }, id: "collective-direct-debit-link-#{order.id}" = link_to 'Sammellastschrift für ausgewählt (.xml)', collective_direct_debit_order_path(id: order.id, mode: 'selected'), class: 'btn btn-block', data: { turbolinks: false }, id: "collective-direct-debit-link-selected-#{order.id}"
- else - else
%i %i
= t('activerecord.attributes.group_order_invoice.links.sepa_not_ready') = t('activerecord.attributes.group_order_invoice.links.sepa_not_ready')

View file

@ -16,7 +16,7 @@
%thead %thead
%tr %tr
%th=I18n.t('activerecord.attributes.group_order_invoice.links.ordergroup') %th=I18n.t('activerecord.attributes.group_order_invoice.links.ordergroup')
%th=I18n.t('activerecord.attributes.group_order_invoice.links.payed') %th=I18n.t('activerecord.attributes.group_order_invoice.links.paid')
%th=I18n.t('activerecord.attributes.group_order_invoice.links.sepa_downloaded') %th=I18n.t('activerecord.attributes.group_order_invoice.links.sepa_downloaded')
%th=I18n.t('activerecord.attributes.group_order_invoice.links.sepa_sequence_type') %th=I18n.t('activerecord.attributes.group_order_invoice.links.sepa_sequence_type')
%th=I18n.t('activerecord.attributes.group_order_invoice.links.sepa_select') %th=I18n.t('activerecord.attributes.group_order_invoice.links.sepa_select')
@ -27,8 +27,8 @@
%tr.order-row %tr.order-row
%td= link_to go.ordergroup.name, edit_admin_ordergroup_path(go.ordergroup) %td= link_to go.ordergroup.name, edit_admin_ordergroup_path(go.ordergroup)
%td %td
.div{id: "payed_#{go.group_order_invoice.id}"} .div{id: "paid_#{go.group_order_invoice.id}"}
= render :partial => "group_order_invoices/toggle_payed", locals: { group_order_invoice: go.group_order_invoice } = render :partial => "group_order_invoices/toggle_paid", locals: { group_order_invoice: go.group_order_invoice }
%td %td
.div{id: "sepa_downloaded_#{go.group_order_invoice.id}"} .div{id: "sepa_downloaded_#{go.group_order_invoice.id}"}
= render :partial => "group_order_invoices/toggle_sepa_downloaded", locals: { group_order_invoice: go.group_order_invoice } = render :partial => "group_order_invoices/toggle_sepa_downloaded", locals: { group_order_invoice: go.group_order_invoice }
@ -55,8 +55,8 @@
%tr.order-row %tr.order-row
%td= I18n.t('activerecord.attributes.group_order_invoice.links.actions_for_all') %td= I18n.t('activerecord.attributes.group_order_invoice.links.actions_for_all')
%td %td
.div{id: "toggle_all_payed_#{order.id}"} .div{id: "toggle_all_paid_#{order.id}"}
= render :partial => 'group_order_invoices/toggle_all_payed', locals: { order: order } = render :partial => 'group_order_invoices/toggle_all_paid', locals: { order: order }
%td %td
.div{id: "toggle_all_sepa_downloaded_#{order.id}"} .div{id: "toggle_all_sepa_downloaded_#{order.id}"}
= render :partial => 'group_order_invoices/toggle_all_sepa_downloaded', locals: { order: order } = render :partial => 'group_order_invoices/toggle_all_sepa_downloaded', locals: { order: order }

View file

@ -3,63 +3,89 @@
- content_for :javascript do - content_for :javascript do
:javascript :javascript
$(document).ready(function() { $(document).ready(function() {
$("#order_#{order.id}_modal").on('click', "#collective-direct-debit-link-#{order.id}", function(e) {
// Function For Downloading the xml
function doTheDownload(selectedGroupOrderIds, url, mode="all"){
if(mode == "all")
{
var data = { order_id: "#{order.id}" }
}
else
{
var data = { group_order_ids: selectedGroupOrderIds }
}
if(mode == "all" || selectedGroupOrderIds.length > 0)
{
//suppress generic error warning
$.ajaxSetup({
global: false,
});
$.ajax({
url: url,
method: 'GET', // You may adjust the HTTP method as needed
data: data,
dataType: 'xml',
success: function(response) {
// Handle success response
// Convert XML response to a Blob
var blob = new Blob([new XMLSerializer().serializeToString(response)], { type: 'text/xml' });
var order_id ="#{order.id}"
// Create a temporary link element
var link = document.createElement('a');
link.href = URL.createObjectURL(blob);
if(selectedGroupOrderIds.length > 1){
link.download = "#{order.supplier.name}-#{order.id}-Sammellastschrift.xml";
} else {
link.download = "#{order.supplier.name}-#{order.id}-Lastschrift.xml";
}
// Append the link to the document and trigger the click event
document.body.appendChild(link);
link.click();
// Clean up
document.body.removeChild(link);
$("group-order-invoices-for-order-#{order.id}" + " .expand-trigger a").click();
$("#order_" + order_id + "_modal").load(window.location + " #order_" + order_id + "_modal");
},
error: function(error) {
// Handle error
if (error.responseJSON) {
alert('AJAX request error:' + "\n" + error.responseJSON.message);
} else{
var errorText = JSON.parse(error.responseText).error;
var alertDiv = '<div class="alert fade in alert-error"><button class="close" data-dismiss="alert">×</button>' + errorText + '</div>';
$('.page-header').before(alertDiv);
$('modal_')
}
}
});
}
else{
var errorText = "Nothing selected";
var alertDiv = '<div class="alert fade in alert-error"><button class="close" data-dismiss="alert">×</button>' + errorText + '</div>';
$('.page-header').before(alertDiv);
}
}
// register onClick listener for selected group_orders
$("#order_#{order.id}_modal").on('click', "#collective-direct-debit-link-selected-#{order.id}", function(e) {
e.preventDefault(); e.preventDefault();
console.log("hi");
// Extract selected group_order_ids // Extract selected group_order_ids
var selectedGroupOrderIds = $('input[name^="group_order_ids_for_order_#{order.id}"]:checked').map(function() { var selectedGroupOrderIds = $('input[name^="group_order_ids_for_order_#{order.id}"]:checked').map(function() {
return $(this).val(); return $(this).val();
}).get(); }).get();
// Log the selected IDs (for testing purposes)
console.log('Selected Group Order IDs:', selectedGroupOrderIds);
var url = $(this).closest('a').attr('href'); var url = $(this).closest('a').attr('href');
//suppress generic error warning doTheDownload(selectedGroupOrderIds, url, "selected");
$.ajaxSetup({ });
global: false,
});
$.ajax({
url: url,
method: 'GET', // You may adjust the HTTP method as needed
data: { group_order_ids: selectedGroupOrderIds },
dataType: 'xml',
success: function(response) {
// Handle success response
console.log('AJAX request successful:', response);
// Convert XML response to a Blob
var blob = new Blob([new XMLSerializer().serializeToString(response)], { type: 'text/xml' });
// Create a temporary link element // register onClick listener for all group_orders
var link = document.createElement('a'); $("#order_#{order.id}_modal").on('click', "#collective-direct-debit-link-all-#{order.id}", function(e) {
link.href = URL.createObjectURL(blob); e.preventDefault();
var url = $(this).closest('a').attr('href');
if(selectedGroupOrderIds.length > 1){ doTheDownload([], url, "all");
link.download = "#{order.supplier.name}-#{order.id}-Sammellastschrift.xml"; });
} else { });
link.download = "#{order.supplier.name}-#{order.id}-Lastschrift.xml";
}
// Append the link to the document and trigger the click event
document.body.appendChild(link);
link.click();
// Clean up
document.body.removeChild(link);
$("group-order-invoices-for-order-#{order.id}" + " .expand-trigger a").click();
},
error: function(error) {
// Handle error
if (error.responseJSON) {
alert('AJAX request error:' + "\n" + error.responseJSON.message);
} else{
var errorText = JSON.parse(error.responseText).error;
var alertDiv = '<div class="alert fade in alert-error"><button class="close" data-dismiss="alert">×</button>' + errorText + '</div>';
$('.page-header').before(alertDiv);
}
}
});
});});
- content_for :javascript do - content_for :javascript do
:javascript :javascript

View file

@ -0,0 +1,2 @@
= link_to toggle_all_paid_group_order_invoices_path(order_id: order.id, paid: order.group_orders.map(&:group_order_invoice).compact.map(&:paid)&.all? ), remote: true, method: :patch, data: { confirm: I18n.t('ui.confirm_mark_all', name: order.group_orders.map(&:group_order_invoice).compact.map(&:paid)&.all? ? I18n.t('activerecord.attributes.group_order_invoice.links.not_paid'): I18n.t('activerecord.attributes.group_order_invoice.links.paid') ) } do
= check_box_tag :paid, '1', order.group_orders.map(&:group_order_invoice).compact.map(&:paid)&.all? , class: 'form-check-input', id: "paid_all_#{order.id}"

View file

@ -1,2 +0,0 @@
= link_to toggle_all_payed_group_order_invoices_path(order_id: order.id, payed: order.group_orders.map(&:group_order_invoice).compact.map(&:payed)&.all? ), remote: true, method: :patch, data: { confirm: I18n.t('ui.confirm_mark_all', name: "payed" ) } do
= check_box_tag :payed, '1', order.group_orders.map(&:group_order_invoice).compact.map(&:payed)&.all? , class: 'form-check-input', id: "payed_all_#{order.id}"

View file

@ -1,2 +1,2 @@
= link_to toggle_all_sepa_downloaded_group_order_invoices_path(order_id: order.id, sepa_downloaded: order.group_orders.map(&:group_order_invoice).compact.map(&:sepa_downloaded)&.all? ), remote: true, method: :patch, data: { confirm: I18n.t('ui.confirm_mark_all', name: "sepa_downloaded" ) } do = link_to toggle_all_sepa_downloaded_group_order_invoices_path(order_id: order.id, sepa_downloaded: order.group_orders.map(&:group_order_invoice).compact.map(&:sepa_downloaded)&.all? ), remote: true, method: :patch, data: { confirm: I18n.t('ui.confirm_mark_all', name: order.group_orders.map(&:group_order_invoice).compact.map(&:sepa_downloaded)&.all? ? I18n.t('activerecord.attributes.group_order_invoice.links.sepa_not_downloaded') : I18n.t('activerecord.attributes.group_order_invoice.links.sepa_downloaded')) } do
= check_box_tag :sepa_downloaded, '1', order.group_orders.map(&:group_order_invoice).compact.map(&:sepa_downloaded)&.all? , class: 'form-check-input', id: "sepa_downloaded_all_#{order.id}" = check_box_tag :sepa_downloaded, '1', order.group_orders.map(&:group_order_invoice).compact.map(&:sepa_downloaded)&.all? , class: 'form-check-input', id: "sepa_downloaded_all_#{order.id}"

View file

@ -0,0 +1,2 @@
= link_to toggle_paid_group_order_invoice_path(group_order_invoice), remote: true, method: :patch, data: { turbolinks: false } do
= check_box_tag 'paid', '1', group_order_invoice.paid , class: 'form-check-input', id: "paid_#{group_order_invoice.id}"

View file

@ -1,2 +0,0 @@
= link_to toggle_payed_group_order_invoice_path(group_order_invoice), remote: true, method: :patch, data: { turbolinks: false } do
= check_box_tag 'payed', '1', group_order_invoice.payed , class: 'form-check-input', id: "payed_#{group_order_invoice.id}"

View file

@ -0,0 +1,4 @@
<% @group_order_invoices.each do |group_order_invoice| %>
$("#paid_<%= group_order_invoice.id %>").html("<%= escape_javascript(render partial: 'toggle_paid', locals: { group_order_invoice: group_order_invoice }) %>");
<% end %>
$("#toggle_all_paid_<%= @order.id %>").html("<%= escape_javascript(render partial: 'toggle_all_paid', locals: { order: @order }) %>");

View file

@ -1,4 +0,0 @@
<% @group_order_invoices.each do |group_order_invoice| %>
$("#payed_<%= group_order_invoice.id %>").html("<%= escape_javascript(render partial: 'toggle_payed', locals: { group_order_invoice: group_order_invoice }) %>");
<% end %>
$("#toggle_all_payed_<%= @order.id %>").html("<%= escape_javascript(render partial: 'toggle_all_payed', locals: { order: @order }) %>");

View file

@ -0,0 +1 @@
$("#paid_<%= @group_order_invoice.id %>").html("<%= escape_javascript(render partial: 'toggle_paid', locals: {group_order_invoice: @group_order_invoice}) %>");

View file

@ -1 +0,0 @@
$("#payed_<%= @group_order_invoice.id %>").html("<%= escape_javascript(render partial: 'toggle_payed', locals: {group_order_invoice: @group_order_invoice}) %>");

View file

@ -106,8 +106,10 @@ de:
generate_with_date: setzen & erzeugen generate_with_date: setzen & erzeugen
invoice_date: Datum der Bestellgruppenrechnung invoice_date: Datum der Bestellgruppenrechnung
ordergroup: Bestellgruppe ordergroup: Bestellgruppe
payed: Bezahlt paid: Bezahlt
not_paid: Nicht Bezahlt
sepa_downloaded: SEPA exportiert sepa_downloaded: SEPA exportiert
sepa_not_downloaded: SEPA nicht exportiert
sepa_not_ready: Wichtige Einstellungen für SEPA Export in Administration -> Einstellungen-> Finanzen fehlen sepa_not_ready: Wichtige Einstellungen für SEPA Export in Administration -> Einstellungen-> Finanzen fehlen
sepa_select: Für SEPA Export markieren sepa_select: Für SEPA Export markieren
sepa_sequence_type: SEPA Typ sepa_sequence_type: SEPA Typ
@ -1991,6 +1993,7 @@ de:
close: Schließen close: Schließen
confirm_delete: Willst du %{name} wirklich löschen? confirm_delete: Willst du %{name} wirklich löschen?
confirm_restore: Willst du %{name} wirklich wiederherstellen? confirm_restore: Willst du %{name} wirklich wiederherstellen?
confirm_mark_all: Willst du wirklich '%{name}' für alle einstellen?
copy: Kopieren copy: Kopieren
delete: Löschen delete: Löschen
download: Herunterladen download: Herunterladen

View file

@ -106,8 +106,10 @@ en:
generate_with_date: set & generate generate_with_date: set & generate
invoice_date: date of group order invoice invoice_date: date of group order invoice
ordergroup: Ordergroup ordergroup: Ordergroup
payed: payed paid: paid
not_paid: unpaid
sepa_downloaded: SEPA exported sepa_downloaded: SEPA exported
sepa_not_downloaded: SEPA not exported
sepa_not_ready: Configurations for SEPA are missing in Admin->Settings->Finances sepa_not_ready: Configurations for SEPA are missing in Admin->Settings->Finances
sepa_select: mark for SEPA export sepa_select: mark for SEPA export
sepa_sequence_type: SEPA type sepa_sequence_type: SEPA type
@ -1966,7 +1968,7 @@ en:
cancel: Cancel cancel: Cancel
close: Close close: Close
confirm_delete: Do you really want to delete %{name}? confirm_delete: Do you really want to delete %{name}?
confirm_mark_all: Do you want to mark all as %{name}? confirm_mark_all: Do you really want to set '%{name}' for all?
confirm_restore: Do you really want to restore %{name}? confirm_restore: Do you really want to restore %{name}?
copy: Copy copy: Copy
delete: Delete delete: Delete

View file

@ -155,13 +155,13 @@ Rails.application.routes.draw do
resources :group_order_invoices do resources :group_order_invoices do
member do member do
patch :select_sepa_sequence_type patch :select_sepa_sequence_type
patch :toggle_payed patch :toggle_paid
patch :toggle_sepa_downloaded patch :toggle_sepa_downloaded
end end
collection do collection do
patch :select_all_sepa_sequence_type patch :select_all_sepa_sequence_type
patch :toggle_all_sepa_downloaded patch :toggle_all_sepa_downloaded
patch :toggle_all_payed patch :toggle_all_paid
end end
end end

View file

@ -0,0 +1,5 @@
class RenamePayedToPaidOnGroupOrderInvoices < ActiveRecord::Migration[7.0]
def change
rename_column :group_order_invoices, :payed, :paid
end
end

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_11_10_131415) do ActiveRecord::Schema[7.0].define(version: 2023_11_28_133642) do
create_table "action_text_rich_texts", charset: "utf8mb4", force: :cascade do |t| create_table "action_text_rich_texts", charset: "utf8mb4", force: :cascade do |t|
t.string "name", null: false t.string "name", null: false
t.text "body", size: :long t.text "body", size: :long
@ -199,7 +199,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_10_131415) do
t.string "payment_method" t.string "payment_method"
t.datetime "created_at", precision: nil, null: false t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false
t.boolean "payed", default: false t.boolean "paid", default: false
t.boolean "sepa_downloaded", default: false t.boolean "sepa_downloaded", default: false
t.string "sepa_sequence_type", default: "RCUR" t.string "sepa_sequence_type", default: "RCUR"
t.index ["group_order_id"], name: "index_group_order_invoices_on_group_order_id", unique: true t.index ["group_order_id"], name: "index_group_order_invoices_on_group_order_id", unique: true

View file

@ -103,7 +103,7 @@ feature GroupOrderInvoice, type: :feature, js: true do
click_link_or_button 'Toggle details' click_link_or_button 'Toggle details'
click_link_or_button I18n.t('activerecord.attributes.group_order_invoice.links.generate') click_link_or_button I18n.t('activerecord.attributes.group_order_invoice.links.generate')
sleep 1 sleep 1
expect(page).to have_selector(:link_or_button, "collective-direct-debit-link-#{order.id}") expect(page).to have_selector(:link_or_button, "collective-direct-debit-link-selected-#{order.id}")
expect(page).to have_selector(".ajax-update-all-link-#{order.id}") expect(page).to have_selector(".ajax-update-all-link-#{order.id}")
end end
end end