Skip to content

Commit

Permalink
feat: (Transcoding) Payment Allocation form.
Browse files Browse the repository at this point in the history
- List Payments.
- List Invoices.
  • Loading branch information
EdwinBetanc0urt committed Oct 24, 2023
1 parent dfb0dd4 commit 36b5312
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 47 deletions.
9 changes: 4 additions & 5 deletions src/api/ADempiere/form/VAllocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,12 @@ export function requestListCurrencies({
})
}

export function listPayments({
export function requestListPayments({
// DSL Query
searchValue,
businessPartnerId,
date,
organizationId,
organizationUuid,
currencyId,
isMultiCurrency,
transactionType,
Expand Down Expand Up @@ -116,7 +115,7 @@ export function listPayments({
})
}

export function listInvoices({
export function requestListInvoices({
// DSL Query
searchValue,
businessPartnerId,
Expand Down Expand Up @@ -187,7 +186,7 @@ export function requestListTransactionOrganizations({
}

// process
export function process({
export function requestProcess({
date,
chargeId,
currencyId,
Expand All @@ -199,7 +198,7 @@ export function process({
transactionOrganizationId
}) {
return request({
url: '/payment-allocation/process-receipt',
url: '/payment-allocation/process',
method: 'post',
data: {
// DSL Query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@
</span>
<span v-else>
<p
v-if="scope.row[header.columnName].length < 13 || (typeof scope.row[header.columnName] === 'number')"
v-if="typeof scope.row[header.columnName] === 'object'"
style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;line-height: 12px;margin: 0px;"
>
{{ scope.row[header.columnName].value }}
</p>
<p
v-else-if="scope.row[header.columnName].length < 13 || (typeof scope.row[header.columnName] === 'number')"
style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;line-height: 12px;margin: 0px;"
>
{{ scope.row[header.columnName] }}
Expand Down Expand Up @@ -94,7 +100,7 @@ import store from '@/store'
import headersInvoice from './headersInvoice.js'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
import { isEmptyValue, getTypeOfValue } from '@/utils/ADempiere/valueUtils'

export default defineComponent({
name: 'InvocesTable',
Expand All @@ -103,7 +109,9 @@ export default defineComponent({
const diference = ref(0)
const sumApplied = computed(() => {
const sumInvoce = selectListAll.value.map(list => {
if (list.type === 'isInvoce') return list.amountApplied
if (list.type === 'isInvoce') {
return list.amountApplied
}
return list.applied
})
const initialValue = 0
Expand All @@ -118,10 +126,10 @@ export default defineComponent({
*/
const listInvocesTable = ref(null)
const panelInvoce = ref(300)

/**
* computed
*/

const selectListAll = computed(() => {
return store.getters.getListSelectInvoceandPayment
})
Expand All @@ -133,7 +141,6 @@ export default defineComponent({
/**
* Methods
*/

function isCellInput(cell) {
const { columnName } = cell
let isInput = false
Expand Down Expand Up @@ -186,17 +193,17 @@ export default defineComponent({
function appliedPay(currentInvoce) {
const { open_amount, discount_amount } = currentInvoce
if (selectListAll.value.length < 1) {
return open_amount - discount_amount
return open_amount.value - discount_amount.value
}
if (num(sumApplied.value) <= num(open_amount - discount_amount) && Math.sign(sumApplied.value) < 0) {
if (num(sumApplied.value) <= num(open_amount.value - discount_amount.value) && Math.sign(sumApplied.value) < 0) {
if (num(sumApplied.value) === 0) {
if (Math.sign(sumApplied.value) < 0) {
return open_amount - discount_amount
return open_amount.value - discount_amount.value
}
}
return sumApplied.value
}
return open_amount - discount_amount
return open_amount.value - discount_amount.value
}

function setToggleSelection() {
Expand Down Expand Up @@ -232,8 +239,13 @@ export default defineComponent({
}

function num(amount) {
if (getTypeOfValue(amount) === 'OBJECT') {
amount = Number(amount.value)
}
const math = Math.sign(amount)
if (math >= 0) return amount
if (math >= 0) {
return amount
}
return -(amount)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,13 @@ export default defineComponent({
})

const maximumDefiniteDate = computed(() => {
if (isEmptyValue(selectListAll.value)) return new Date()
if (isEmptyValue(selectListAll.value)) {
return new Date()
}
const date = selectListAll.value.map(date => {
if (date.type === 'isPayment') return date.transaction_date
if (date.type === 'isPayment') {
return date.transaction_date
}
return date.date_invoiced
})
return date.sort((a, b) => {
Expand All @@ -457,7 +461,9 @@ export default defineComponent({
})

const sumApplied = computed(() => {
const sumInvoce = selectListAll.value.filter(list => list.type === 'isInvoce').map(list => {
const sumInvoce = selectListAll.value.filter(list => {
return list.type === 'isInvoce'
}).map(list => {
const { transaction_type } = list
if (list.type === 'isInvoce') {
if (transaction_type.value === 'R') {
Expand All @@ -467,7 +473,11 @@ export default defineComponent({
}
return list.applied
})
const sumPayment = selectListAll.value.filter(list => list.type !== 'isInvoce').map(list => list.applied)
const sumPayment = selectListAll.value.filter(list => {
return list.type !== 'isInvoce'
}).map(list => {
return list.applied
})
const initialValue = 0
const initialValuePayment = 0
const initialValueAll = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import store from '@/store'
import headersPayments from './headersPayments.js'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
import { isEmptyValue, getTypeOfValue } from '@/utils/ADempiere/valueUtils'

export default defineComponent({
name: 'PaymentsTable',
Expand All @@ -110,15 +110,16 @@ export default defineComponent({
const { isLoadingPayments } = store.getters.getisLoadTables
return isLoadingPayments
})

/**
* Refs
*/
const listPaymentsTable = ref(null)
const panelInvoce = ref(100)

/**
* computed
*/

const listPayments = computed(() => {
return store.getters.getListVAllocation.payments
})
Expand All @@ -128,7 +129,9 @@ export default defineComponent({
})

const sumAppliedInvoce = computed(() => {
const sumInvoce = selectListAll.value.filter(list => list.type === 'isInvoce').map(list => {
const sumInvoce = selectListAll.value.filter(list => {
return list.type === 'isInvoce'
}).map(list => {
const { transaction_type } = list
if (list.type === 'isInvoce') {
if (transaction_type.value === 'R') {
Expand All @@ -138,7 +141,9 @@ export default defineComponent({
}
return list.applied
})
const sumPayment = selectListAll.value.filter(list => list.type !== 'isInvoce').map(list => list.applied)
const sumPayment = selectListAll.value.filter(list => {
return list.type !== 'isInvoce'
}).map(list => list.applied)
const initialValue = 0
const initialValuePayment = 0
const initialValueAll = 0
Expand Down Expand Up @@ -235,24 +240,32 @@ export default defineComponent({
}

function applied(row) {
if (isEmptyValue(selectListAll.value)) return row.open_amount
if (isEmptyValue(selectListAll.value)) {
return row.open_amount.value
}
if (num(sumAppliedInvoce.value) > 0) {
if (num(sumAppliedInvoce.value) > num(row.open_amount)) {
return row.open_amount
if (num(sumAppliedInvoce.value) > num(row.open_amount.value)) {
return row.open_amount.value
}
if (Math.sign(sumAppliedInvoce.value) === Math.sign(row.open_amount)) {
return row.open_amount
if (Math.sign(sumAppliedInvoce.value) === Math.sign(row.open_amount.value)) {
return row.open_amount.value
}
if (row.transaction_type.value === 'P') {
return -(sumAppliedInvoce.value)
}
if (row.transaction_type.value === 'P') return -(sumAppliedInvoce.value)
return sumAppliedInvoce.value
} else {
return row.open_amount
}
return row.open_amount.value
}

function num(amount) {
if (getTypeOfValue(amount) === 'OBJECT') {
amount = Number(amount.value)
}
const math = Math.sign(amount)
if (math > 0) return amount
if (math > 0) {
return amount
}
return -(amount)
}

Expand Down
13 changes: 9 additions & 4 deletions src/components/ADempiere/FormDefinition/VAllocation/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,15 @@ export default defineComponent({
})

function nextStep(step) {
if (currentSetp.value === 0) store.commit('setListSelectInvoceandPayment', [])
if (currentSetp.value === 1) store.dispatch('processSend')
if (currentSetp.value >= 1) return

if (currentSetp.value === 0) {
store.commit('setListSelectInvoceandPayment', [])
}
if (currentSetp.value === 1) {
store.dispatch('processSend')
}
if (currentSetp.value >= 1) {
return
}
currentSetp.value++
if (currentSetp.value === 1) {
store.dispatch('findListPayment')
Expand Down
17 changes: 10 additions & 7 deletions src/store/modules/ADempiere/form/VAllocation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
* Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
* 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
Expand All @@ -18,9 +18,9 @@

// API Request Methods
import {
process,
listPayments,
listInvoices
requestProcess,
requestListPayments,
requestListInvoices
} from '@/api/ADempiere/form/VAllocation.js'

// Utils and Helper Methods
Expand Down Expand Up @@ -81,6 +81,7 @@ const VAllocation = {

export default {
state: VAllocation,

mutations: {
setSearchCriteria(state, structure) {
state.searchCriteria = structure
Expand Down Expand Up @@ -173,6 +174,7 @@ export default {
state.listSelectAll = list
}
},

actions: {
findListPayment({ commit, state }) {
return new Promise(resolve => {
Expand All @@ -193,7 +195,7 @@ export default {
criteria: 'isLoadTables',
value: true
})
listPayments({
requestListPayments({
businessPartnerId,
businessPartnerUuid,
date,
Expand Down Expand Up @@ -259,7 +261,7 @@ export default {
criteria: 'isLoadTables',
value: true
})
listInvoices({
requestListInvoices({
businessPartnerId,
businessPartnerUuid,
date,
Expand Down Expand Up @@ -326,7 +328,7 @@ export default {
listInvoce = state.listSelectAll.filter(list => list.type === 'isInvoce')
listPayments = state.listSelectAll.filter(list => list.type === 'isPayment')
}
process({
requestProcess({
date,
chargeId,
currencyId,
Expand Down Expand Up @@ -367,6 +369,7 @@ export default {
return
}
},

getters: {
getSearchFilter(state) {
return state.searchCriteria
Expand Down
Loading

0 comments on commit 36b5312

Please sign in to comment.