diff --git a/CHANGELOG.md b/CHANGELOG.md index 10fbead69..5548ef4bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Next release - improvement: Allow the admin to update payment method only the overdue subscription item without cancel PayZen subscription +- improvement: add payment transfer/check to accounting settings ## v6.3.11 2024 February 2 diff --git a/app/controllers/open_api/v1/accounting_controller.rb b/app/controllers/open_api/v1/accounting_controller.rb index c92a654ce..86be5db41 100644 --- a/app/controllers/open_api/v1/accounting_controller.rb +++ b/app/controllers/open_api/v1/accounting_controller.rb @@ -13,6 +13,8 @@ def index @codes = { card: Setting.get('accounting_payment_card_code'), wallet: Setting.get('accounting_payment_wallet_code'), + transfer: Setting.get('accounting_payment_transfer_code'), + check: Setting.get('accounting_payment_check_code'), other: Setting.get('accounting_payment_other_code') } diff --git a/app/frontend/src/javascript/components/accounting/accounting-codes-settings.tsx b/app/frontend/src/javascript/components/accounting/accounting-codes-settings.tsx index d6fc9bde4..c78c732e0 100644 --- a/app/frontend/src/javascript/components/accounting/accounting-codes-settings.tsx +++ b/app/frontend/src/javascript/components/accounting/accounting-codes-settings.tsx @@ -69,6 +69,18 @@ export const AccountingCodesSettings: React.FC = ( +
{t('app.admin.accounting_codes_settings.transfer')}
+
+ + + +
+
{t('app.admin.accounting_codes_settings.check')}
+
+ + + +
{t('app.admin.accounting_codes_settings.other')}
diff --git a/app/frontend/src/javascript/models/setting.ts b/app/frontend/src/javascript/models/setting.ts index 926c51d1a..604a58a28 100644 --- a/app/frontend/src/javascript/models/setting.ts +++ b/app/frontend/src/javascript/models/setting.ts @@ -113,6 +113,12 @@ export const accountingSettings = [ 'accounting_payment_other_code', 'accounting_payment_other_label', 'accounting_payment_other_journal_code', + 'accounting_payment_transfer_code', + 'accounting_payment_transfer_label', + 'accounting_payment_transfer_journal_code', + 'accounting_payment_check_code', + 'accounting_payment_check_label', + 'accounting_payment_check_journal_code', 'accounting_wallet_code', 'accounting_wallet_label', 'accounting_wallet_journal_code', diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index da4c92808..79885b5b1 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -74,6 +74,12 @@ module SettingsHelper accounting_payment_other_code accounting_payment_other_label accounting_payment_other_journal_code + accounting_payment_transfer_code + accounting_payment_transfer_label + accounting_payment_transfer_journal_code + accounting_payment_check_code + accounting_payment_check_label + accounting_payment_check_journal_code accounting_wallet_code accounting_wallet_label accounting_wallet_journal_code diff --git a/app/models/accounting_line.rb b/app/models/accounting_line.rb index 4c980fe5b..bbe4831af 100644 --- a/app/models/accounting_line.rb +++ b/app/models/accounting_line.rb @@ -13,6 +13,10 @@ def invoice_payment_method # else if invoice.paid_by_card? 'card' + elsif invoice.paid_by_transfer? + 'transfer' + elsif invoice.paid_by_check? + 'check' else 'other' end diff --git a/app/models/invoice.rb b/app/models/invoice.rb index fb4c0ed90..454671423 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -167,6 +167,10 @@ def payment_means 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? + res.push(means: :check, amount: amount_paid) else res.push(means: :other, amount: amount_paid) end @@ -202,6 +206,14 @@ def paid_by_wallet? (wallet_transaction && wallet_amount.positive?) || payment_method == 'wallet' end + def paid_by_transfer? + payment_method == 'transfer' + end + + def paid_by_check? + payment_method == 'check' + end + def render_resource { partial: 'api/invoices/invoice', locals: { invoice: self } } end diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index 3ad1ddc67..bcbabea7a 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -276,6 +276,8 @@ en: card: "Card payments" wallet_debit: "Virtual wallet payments" other: "Other payment means" + transfer: "Transfer" + check: "Check" wallet_credit: "Virtual wallet credit" VAT: "VAT" sales: "Sales" diff --git a/db/seeds/settings.rb b/db/seeds/settings.rb index fcfb09328..2b62e06a9 100644 --- a/db/seeds/settings.rb +++ b/db/seeds/settings.rb @@ -702,6 +702,12 @@ Setting.set('accounting_payment_other_code', '5803') unless Setting.find_by(name: 'accounting_payment_other_code').try(:value) Setting.set('accounting_payment_other_label', 'Payments on site') unless Setting.find_by(name: 'accounting_payment_other_label').try(:value) Setting.set('accounting_payment_other_journal_code', 'SI01') unless Setting.find_by(name: 'accounting_payment_other_journal_code').try(:value) +Setting.set('accounting_payment_transfer_code', '5804') unless Setting.find_by(name: 'accounting_payment_transfer_code').try(:value) +Setting.set('accounting_payment_transfer_label', 'Transfer Payments ') unless Setting.find_by(name: 'accounting_payment_transfer_label').try(:value) +Setting.set('accounting_payment_transfer_journal_code', 'TR01') unless Setting.find_by(name: 'accounting_payment_transfer_journal_code').try(:value) +Setting.set('accounting_payment_check_code', '5805') unless Setting.find_by(name: 'accounting_payment_check_code').try(:value) +Setting.set('accounting_payment_check_label', 'Payments by check') unless Setting.find_by(name: 'accounting_payment_check_label').try(:value) +Setting.set('accounting_payment_check_journal_code', 'CH01') unless Setting.find_by(name: 'accounting_payment_check_journal_code').try(:value) Setting.set('accounting_wallet_code', '4191') unless Setting.find_by(name: 'accounting_wallet_code').try(:value) Setting.set('accounting_wallet_label', 'Wallet credit') unless Setting.find_by(name: 'accounting_wallet_label').try(:value) Setting.set('accounting_wallet_journal_code', 'WC01') unless Setting.find_by(name: 'accounting_wallet_journal_code').try(:value)