Skip to content

Commit

Permalink
Merge branch 'dev' for release 6.3.16
Browse files Browse the repository at this point in the history
  • Loading branch information
gnepud committed Mar 11, 2024
2 parents 59ef0db + d5d3e61 commit 91a1dc1
Show file tree
Hide file tree
Showing 41 changed files with 76 additions and 64 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Next release

## v6.3.16 2024 March 11

- Fix a bug: set settlement by cash by default for local payment mean
- updates translations
- #content_type_whitelist is instead by #content_type_allowlist
- #extension_whitelist is instead by #extension_allowlist
- [TODO DEPLOY] `rails fablab:setup:build_accounting_lines`

## v6.3.15 2024 February 29

- Fix a bug: unable to generate invoice for payment by check/transfer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import CheckoutAPI from '../../../api/checkout';
import { SelectOption } from '../../../models/select';
import { PaymentMethod } from '../../../models/payment';

const ALL_SCHEDULE_METHODS = ['card', 'check', 'transfer'] as const;
type scheduleMethod = typeof ALL_SCHEDULE_METHODS[number];
const ALL_PAYMENT_METHODS = ['card', 'check', 'transfer', 'cash'] as const;
type paymentMethod = typeof ALL_PAYMENT_METHODS[number];

/**
* A form component to ask for confirmation before cashing a payment directly at the FabLab's reception.
Expand All @@ -24,13 +24,13 @@ type scheduleMethod = typeof ALL_SCHEDULE_METHODS[number];
export const LocalPaymentForm: React.FC<GatewayFormProps> = ({ onSubmit, onSuccess, onError, children, className, paymentSchedule, cart, updateCart, customer, operator, formId, order }) => {
const { t } = useTranslation('admin');

const [method, setMethod] = useState<scheduleMethod>('check');
const [method, setMethod] = useState<paymentMethod>('cash');
const [onlinePaymentModal, setOnlinePaymentModal] = useState<boolean>(false);

useEffect(() => {
setMethod(cart.payment_method || 'check');
setMethod(cart.payment_method || 'cash');
if (cart.payment_method === '') {
cart.payment_method = PaymentMethod.Check;
cart.payment_method = PaymentMethod.Cash;
}
}, [cart]);

Expand All @@ -44,23 +44,23 @@ export const LocalPaymentForm: React.FC<GatewayFormProps> = ({ onSubmit, onSucce
/**
* Convert all payement methods for schedules to the react-select format
*/
const buildMethodOptions = (): Array<SelectOption<scheduleMethod>> => {
return ALL_SCHEDULE_METHODS.map(i => methodToOption(i));
const buildMethodOptions = (): Array<SelectOption<paymentMethod>> => {
return ALL_PAYMENT_METHODS.filter(p => p !== 'cash').map(i => methodToOption(i));
};

/**
* Convert the given payment-method to the react-select format
*/
const methodToOption = (value: scheduleMethod): SelectOption<scheduleMethod> => {
if (!value) return { value, label: '' };
const methodToOption = (value: paymentMethod): SelectOption<paymentMethod> => {
if (!value || value === 'cash') return { value, label: '' };

return { value, label: t(`app.admin.local_payment_form.method_${value}`) };
};

/**
* Callback triggered when the user selects a payment method for the current payment schedule.
*/
const handleUpdateMethod = (option: SelectOption<scheduleMethod>) => {
const handleUpdateMethod = (option: SelectOption<paymentMethod>) => {
updateCart(Object.assign({}, cart, { payment_method: option.value }));
setMethod(option.value);
};
Expand All @@ -69,6 +69,10 @@ export const LocalPaymentForm: React.FC<GatewayFormProps> = ({ onSubmit, onSucce
* Handle the submission of the form. It will process the local payment.
*/
const handleSubmit = async (event: FormEvent): Promise<void> => {
if (paymentSchedule && !ALL_PAYMENT_METHODS.filter(p => p !== 'cash').includes(method)) {
event.preventDefault();
return;
}
event.preventDefault();
onSubmit();

Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/javascript/models/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export enum PaymentMethod {
Card = 'card',
Check = 'check',
Transfer = 'transfer',
Cash = 'cash',
Other = ''
}

Expand Down
2 changes: 0 additions & 2 deletions app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ def payment_means

if paid_by_card?
res.push(means: :card, amount: amount_paid)
elsif paid_by_wallet?
res.push(means: :wallet, amount: amount_paid)
elsif paid_by_transfer?
res.push(means: :transfer, amount: amount_paid)
elsif paid_by_check?
Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/custom_assets_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[pdf png jpeg jpg ico]
end

def content_type_whitelist
def content_type_allowlist
[%r{image/}, 'application/pdf']
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/event_file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[pdf]
end

def content_type_whitelist
def content_type_allowlist
%w[application/pdf]
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/event_image_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[jpg jpeg gif png]
end

def content_type_whitelist
def content_type_allowlist
[%r{image/}]
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/import_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[csv]
end

def content_type_whitelist
def content_type_allowlist
%w[text/csv]
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/machine_file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[pdf]
end

def content_type_whitelist
def content_type_allowlist
%w[application/pdf]
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/machine_image_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[jpg jpeg gif png]
end

def content_type_whitelist
def content_type_allowlist
[%r{image/}]
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/plan_file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[pdf png jpeg jpg]
end

def content_type_whitelist
def content_type_allowlist
[%r{image/}, 'application/pdf']
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/product_file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[pdf]
end

def content_type_whitelist
def content_type_allowlist
['application/pdf']
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/product_image_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[jpg jpeg gif png webp]
end

def content_type_whitelist
def content_type_allowlist
[%r{image/}]
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/project_cao_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
Setting.get('allowed_cad_extensions').split(' ')
end

def content_type_whitelist
def content_type_allowlist
Setting.get('allowed_cad_mime_types').split(' ')
end
end
4 changes: 2 additions & 2 deletions app/uploaders/project_image_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[jpg jpeg gif png]
end

def content_type_whitelist
def content_type_allowlist
[%r{image/}]
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/space_file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[pdf]
end

def content_type_whitelist
def content_type_allowlist
%w[application/pdf]
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/space_image_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[jpg jpeg gif png]
end

def content_type_whitelist
def content_type_allowlist
[%r{image/}]
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/supporting_document_file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[pdf png jpeg jpg]
end

def content_type_whitelist
def content_type_allowlist
[%r{image/}, 'application/pdf']
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/training_image_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[jpg jpeg gif png]
end

def content_type_whitelist
def content_type_allowlist
[%r{image/}]
end

Expand Down
4 changes: 2 additions & 2 deletions app/uploaders/user_avatar_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ def base_store_dir

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
def extension_allowlist
%w[jpg jpeg gif png]
end

def content_type_whitelist
def content_type_allowlist
%w[image/jpeg image/gif image/png]
end

Expand Down
2 changes: 1 addition & 1 deletion config/locales/app.public.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ de:
discover_members: "Mitglieder entdecken"
#next events summary on the home page
fablab_s_next_events: "Next events"
every_events: "Alle Veranstaltungen"
every_events: "All events"
event_card:
on_the_date: "Am {DATE}"
from_date_to_date: "Von {START} bis {END}"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/app.public.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ en:
discover_members: "Discover members"
#next events summary on the home page
fablab_s_next_events: "Next events"
every_events: "Every events"
every_events: "All events"
event_card:
on_the_date: "On the {DATE}"
from_date_to_date: "From {START} to {END}"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/app.public.es-MX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ es-MX:
discover_members: "Descubrir miembros"
#next events summary on the home page
fablab_s_next_events: "Próximos eventos"
every_events: "Todos los eventos"
every_events: "All events"
event_card:
on_the_date: "El {DATE}"
from_date_to_date: "Desde {START} hasta {END}"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/app.public.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ es:
discover_members: "Descubrir miembros"
#next events summary on the home page
fablab_s_next_events: "Próximos eventos"
every_events: "Todos los eventos"
every_events: "All events"
event_card:
on_the_date: "El {DATE}"
from_date_to_date: "Desde {START} hasta {END}"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/app.public.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ it:
discover_members: "Cerca i membri"
#next events summary on the home page
fablab_s_next_events: "Prossimi eventi"
every_events: "Tutti gli eventi"
every_events: "All events"
event_card:
on_the_date: "Il {DATE}"
from_date_to_date: "Da {START} a {END}"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/app.public.no.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
discover_members: "Oppdag medlemmer"
#next events summary on the home page
fablab_s_next_events: "Next events"
every_events: "Alle arrangementer"
every_events: "All events"
event_card:
on_the_date: "På {DATE}"
from_date_to_date: "Fra {START} til {END}"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/app.public.pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pt:
discover_members: "Ver membros"
#next events summary on the home page
fablab_s_next_events: "Próximos eventos"
every_events: "Todos Eventos"
every_events: "All events"
event_card:
on_the_date: "Em {DATE}"
from_date_to_date: "De {START} até {END}"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/app.public.sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ sv:
discover_members: "Upptäck medlemmar"
#next events summary on the home page
fablab_s_next_events: "Nästa evenemang"
every_events: "Alla evenemang"
every_events: "All events"
event_card:
on_the_date: "Den {DATE}"
from_date_to_date: "Från {START} till {END}"
Expand Down
Loading

0 comments on commit 91a1dc1

Please sign in to comment.