1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

(feat) rename client accounts to financial

This commit is contained in:
Sylvain 2022-12-12 11:10:06 +01:00
parent 40dd3f11b8
commit b552e5e626
21 changed files with 174 additions and 161 deletions

View File

@ -8,9 +8,9 @@ class OpenAPI::V1::AccountingController < OpenAPI::V1::BaseController
def index
@codes = {
card: Setting.get('accounting_card_client_code'),
wallet: Setting.get('accounting_wallet_client_code'),
other: Setting.get('accounting_other_client_code')
card: Setting.get('accounting_payment_card_code'),
wallet: Setting.get('accounting_payment_wallet_code'),
other: Setting.get('accounting_payment_other_code')
}
@lines = AccountingLine.order(date: :desc)

View File

@ -17,7 +17,7 @@ class OpenAPI::V1::AccountingDoc < OpenAPI::V1::BaseDoc
'Ordered by *date* descendant.<br>' \
'The field *status* indicates if the accounting data is being built or if the build is over. ' \
'Possible status are: <i>building</i> or <i>built</i>.<br>' \
'The field *invoice.payment_details* is available if line_type=client. It will contain the following data:<br>' \
'The field *invoice.payment_details* is available if line_type=payment. It will contain the following data:<br>' \
'· *payment_mean*, possible status are: <i>card</i>, <i>wallet</i> or <i>other</i>. *WARNING*: If an invoice was settled ' \
'using multiple payment means, this will only report the payment mean applicable to current line.<br>' \
'· *gateway_object_id*, if payment_mean=card, report the ID of the payment gateway related object<br>' \
@ -35,7 +35,7 @@ class OpenAPI::V1::AccountingDoc < OpenAPI::V1::BaseDoc
"lines": [
{
"id": 1,
"line_type": "client",
"line_type": "payment",
"journal_code": "VT01",
"date": "2022-01-02T18:14:21+01:00",
"account_code": "5802",

View File

@ -56,24 +56,24 @@ export const AccountingCodesSettings: React.FC<AccountingCodesSettingsProps> = (
tooltip={t('app.admin.accounting_codes_settings.enable_advanced_help')} />
</FabPanel>
<FabPanel>
<h4>{t('app.admin.accounting_codes_settings.payment_means')}</h4>
<h4>{t('app.admin.accounting_codes_settings.financial')}</h4>
<h5>{t('app.admin.accounting_codes_settings.card')}</h5>
<div className="cards">
<FormInput register={register} id="accounting_card_client_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
<FormInput register={register} id="accounting_card_client_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_card_client_label" label={t('app.admin.accounting_codes_settings.label')} />
<FormInput register={register} id="accounting_payment_card_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
<FormInput register={register} id="accounting_payment_card_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_payment_card_label" label={t('app.admin.accounting_codes_settings.label')} />
</div>
<h5>{t('app.admin.accounting_codes_settings.wallet_debit')}</h5>
<div className="wallets">
<FormInput register={register} id="accounting_wallet_client_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
<FormInput register={register} id="accounting_wallet_client_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_wallet_client_label" label={t('app.admin.accounting_codes_settings.label')} />
<FormInput register={register} id="accounting_payment_wallet_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
<FormInput register={register} id="accounting_payment_wallet_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_payment_wallet_label" label={t('app.admin.accounting_codes_settings.label')} />
</div>
<h5>{t('app.admin.accounting_codes_settings.other')}</h5>
<div className="others">
<FormInput register={register} id="accounting_other_client_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
<FormInput register={register} id="accounting_other_client_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_other_client_label" label={t('app.admin.accounting_codes_settings.label')} />
<FormInput register={register} id="accounting_payment_other_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
<FormInput register={register} id="accounting_payment_other_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_payment_other_label" label={t('app.admin.accounting_codes_settings.label')} />
</div>
<h4>{t('app.admin.accounting_codes_settings.sales')}</h4>
<h5>{t('app.admin.accounting_codes_settings.sales_journal')}</h5>

View File

@ -97,15 +97,15 @@ export const titleSettings = [
export const accountingSettings = [
'accounting_sales_journal_code',
'accounting_card_client_code',
'accounting_card_client_label',
'accounting_card_client_journal_code',
'accounting_wallet_client_code',
'accounting_wallet_client_label',
'accounting_wallet_client_journal_code',
'accounting_other_client_code',
'accounting_other_client_label',
'accounting_other_client_journal_code',
'accounting_payment_card_code',
'accounting_payment_card_label',
'accounting_payment_card_journal_code',
'accounting_payment_wallet_code',
'accounting_payment_wallet_label',
'accounting_payment_wallet_journal_code',
'accounting_payment_other_code',
'accounting_payment_other_label',
'accounting_payment_other_journal_code',
'accounting_wallet_code',
'accounting_wallet_label',
'accounting_wallet_journal_code',

View File

@ -57,15 +57,15 @@ class Setting < ApplicationRecord
display_name_enable
machines_sort_by
accounting_sales_journal_code
accounting_card_client_code
accounting_card_client_label
accounting_card_client_journal_code
accounting_wallet_client_code
accounting_wallet_client_label
accounting_wallet_client_journal_code
accounting_other_client_code
accounting_other_client_label
accounting_other_client_journal_code
accounting_payment_card_code
accounting_payment_card_label
accounting_payment_card_journal_code
accounting_payment_wallet_code
accounting_payment_wallet_label
accounting_payment_wallet_journal_code
accounting_payment_other_code
accounting_payment_other_label
accounting_payment_other_journal_code
accounting_wallet_code
accounting_wallet_label
accounting_wallet_journal_code

View File

@ -6,10 +6,10 @@ module Accounting; end
# fetch the code matching the given resource
class Accounting::AccountingCodeService
class << self
def client_account(payment_mean, type: :code)
def payment_account(payment_mean, type: :code)
raise ArgumentError('invalid type') unless %i[code label].include?(type)
Setting.get("accounting_#{payment_mean}_client_#{type}")
Setting.get("accounting_payment_#{payment_mean}_#{type}")
end
def vat_account(type: :code)

View File

@ -10,16 +10,16 @@ class Accounting::AccountingJournalService
sales: Setting.get('accounting_sales_journal_code') || '',
wallet: Setting.get('accounting_wallet_journal_code') || '',
vat: Setting.get('accounting_VAT_journal_code') || '',
client: {
card: Setting.get('accounting_card_client_journal_code') || '',
wallet: Setting.get('accounting_wallet_client_journal_code') || '',
other: Setting.get('accounting_other_client_journal_code') || ''
payment: {
card: Setting.get('accounting_payment_card_journal_code') || '',
wallet: Setting.get('accounting_payment_wallet_journal_code') || '',
other: Setting.get('accounting_payment_other_journal_code') || ''
}
}
end
def client_journal(payment_mean)
@journal_codes[:client][payment_mean]
def payment_journal(payment_mean)
@journal_codes[:payment][payment_mean]
end
def vat_journal

View File

@ -37,7 +37,7 @@ class Accounting::AccountingService
private
def generate_lines(invoice)
lines = client_lines(invoice) + items_lines(invoice)
lines = payment_lines(invoice) + items_lines(invoice)
vat = vat_line(invoice)
lines << vat unless vat.nil?
@ -67,17 +67,17 @@ class Accounting::AccountingService
lines
end
# Generate the "client" lines, which contains the debit to the client account, all taxes included
def client_lines(invoice)
# Generate the "payment" lines, which contains the debit to the client account, all taxes included
def payment_lines(invoice)
lines = []
invoice.payment_means.each do |details|
lines << line(
invoice,
'client',
@journal_service.client_journal(details[:means]),
Accounting::AccountingCodeService.client_account(details[:means]),
'payment',
@journal_service.payment_journal(details[:means]),
Accounting::AccountingCodeService.payment_account(details[:means]),
details[:amount],
account_label: Accounting::AccountingCodeService.client_account(details[:means], type: :label),
account_label: Accounting::AccountingCodeService.payment_account(details[:means], type: :label),
debit_method: :debit_client,
credit_method: :credit_client
)
@ -158,13 +158,13 @@ class Accounting::AccountingService
# In case of rounding errors, fix the balance by adding or removing a cent to the last item line
# This case should only happen when a coupon has been used.
def fix_rounding_errors(lines)
debit_sum = lines.filter { |l| l[:line_type] == 'client' }.pluck(:debit).sum
credit_sum = lines.filter { |l| l[:line_type] != 'client' }.pluck(:credit).sum
debit_sum = lines.filter { |l| l[:line_type] == 'payment' }.pluck(:debit).sum
credit_sum = lines.filter { |l| l[:line_type] != 'payment' }.pluck(:credit).sum
return if debit_sum == credit_sum
diff = debit_sum - credit_sum
fixable_line = lines.filter { |l| l[:line_type] == 'item' }.last
fixable_line = lines.filter { |l| l[:line_type] == 'payment' }.last
fixable_line.credit += diff
end
end

View File

@ -7,7 +7,7 @@ json.lines @lines do |line|
json.extract! line.invoice, :reference, :id
json.label Invoices::LabelService.build(line.invoice)
json.url download_open_api_v1_invoice_path(line.invoice)
if @codes.values.include?(line.account_code) # if this is a 'client' line
if @codes.values.include?(line.account_code) # if this is a 'payment' line
mean = @codes.select { |_key, value| value == line.account_code }
json.payment_details line.invoice.payment_details(mean.keys[0])
end

View File

@ -146,10 +146,10 @@ en:
label: "Account label"
journal_code: "Journal code"
sales_journal: "Sales journal"
payment_means: "Payment means"
card: "Card clients"
wallet_debit: "Virtual wallet clients"
other: "Other payment mean clients"
financial: "Financial"
card: "Card payments"
wallet_debit: "Virtual wallet payments"
other: "Other payment means"
wallet_credit: "Virtual wallet credit"
VAT: "VAT"
sales: "Sales"

View File

@ -0,0 +1,25 @@
# frozen_string_literal: true
# From this migration some settings related to accounting will be renamed.
# Eg. "accounting_journal_code" will be renamed to "accounting_sales_journal_code"
class RenameAccountingSettings < ActiveRecord::Migration[5.2]
def up
Setting.find_by(name: 'accounting_journal_code')&.update(name: 'accounting_sales_journal_code')
Setting.find_by(name: 'accounting_card_client_code')&.update(name: 'accounting_payment_card_code')
Setting.find_by(name: 'accounting_card_client_label')&.update(name: 'accounting_payment_card_label')
Setting.find_by(name: 'accounting_wallet_client_code')&.update(name: 'accounting_payment_wallet_code')
Setting.find_by(name: 'accounting_wallet_client_label')&.update(name: 'accounting_payment_wallet_label')
Setting.find_by(name: 'accounting_other_client_code')&.update(name: 'accounting_payment_other_code')
Setting.find_by(name: 'accounting_other_client_label')&.update(name: 'accounting_payment_other_label')
end
def down
Setting.find_by(name: 'accounting_sales_journal_code')&.update(name: 'accounting_journal_code')
Setting.find_by(name: 'accounting_payment_card_client_code')&.update(name: 'accounting_card_client_code')
Setting.find_by(name: 'accounting_payment_card_client_label')&.update(name: 'accounting_card_client_label')
Setting.find_by(name: 'accounting_payment_wallet_code')&.update(name: 'accounting_wallet_client_code')
Setting.find_by(name: 'accounting_payment_wallet_label')&.update(name: 'accounting_wallet_client_label')
Setting.find_by(name: 'accounting_payment_other_code')&.update(name: 'accounting_other_client_code')
Setting.find_by(name: 'accounting_payment_other_label')&.update(name: 'accounting_other_client_label')
end
end

View File

@ -1,12 +0,0 @@
# frozen_string_literal: true
# From this migration the setting "accounting_journal_code" will be renamed to "accounting_sales_journal_code"
class RenameJournalCodeSetting < ActiveRecord::Migration[5.2]
def up
Setting.find_by(name: 'accounting_journal_code')&.update(name: 'accounting_sales_journal_code')
end
def down
Setting.find_by(name: 'accounting_sales_journal_code')&.update(name: 'accounting_journal_code')
end
end

View File

@ -19,8 +19,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do
enable_extension "unaccent"
create_table "abuses", id: :serial, force: :cascade do |t|
t.integer "signaled_id"
t.string "signaled_type"
t.integer "signaled_id"
t.string "first_name"
t.string "last_name"
t.string "email"
@ -68,8 +68,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do
t.string "locality"
t.string "country"
t.string "postal_code"
t.integer "placeable_id"
t.string "placeable_type"
t.integer "placeable_id"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -93,8 +93,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do
end
create_table "assets", id: :serial, force: :cascade do |t|
t.integer "viewable_id"
t.string "viewable_type"
t.integer "viewable_id"
t.string "attachment"
t.string "type"
t.datetime "created_at"
@ -176,8 +176,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do
end
create_table "credits", id: :serial, force: :cascade do |t|
t.integer "creditable_id"
t.string "creditable_type"
t.integer "creditable_id"
t.integer "plan_id"
t.integer "hours"
t.datetime "created_at"
@ -408,15 +408,15 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do
create_table "notifications", id: :serial, force: :cascade do |t|
t.integer "receiver_id"
t.integer "attached_object_id"
t.string "attached_object_type"
t.integer "attached_object_id"
t.integer "notification_type_id"
t.boolean "is_read", default: false
t.datetime "created_at"
t.datetime "updated_at"
t.string "receiver_type"
t.boolean "is_send", default: false
t.jsonb "meta_data", default: {}
t.jsonb "meta_data", default: "{}"
t.index ["notification_type_id"], name: "index_notifications_on_notification_type_id"
t.index ["receiver_id"], name: "index_notifications_on_receiver_id"
end
@ -656,8 +656,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do
create_table "prices", id: :serial, force: :cascade do |t|
t.integer "group_id"
t.integer "plan_id"
t.integer "priceable_id"
t.string "priceable_type"
t.integer "priceable_id"
t.integer "amount"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@ -857,8 +857,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do
t.text "message"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "reservable_id"
t.string "reservable_type"
t.integer "reservable_id"
t.integer "nb_reserve_places"
t.integer "statistic_profile_id"
t.index ["reservable_type", "reservable_id"], name: "index_reservations_on_reservable_type_and_reservable_id"
@ -867,8 +867,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do
create_table "roles", id: :serial, force: :cascade do |t|
t.string "name"
t.integer "resource_id"
t.string "resource_type"
t.integer "resource_id"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"

View File

@ -1,10 +1,10 @@
accounting_line_43:
id: 43
line_type: client
line_type: payment
journal_code: CB01
date: '2012-03-12 11:03:31.651441'
account_code: '5801'
account_label: Client card
account_label: Payment by card
analytical_code: ''
invoice_id: 1
invoicing_profile_id: 3
@ -34,11 +34,11 @@ accounting_line_44:
accounting_line_45:
id: 45
line_type: client
line_type: payment
journal_code: CA01
date: '2012-03-12 13:40:22.342717'
account_code: '5803'
account_label: Client other
account_label: Payment by other
analytical_code: ''
invoice_id: 2
invoicing_profile_id: 4
@ -68,11 +68,11 @@ accounting_line_46:
accounting_line_47:
id: 47
line_type: client
line_type: payment
journal_code: CA01
date: '2015-06-10 11:20:01.341130'
account_code: '5803'
account_label: Client other
account_label: Payment by other
analytical_code: ''
invoice_id: 3
invoicing_profile_id: 7
@ -102,11 +102,11 @@ accounting_line_48:
accounting_line_49:
id: 49
line_type: client
line_type: payment
journal_code: CA01
date: '2016-04-05 08:35:52.931187'
account_code: '5803'
account_label: Client other
account_label: Payment by other
analytical_code: ''
invoice_id: 4
invoicing_profile_id: 7
@ -136,11 +136,11 @@ accounting_line_50:
accounting_line_51:
id: 51
line_type: client
line_type: payment
journal_code: CA01
date: '2016-04-05 08:36:46.853368'
account_code: '5803'
account_label: Client other
account_label: Payment by other
analytical_code: ''
invoice_id: 5
invoicing_profile_id: 3
@ -170,11 +170,11 @@ accounting_line_52:
accounting_line_53:
id: 53
line_type: client
line_type: payment
journal_code: CA01
date: '2021-01-04 14:51:21.616153'
account_code: '5803'
account_label: Client other
account_label: Payment by other
analytical_code: ''
invoice_id: 6
invoicing_profile_id: 8
@ -204,11 +204,11 @@ accounting_line_54:
accounting_line_55:
id: 55
line_type: client
line_type: payment
journal_code: CA01
date: '2022-09-20 15:14:22.873707'
account_code: '5803'
account_label: Client other
account_label: Payment by other
analytical_code: ''
invoice_id: 5811
invoicing_profile_id: 3
@ -255,11 +255,11 @@ accounting_line_57:
accounting_line_58:
id: 58
line_type: client
line_type: payment
journal_code: CA01
date: '2022-09-20 15:14:48.345927'
account_code: '5803'
account_label: Client other
account_label: Payment by other
analytical_code: ''
invoice_id: 5812
invoicing_profile_id: 7
@ -289,11 +289,11 @@ accounting_line_59:
accounting_line_60:
id: 60
line_type: client
line_type: payment
journal_code: CB01
date: '2022-10-04 12:36:03.060832'
account_code: '5801'
account_label: Client card
account_label: Payment by card
analytical_code: ''
invoice_id: 5816
invoicing_profile_id: 4
@ -340,11 +340,11 @@ accounting_line_62:
accounting_line_63:
id: 63
line_type: client
line_type: payment
journal_code: CB01
date: '2022-10-04 13:54:42.975196'
account_code: '5801'
account_label: Client card
account_label: Payment by card
analytical_code: ''
invoice_id: 5817
invoicing_profile_id: 4
@ -391,11 +391,11 @@ accounting_line_65:
accounting_line_66:
id: 66
line_type: client
line_type: payment
journal_code: CB01
date: '2022-10-04 14:04:12.742685'
account_code: '5801'
account_label: Client card
account_label: Payment by card
analytical_code: ''
invoice_id: 5818
invoicing_profile_id: 4
@ -425,11 +425,11 @@ accounting_line_67:
accounting_line_68:
id: 68
line_type: client
line_type: payment
journal_code: CB01
date: '2022-10-04 14:17:52.854636'
account_code: '5801'
account_label: Client card
account_label: Payment by card
analytical_code: ''
invoice_id: 5819
invoicing_profile_id: 4
@ -476,11 +476,11 @@ accounting_line_70:
accounting_line_71:
id: 71
line_type: client
line_type: payment
journal_code: CA01
date: '2022-10-04 14:25:37.291945'
account_code: '5803'
account_label: Client other
account_label: Payment by other
analytical_code: ''
invoice_id: 5820
invoicing_profile_id: 3
@ -510,11 +510,11 @@ accounting_line_72:
accounting_line_73:
id: 73
line_type: client
line_type: payment
journal_code: CA01
date: '2022-10-04 14:32:28.204985'
account_code: '5803'
account_label: Client other
account_label: Payment by other
analytical_code: ''
invoice_id: 5821
invoicing_profile_id: 2
@ -544,11 +544,11 @@ accounting_line_74:
accounting_line_75:
id: 75
line_type: client
line_type: payment
journal_code: CA01
date: '2022-10-04 14:35:40.584472'
account_code: '5803'
account_label: Client other
account_label: Payment by other
analytical_code: ''
invoice_id: 5822
invoicing_profile_id: 2

View File

@ -395,7 +395,7 @@ history_value_40:
history_value_41:
id: 41
setting_id: 41
value: Client card
value: Payment by card
created_at: '2019-09-20 11:02:32.125400'
updated_at: '2021-05-31 15:00:36.518127'
footprint: bad61ed94921d492052622f6da1e7b1611c8abee4d0e3260229f0bf23bc24f70
@ -413,7 +413,7 @@ history_value_42:
history_value_43:
id: 43
setting_id: 43
value: Client wallet
value: Payment by wallet
created_at: '2019-09-20 11:02:32.125400'
updated_at: '2021-05-31 15:00:36.553577'
footprint: 430cdf800a4e84f0385ebbdb7b48a107450c618b9c49b9b97016e80047407036
@ -431,7 +431,7 @@ history_value_44:
history_value_45:
id: 45
setting_id: 45
value: Client other
value: Payment by other
created_at: '2019-09-20 11:02:32.125400'
updated_at: '2021-05-31 15:00:36.593026'
footprint: 383ef2b5ad5aaa5e014893e0ca8f7bdcd13d565a3bfd97446e5543e8d0dca941

View File

@ -229,37 +229,37 @@ setting_39:
setting_40:
id: 40
name: accounting_card_client_code
name: accounting_payment_card_code
created_at: 2019-09-20 11:02:32.125400000 Z
updated_at: 2019-09-20 11:02:32.125400000 Z
setting_41:
id: 41
name: accounting_card_client_label
name: accounting_payment_card_label
created_at: 2019-09-20 11:02:32.125400000 Z
updated_at: 2019-09-20 11:02:32.125400000 Z
setting_42:
id: 42
name: accounting_wallet_client_code
name: accounting_payment_wallet_code
created_at: 2019-09-20 11:02:32.125400000 Z
updated_at: 2019-09-20 11:02:32.125400000 Z
setting_43:
id: 43
name: accounting_wallet_client_label
name: accounting_payment_wallet_label
created_at: 2019-09-20 11:02:32.125400000 Z
updated_at: 2019-09-20 11:02:32.125400000 Z
setting_44:
id: 44
name: accounting_other_client_code
name: accounting_payment_other_code
created_at: 2019-09-20 11:02:32.125400000 Z
updated_at: 2019-09-20 11:02:32.125400000 Z
setting_45:
id: 45
name: accounting_other_client_label
name: accounting_payment_other_label
created_at: 2019-09-20 11:02:32.125400000 Z
updated_at: 2019-09-20 11:02:32.125400000 Z
@ -529,19 +529,19 @@ setting_89:
setting_90:
id: 90
name: accounting_card_client_journal_code
name: accounting_payment_card_journal_code
created_at: 2022-12-09 14:00:14.512000000 Z
updated_at: 2022-12-09 14:00:14.512000000 Z
setting_91:
id: 91
name: accounting_wallet_client_journal_code
name: accounting_payment_wallet_journal_code
created_at: 2022-12-09 14:00:14.512000000 Z
updated_at: 2022-12-09 14:00:14.512000000 Z
setting_92:
id: 92
name: accounting_other_client_journal_code
name: accounting_payment_other_journal_code
created_at: 2022-12-09 14:00:14.512000000 Z
updated_at: 2022-12-09 14:00:14.512000000 Z

View File

@ -543,7 +543,7 @@ export const settings: Array<Setting> = [
},
{
name: 'accounting_card_client_code',
value: '411210',
value: '5801',
last_update: '2022-11-22T17:27:19+0100',
localized: 'Code clients par carte'
},
@ -555,7 +555,7 @@ export const settings: Array<Setting> = [
},
{
name: 'accounting_wallet_client_code',
value: '411211',
value: '5802',
last_update: '2022-11-22T17:27:19+0100',
localized: 'Code clients par porte-monnaie'
},
@ -567,7 +567,7 @@ export const settings: Array<Setting> = [
},
{
name: 'accounting_other_client_code',
value: '411212',
value: '5803',
last_update: '2022-11-22T17:27:19+0100',
localized: 'Code clients autre moyen'
},

View File

@ -10,7 +10,7 @@ describe('AccountingCodesSettings', () => {
render(<AccountingCodesSettings onError={onError} onSuccess={onSuccess} />);
await waitFor(() => screen.getByRole('heading', { name: /app.admin.accounting_codes_settings.advanced_accounting/ }));
expect(screen.getByLabelText(/app.admin.accounting_codes_settings.enable_advanced/)).toBeInTheDocument();
expect(screen.getByLabelText(/app.admin.accounting_codes_settings.journal_code/)).toBeInTheDocument();
expect(screen.getAllByLabelText(/app.admin.accounting_codes_settings.journal_code/)).toHaveLength(6);
expect(screen.getAllByLabelText(/app.admin.accounting_codes_settings.code/)).toHaveLength(13);
expect(screen.getAllByLabelText(/app.admin.accounting_codes_settings.label/)).toHaveLength(13);
expect(screen.getByRole('button', { name: /app.admin.accounting_codes_settings.save/ })).toBeInTheDocument();

View File

@ -53,8 +53,8 @@ class Exports::AccountingExportTest < ActionDispatch::IntegrationTest
# test values
first_invoice = Invoice.first
# first line = client line
check_client_line(first_invoice, data[0])
# first line = payment line
check_payment_line(first_invoice, data[0])
# second line = sold item line
check_item_line(first_invoice, first_invoice.invoice_items.first, data[1])
@ -65,12 +65,12 @@ class Exports::AccountingExportTest < ActionDispatch::IntegrationTest
# test with a reservation invoice
machine_invoice = Invoice.find(5)
check_client_line(machine_invoice, data[6])
check_payment_line(machine_invoice, data[6])
check_item_line(machine_invoice, machine_invoice.invoice_items.first, data[7])
# test with a shop order invoice (local payment)
shop_invoice = Invoice.find(5811)
check_client_line(shop_invoice, data[10])
check_payment_line(shop_invoice, data[10])
check_item_line(shop_invoice, shop_invoice.invoice_items.first, data[11])
check_item_line(shop_invoice, shop_invoice.invoice_items.last, data[12])
@ -79,22 +79,22 @@ class Exports::AccountingExportTest < ActionDispatch::IntegrationTest
FileUtils.rm(e.file)
end
def check_client_line(invoice, client_line)
check_entry_date(invoice, client_line)
check_client_accounts(invoice, client_line)
check_entry_label(invoice, client_line)
check_document(invoice, client_line)
def check_payment_line(invoice, payment_line)
check_entry_date(invoice, payment_line)
check_client_accounts(invoice, payment_line)
check_entry_label(invoice, payment_line)
check_document(invoice, payment_line)
if invoice.wallet_transaction_id.nil?
assert_equal invoice.total / 100.00, client_line[I18n.t('accounting_export.debit_origin')].to_f,
assert_equal invoice.total / 100.00, payment_line[I18n.t('accounting_export.debit_origin')].to_f,
'Origin debit amount does not match'
assert_equal invoice.total / 100.00, client_line[I18n.t('accounting_export.debit_euro')].to_f, 'Euro debit amount does not match'
assert_equal invoice.total / 100.00, payment_line[I18n.t('accounting_export.debit_euro')].to_f, 'Euro debit amount does not match'
else
warn "WARNING: unable to test accurately accounting export: invoice #{invoice.id} is using wallet"
end
assert_equal 0, client_line[I18n.t('accounting_export.credit_origin')].to_f, 'Credit origin amount does not match'
assert_equal 0, client_line[I18n.t('accounting_export.credit_euro')].to_f, 'Credit euro amount does not match'
assert_equal 0, payment_line[I18n.t('accounting_export.credit_origin')].to_f, 'Credit origin amount does not match'
assert_equal 0, payment_line[I18n.t('accounting_export.credit_euro')].to_f, 'Credit euro amount does not match'
end
def check_item_line(invoice, invoice_item, item_line)
@ -126,24 +126,24 @@ class Exports::AccountingExportTest < ActionDispatch::IntegrationTest
def check_client_accounts(invoice, client_line)
if invoice.wallet_transaction && invoice.wallet_amount.positive?
wallet_client_code = Setting.get('accounting_wallet_client_code')
wallet_client_code = Setting.get('accounting_payment_wallet_code')
assert_equal wallet_client_code, client_line[I18n.t('accounting_export.account_code')], 'Account code for wallet client is wrong'
wallet_client_label = Setting.get('accounting_wallet_client_label')
wallet_client_label = Setting.get('accounting_payment_wallet_label')
assert_equal wallet_client_label, client_line[I18n.t('accounting_export.account_label')], 'Account label for wallet client is wrong'
wallet_client_journal = Setting.get('accounting_wallet_client_journal_code')
wallet_client_journal = Setting.get('accounting_payent_wallet_journal_code')
assert_equal wallet_client_journal, client_line[I18n.t('accounting_export.journal_code')], 'Journal code for wallet client is wrong'
end
mean = invoice.paid_by_card? ? 'card' : 'other'
client_code = Setting.get("accounting_#{mean}_client_code")
client_code = Setting.get("accounting_payment_#{mean}_code")
assert_equal client_code, client_line[I18n.t('accounting_export.account_code')], 'Account code for client is wrong'
client_label = Setting.get("accounting_#{mean}_client_label")
client_label = Setting.get("accounting_payment_#{mean}_label")
assert_equal client_label, client_line[I18n.t('accounting_export.account_label')], 'Account label for client is wrong'
client_journal = Setting.get("accounting_#{mean}_client_journal_code")
client_journal = Setting.get("accounting_payment_#{mean}_journal_code")
assert_equal client_journal, client_line[I18n.t('accounting_export.journal_code')], 'Journal code for client is wrong'
end

View File

@ -70,28 +70,28 @@ class OpenApi::AccountingTest < ActionDispatch::IntegrationTest
end
test 'list all accounting lines with type filtering' do
get '/open_api/v1/accounting?type=[client,vat]', headers: open_api_headers(@token)
get '/open_api/v1/accounting?type=[payment,vat]', headers: open_api_headers(@token)
assert_response :success
assert_equal Mime[:json], response.content_type
lines = json_response(response.body)
assert lines[:lines].count.positive?
assert(lines[:lines].all? { |line| %w[client vat].include?(line[:line_type]) })
assert(lines[:lines].all? { |line| %w[payment vat].include?(line[:line_type]) })
end
test 'list all accounting client lines have payment details' do
get '/open_api/v1/accounting?type=client', headers: open_api_headers(@token)
test 'list all accounting payment lines should have payment details' do
get '/open_api/v1/accounting?type=payment', headers: open_api_headers(@token)
assert_response :success
assert_equal Mime[:json], response.content_type
card_code = Setting.get('accounting_card_client_code')
wallet_code = Setting.get('accounting_wallet_client_code')
other_code = Setting.get('accounting_other_client_code')
card_code = Setting.get('accounting_payment_card_code')
wallet_code = Setting.get('accounting_payment_wallet_code')
other_code = Setting.get('accounting_payment_other_code')
lines = json_response(response.body)
assert lines[:lines].count.positive?
assert(lines[:lines].all? { |line| line[:line_type] == 'client' })
assert(lines[:lines].all? { |line| !line[:invoice][:payment_details].nil? })
assert(lines[:lines].all? { |line| line[:line_type] == 'payment' })
assert(lines[:lines].none? { |line| line[:invoice][:payment_details].nil? })
assert(lines[:lines].all? { |line| %w[card wallet other].include?(line[:invoice][:payment_details][:payment_mean]) })
assert(lines[:lines].filter { |line| line[:account_code] == card_code }
.none? { |line| line[:invoice][:payment_details][:gateway_object_id].nil? })
@ -100,6 +100,6 @@ class OpenApi::AccountingTest < ActionDispatch::IntegrationTest
assert(lines[:lines].filter { |line| line[:account_code] == wallet_code }
.none? { |line| line[:invoice][:payment_details][:wallet_transaction_id].nil? })
assert(lines[:lines].filter { |line| line[:account_code] == other_code }
.all? { |line| line[:invoice][:payment_details].empty? })
.all? { |line| line[:invoice][:payment_details][:payment_mean] == 'other' })
end
end

View File

@ -56,16 +56,16 @@ class AccountingServiceTest < ActionDispatch::IntegrationTest
assert 5, lines.count
# Check the wallet line
assert 2, lines.filter { |l| l.line_type == 'client' }.count
client_wallet = lines.find { |l| l.account_code == Setting.get('accounting_wallet_client_code') }
assert_not_nil client_wallet
assert_equal 1000, client_wallet&.debit
assert_equal Setting.get('accounting_wallet_client_journal_code'), client_wallet&.journal_code
assert 2, lines.filter { |l| l.line_type == 'payment' }.count
payment_wallet = lines.find { |l| l.account_code == Setting.get('accounting_payment_wallet_code') }
assert_not_nil payment_wallet
assert_equal 1000, payment_wallet&.debit
assert_equal Setting.get('accounting_payment_wallet_journal_code'), payment_wallet&.journal_code
# Check the local payment line
client_other = lines.find { |l| l.account_code == Setting.get('accounting_other_client_code') }
assert_not_nil client_other
assert_equal invoice.total - 1000, client_other&.debit
assert_equal Setting.get('accounting_other_client_journal_code'), client_other&.journal_code
payment_other = lines.find { |l| l.account_code == Setting.get('accounting_payment_other_code') }
assert_not_nil payment_other
assert_equal invoice.total - 1000, payment_other&.debit
assert_equal Setting.get('accounting_payment_other_journal_code'), payment_other&.journal_code
# Check the machine reservation line
assert 2, lines.filter { |l| l.line_type == 'item' }.count