Skip to content

Commit

Permalink
(feat) add payment transfer/check to accounting settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gnepud committed Feb 12, 2024
1 parent ff80216 commit cf998e6
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/open_api/v1/accounting_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ export const AccountingCodesSettings: React.FC<AccountingCodesSettingsProps> = (
<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.transfer')}</h5>
<div className="others">
<FormInput register={register} id="accounting_payment_transfer_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
<FormInput register={register} id="accounting_payment_transfer_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_payment_transfer_label" label={t('app.admin.accounting_codes_settings.label')} />
</div>
<h5>{t('app.admin.accounting_codes_settings.check')}</h5>
<div className="others">
<FormInput register={register} id="accounting_payment_check_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
<FormInput register={register} id="accounting_payment_check_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_payment_check_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_payment_other_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/javascript/models/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/settings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/models/accounting_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config/locales/app.admin.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions db/seeds/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cf998e6

Please sign in to comment.