Skip to content

Commit

Permalink
fix: POS List Bank Accounts with mandatory Bank identifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt committed Jul 22, 2024
1 parent 03fe378 commit 8beb12a
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 100 deletions.
77 changes: 77 additions & 0 deletions src/api/ADempiere/form/VPOS/banks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
* Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
* Contributor(s): Elsio Sanchez [email protected] https://github.com/elsiosanchez
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { request } from '@/utils/ADempiere/request'

/**
* List Banks
*/
export function listBanksRequest({
posId
}) {
return request({
url: `point-of-sales/${posId}/banks`,
method: 'get',
params: {
page_size: 100
}
})
}

/**
* Get Bank
*/
export function getBankRequest({
posId,
id
}) {
return request({
url: `point-of-sales/${posId}/banks/${id}`,
method: 'get'
})
}

/**
* List Bank Accounts
*/
export function listBankAccountsRequest({
posId,
bankId
}) {
return request({
url: `point-of-sales/${posId}/banks/${bankId}/bank-accounts`,
method: 'get',
params: {
page_size: 100
}
})
}

/**
* Get Bank Account
*/
export function getBankAccountRequest({
posId,
bankId,
id
}) {
return request({
url: `point-of-sales/${posId}/banks/${bankId}/bank-accounts/${id}`,
method: 'get'
})
}
44 changes: 44 additions & 0 deletions src/api/ADempiere/form/VPOS/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,47 @@ export function getCustomerRequest({
}
})
}

/**
* List Bank Accounts
*/
export function listCustomerBankAccountsRequest({
posId,
customerId,
bankId
}) {
return request({
url: `point-of-sales/${posId}/customers/${customerId}/bank-accounts`,
method: 'get',
params: {
page_size: 100,
bank_id: bankId
}
})
}

/**
* Create Customer Account
*/
export function createCustomerBankAccount({
posId,
customerId,
accountNo,
driverLicense,
bankId,
bankAccountType = 'C',
isAch = true
}) {
return request({
url: `point-of-sales/${posId}/customers/${customerId}/bank-accounts`,
method: 'post',
data: {
account_no: accountNo,
driver_license: driverLicense,
bank_id: bankId,
bank_account_type: bankAccountType,
social_security_number: driverLicense,
is_ach: isAch
}
})
}
59 changes: 0 additions & 59 deletions src/api/ADempiere/form/VPOS/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,65 +885,6 @@ export function listStocks({
})
}

/**
* List Banks
*/
export function listBanks({
posId
}) {
return request({
url: `point-of-sales/${posId}/banks`,
method: 'get',
params: {
page_size: 100
}
})
}

/**
* List Bank Accounts
*/
export function listBankAccounts({
posId,
customerId,
bankId
}) {
return request({
url: `point-of-sales/${posId}/customers/${customerId}/bank-accounts`,
method: 'get',
params: {
page_size: 100,
bank_id: bankId
}
})
}

/**
* Create Customer Account
*/
export function createCustomerBankAccount({
posId,
customerId,
accountNo,
driverLicense,
bankId,
bankAccountType = 'C',
isAch = true
}) {
return request({
url: `point-of-sales/${posId}/customers/${customerId}/bank-accounts`,
method: 'post',
data: {
account_no: accountNo,
driver_license: driverLicense,
bank_id: bankId,
bank_account_type: bankAccountType,
social_security_number: driverLicense,
is_ach: isAch
}
})
}

/**
* Credit Memo as Payment Method
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<!--
ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A.
Contributor(s): Elsio Sanchez elsiosanchez15@outlook.com https://github.com/elsiosanchez
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https:www.gnu.org/licenses/>.
ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
Contributor(s): Elsio Sanchez elsiosanchez15@outlook.com https://github.com/elsiosanchez
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https:www.gnu.org/licenses/>.
-->

<template>
Expand Down Expand Up @@ -77,8 +79,10 @@ export default defineComponent({
})

function findBankAccounts(show) {
if (!show) return
store.dispatch('listAccounts')
if (!show) {
return
}
store.dispatch('listCustomerBankAccounts')
}

function setDataAccount(account) {
Expand Down
66 changes: 40 additions & 26 deletions src/store/modules/ADempiere/form/VPOS/fieldsCollections.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
// Copyright (C) 2023-Present E.R.P. Consultores y Asociados, C.A.
// Contributor(s): Elsio Sanchez [email protected] https://github.com/elsiosanchez
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/**
* ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
* Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
* Contributor(s): Elsio Sanchez [email protected] https://github.com/elsiosanchez
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import lang from '@/lang'

// API Request Methods
import {
listAvailablePaymentMethods,
listAvailableCurrencies,
createCustomerBankAccount,
listCustomerCredits,
listBankAccounts,
validatePIN,
listBanks
validatePIN
} from '@/api/ADempiere/form/VPOS'
import {
createCustomerBankAccount,
listCustomerBankAccountsRequest
} from '@/api/ADempiere/form/VPOS/customer'
import {
listBanksRequest
} from '@/api/ADempiere/form/VPOS/banks'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import { showMessage } from '@/utils/ADempiere/notification'
Expand Down Expand Up @@ -204,8 +212,10 @@ export default {
}) {
return new Promise(resolve => {
const currentPos = getters.getVPOS
if (isEmptyValue(currentPos.id)) resolve({})
listBanks({
if (isEmptyValue(currentPos.id)) {
resolve({})
}
listBanksRequest({
posId: currentPos.id
})
.then(response => {
Expand Down Expand Up @@ -236,21 +246,25 @@ export default {
})
})
},
listAccounts({
listCustomerBankAccounts({
commit,
getters
}) {
return new Promise(resolve => {
const currentPos = getters.getVPOS
const currentOrder = getters.getCurrentOrder
let bankId
const banck = getters.getAttributeField({
const bank = getters.getAttributeField({
field: 'banks',
attribute: 'recipientBank'
})
if (banck) bankId = banck.id
if (isEmptyValue(currentPos.id)) resolve({})
listBankAccounts({
if (bank) {
bankId = bank.id
}
if (isEmptyValue(currentPos.id)) {
resolve({})
}
listCustomerBankAccountsRequest({
posId: currentPos.id,
bankId,
customerId: currentOrder.customer.id
Expand Down

0 comments on commit 8beb12a

Please sign in to comment.