Skip to content

Commit

Permalink
Fix: Support Create Order from RMA (Transcoding) (adempiere#1571)
Browse files Browse the repository at this point in the history
  • Loading branch information
elsiosanchez authored Oct 30, 2023
1 parent 631a9d6 commit 9b722f2
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 53 deletions.
22 changes: 21 additions & 1 deletion src/api/ADempiere/form/VPOS/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1398,10 +1398,30 @@ export function processRMA({
}) {
return request({
url: `point-of-sales/returns/${rmaId}/process`,
method: 'get',
method: 'put',
params: {
pos_id: posId,
rma_id: rmaId,
document_action: documentAction
}
})
}

/**
* Create Order from RMA
*/

export function createOrderFromRMA({
posId,
salesRepresentativeId,
sourceRmaId
}) {
return request({
url: `point-of-sales/returns/${sourceRmaId}/create-order`,
method: 'post',
params: {
pos_id: posId,
sales_representative_id: salesRepresentativeId
}
})
}
67 changes: 48 additions & 19 deletions src/components/ADempiere/Form/VPOS2/Options/RMA/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ along with this program. If not, see <https:www.gnu.org/licenses/>.

<template>
<el-main
v-if="!isEmptyValue(currentRMA)"
class="product-list-content"
>
<el-form
Expand Down Expand Up @@ -84,13 +85,16 @@ along with this program. If not, see <https:www.gnu.org/licenses/>.
icon="el-icon-document-copy"
@click="copyCode(scope.row)"
/>
<edit-qty-entered
v-if="scope.row.isEditQtyEntered && valueOrder.columnName === 'QtyEntered'"
:qty="Number(scope.row.quantity_ordered.value)"
:handle-change="updateQuantity"
/>
<span v-if="scope.row.isEditQty && valueOrder.columnName === 'QtyEntered'">
<el-button v-if="scope.row.isLoading" :loading="scope.row.isLoading" />
<edit-qty-entered
v-else
:qty="Number(scope.row.quantity_ordered.value)"
:handle-change="updateQuantity"
/>
</span>
<span v-else>
{{ displayValue({ row: scope.row, columnName: valueOrder.columnName}) }}
{{ displayValue({ row: scope.row, columnName: valueOrder.columnName }) }}
</span>
</template>
</el-table-column>
Expand All @@ -111,7 +115,15 @@ along with this program. If not, see <https:www.gnu.org/licenses/>.
</template>
</el-table-column>
</el-table>
<info-r-m-a />
</el-main>
<div
v-else
v-loading="true"
:element-loading-text="$t('notifications.loading')"
element-loading-background="rgba(255, 255, 255, 0.7)"
style="height: 350px;"
/>
</template>

<script>
Expand All @@ -123,8 +135,10 @@ import infoRMA from '@/components/ADempiere/Form/VPOS2/Options/RMA/infoRMA.vue'
import editQtyEntered from '@/components/ADempiere/Form/VPOS2/MainOrder/OptionLine/editLine/editQtyEntered.vue'
// Utils and Helper Methods
import { formatQuantity } from '@/utils/ADempiere/formatValue/numberFormat'
import { copyToClipboard } from '@/utils/ADempiere/coreUtils.js'
import {
displayLabel
displayLabel,
displayValue
} from '@/utils/ADempiere/dictionary/form/VPOS'

export default defineComponent({
Expand Down Expand Up @@ -190,12 +204,6 @@ export default defineComponent({
isNumeric: true,
isVisible: true,
size: '150px'
},
convertedAmount: {
columnName: 'ConvertedAmount',
label: lang.t('form.pos.collect.convertedAmount'),
isNumeric: true,
size: '150px'
}
}
})
Expand All @@ -211,6 +219,12 @@ export default defineComponent({
})
})

const currentRMA = computed(() => {
return store.getters.getAttributeRMA({
attribute: 'current'
})
})

// Methods

/**
Expand All @@ -233,31 +247,36 @@ export default defineComponent({
id,
quantity_ordered
} = item
store.dispatch('createShipmentLine', {
store.dispatch('createRMALine', {
quantity: quantity_ordered.value,
orderLineId: id
sourceOrderLineId: id
})
}

function selectLine(row, column, event) {
const { property } = column
if (property === 'quantity') {
const { columnKey } = column
if (columnKey === 'QtyEntered') {
row.isEditQty = true
}
}

function exitLine(row, column, event) {
const { property } = column
if (property === 'quantity') {
const { columnKey } = column
if (columnKey === 'QtyEntered') {
row.isEditQty = false
}
}

function updateQuantity(quantity) {
line.value.isLoading = true
store.dispatch('updateRMALine', {
lineId: line.value.id,
quantity
})
.finally(() => {
line.value.isEditQty = false
line.value.isLoading = false
})
}

function currentLine(currentRow, oldCurrentRow) {
Expand All @@ -274,14 +293,23 @@ export default defineComponent({
})
}

function copyCode(value) {
copyToClipboard({
text: value.product.value,
isShowMessage: true
})
}

return {
// Ref
searchProduct,
// Computed
lines,
currentRMA,
listLineRMA,
orderLineDefinition,
// Methods
copyCode,
exitLine,
selectLine,
deleteLine,
Expand All @@ -291,6 +319,7 @@ export default defineComponent({
productFilter,
updateQuantity,
displayLabel,
displayValue,
formatQuantity
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/ADempiere/Form/VPOS2/Options/RMA/infoRMA.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ import { defineComponent, computed } from '@vue/composition-api'
import { formatPrice } from '@/utils/ADempiere/formatValue/numberFormat'
import { formatDate } from '@/utils/ADempiere/valueFormat.js'
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
import { formatQuantity } from '@/utils/ADempiere/formatValue/numberFormat'

export default defineComponent({
name: 'infoRMA',
Expand Down Expand Up @@ -172,6 +173,7 @@ export default defineComponent({
// Methods
display,
formatDate,
formatQuantity,
displayAmount
}
}
Expand Down
Loading

0 comments on commit 9b722f2

Please sign in to comment.