mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(bug) empty advanced accounting code
This commit is contained in:
parent
3bbca47d19
commit
dbd88f9889
@ -1,5 +1,7 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
- Fix a bug: empty advanced accounting code is not defaulted to the general setting
|
||||
|
||||
## v5.8.1 2023 March 03
|
||||
|
||||
- Fix a bug: unable to reserve an event
|
||||
|
@ -44,7 +44,7 @@ class Accounting::AccountingCodeService
|
||||
|
||||
if type == :code
|
||||
item_code = Setting.get('advanced_accounting') ? invoice_item.object.reservable.advanced_accounting&.send(section) : nil
|
||||
return Setting.get("accounting_#{invoice_item.object.reservable_type}_code") if item_code.nil? && section == :code
|
||||
return Setting.get("accounting_#{invoice_item.object.reservable_type}_code") if item_code.blank? && section == :code
|
||||
|
||||
item_code
|
||||
else
|
||||
@ -58,7 +58,7 @@ class Accounting::AccountingCodeService
|
||||
|
||||
if type == :code
|
||||
item_code = Setting.get('advanced_accounting') ? invoice_item.object.plan.advanced_accounting&.send(section) : nil
|
||||
return Setting.get('accounting_subscription_code') if item_code.nil? && section == :code
|
||||
return Setting.get('accounting_subscription_code') if item_code.blank? && section == :code
|
||||
|
||||
item_code
|
||||
else
|
||||
@ -72,7 +72,7 @@ class Accounting::AccountingCodeService
|
||||
|
||||
if type == :code
|
||||
item_code = Setting.get('advanced_accounting') ? invoice_item.object.orderable.advanced_accounting&.send(section) : nil
|
||||
return Setting.get('accounting_Product_code') if item_code.nil? && section == :code
|
||||
return Setting.get('accounting_Product_code') if item_code.blank? && section == :code
|
||||
|
||||
item_code
|
||||
else
|
||||
|
@ -17,8 +17,16 @@ class AccountingServiceTest < ActionDispatch::IntegrationTest
|
||||
|
||||
# enable the VAT
|
||||
Setting.set('invoice_VAT-active', true)
|
||||
Setting.set('invoice_VAT-rate', 19.6)
|
||||
Setting.set('invoice_VAT-rate', '19.6')
|
||||
|
||||
# enable advanced accounting on the plan
|
||||
Setting.set('advanced_accounting', true)
|
||||
plan.update(advanced_accounting_attributes: {
|
||||
code: '7021',
|
||||
analytical_section: 'PL21'
|
||||
})
|
||||
|
||||
# book and pay
|
||||
post '/api/local_payment/confirm_payment', params: {
|
||||
customer_id: @vlonchamp.id,
|
||||
coupon_code: 'GIME3EUR',
|
||||
@ -73,11 +81,13 @@ class AccountingServiceTest < ActionDispatch::IntegrationTest
|
||||
assert_not_nil item_machine
|
||||
assert_equal invoice.main_item.net_amount, item_machine&.credit
|
||||
assert_equal Setting.get('accounting_sales_journal_code'), item_machine&.journal_code
|
||||
|
||||
# Check the subscription line
|
||||
item_suscription = lines.find { |l| l.account_code == Setting.get('accounting_subscription_code') }
|
||||
item_suscription = lines.find { |l| l.account_code == '7021' }
|
||||
assert_not_nil item_suscription
|
||||
assert_equal invoice.other_items.last.net_amount, item_suscription&.credit
|
||||
assert_equal Setting.get('accounting_sales_journal_code'), item_suscription&.journal_code
|
||||
assert_equal '7021', item_suscription&.account_code
|
||||
|
||||
# Check the VAT line
|
||||
vat_service = VatHistoryService.new
|
||||
|
Loading…
x
Reference in New Issue
Block a user