Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/modules/purchase/down-payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ const actions = {
reject(error)
})
})
},
sendBulkRequestApproval (context, payload) {
return new Promise((resolve, reject) => {
api.post(url + '/send-bulk-request-approval', payload)
.then(response => {
resolve(response)
}).catch(error => {
reject(error)
})
})
}
}

Expand Down
56 changes: 56 additions & 0 deletions src/modules/purchase/order-history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import api from '@/api'

const url = '/purchase/orders'

const state = {
purchaseOrderHistories: [],
pagination: {}
}

const getters = {
purchaseOrderHistories: state => {
return state.purchaseOrderHistories
},
pagination: state => {
return state.pagination
}
}

const mutations = {
'FETCH_ARRAY' (state, payload) {
state.purchaseOrderHistories = payload.data
state.pagination = payload.meta
}
}

const actions = {
get ({ commit }, payload) {
return new Promise((resolve, reject) => {
api.get(url + '/' + payload.id + '/histories', payload)
.then(response => {
commit('FETCH_ARRAY', response)
resolve(response)
}).catch(error => {
reject(error)
})
})
},
add (context, payload) {
return new Promise((resolve, reject) => {
api.post(url + '/' + payload.id + '/histories', payload)
.then(response => {
resolve(response)
}).catch(error => {
reject(error)
})
})
}
}

export default {
namespaced: true,
state,
getters,
mutations,
actions
}
39 changes: 39 additions & 0 deletions src/modules/purchase/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const state = {
items: []
},
purchaseOrders: [],
histories: [],
pagination: {}
}

Expand All @@ -32,6 +33,9 @@ const getters = {
purchaseOrders: state => {
return state.purchaseOrders
},
histories: state => {
return state.histories
},
pagination: state => {
return state.pagination
}
Expand All @@ -48,6 +52,10 @@ const mutations = {
})
state.purchaseOrder = payload.data
},
'FETCH_HISTORY' (state, payload) {
state.histories = payload.data
state.pagination = payload.meta
},
'CREATE' (state, payload) {
state.purchaseOrder = payload
},
Expand All @@ -71,6 +79,27 @@ const actions = {
})
})
},
history ({ commit }, payload) {
return new Promise((resolve, reject) => {
api.get(url + '/history', payload)
.then(response => {
commit('FETCH_HISTORY', response)
resolve(response)
}).catch(error => {
reject(error)
})
})
},
storeHistory (context, payload) {
return new Promise((resolve, reject) => {
api.post(url + '/history', payload)
.then(response => {
resolve(response)
}).catch(error => {
reject(error)
})
})
},
find ({ commit }, payload) {
return new Promise((resolve, reject) => {
api.get(url + '/' + payload.id, payload)
Expand Down Expand Up @@ -151,6 +180,16 @@ const actions = {
reject(error)
})
})
},
sendBulkRequestApproval (context, payload) {
return new Promise((resolve, reject) => {
api.post(url + '/send-bulk-request-approval', payload)
.then(response => {
resolve(response)
}).catch(error => {
reject(error)
})
})
}
}

Expand Down
24 changes: 24 additions & 0 deletions src/views/Approval.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ export default {
if (this.resourceType === 'CashAdvance') {
({ resource, projectName, approvalStatus } = await this.handleApprovalCashAdvance(headers))
}
if (this.resourceType === 'PurchaseOrder') {
({ resource, projectName, approvalStatus } = await this.handleApprovalPurchaseOrder(headers))
}
if (this.resourceType === 'TransferSend') {
this.handleApprovalTransferSend()
}
Expand Down Expand Up @@ -232,6 +235,27 @@ export default {
}
}
},
async handleApprovalPurchaseOrder (headers) {
let status = 0
if (this.action === 'approve') {
status = 1
} else if (this.action === 'reject') {
status = -1
}

console.log(this.token, this.id, status, headers)
const { data: { data: purchaseOrder } } = await axios.post('approval-with-token/purchase/orders', { token: this.token, id: this.id, status: status })
if (purchaseOrder.form.approval_status == 0) {
this.warningMessage = 'Balance Not Enough'
} else if (purchaseOrder.form.approval_status != status) {
if (purchaseOrder.form.approval_status == 1) {
this.warningMessage = 'Purchase Order was approved before'
} else if (purchaseOrder.form.approval_status == -1) {
this.warningMessage = 'Purchase Order was rejected before'
}
}
return { resource: purchaseOrder, projectName: this.projectName, approvalStatus: purchaseOrder.form.approval_status }
},
async handleApprovalCashAdvance (headers) {
let status = 0
if (this.action === 'approve') {
Expand Down
14 changes: 14 additions & 0 deletions src/views/ApprovalAll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ export default {
if (this.resourceType === 'SalesDeliveryOrder') {
this.handleApprovalDeliveryOrder()
}
if (this.resourceType === 'PurchaseOrder') {
this.handleApprovalPurchaseOrder()
}
if (this.resourceType === 'PaymentCollection') {
this.handleApprovalPaymentCollection()
}
Expand Down Expand Up @@ -301,6 +304,17 @@ export default {
})
}
},
async handleApprovalPurchaseOrder (headers) {
let activity = ''
if (this.action === 'approve') {
activity = 'approved by email'
} else if (this.action === 'reject') {
activity = 'rejected by email'
}
const bulkId = JSON.parse(this.$route.query.ids)
const { data: { data: purchaseOrders } } = await axios.post('approval-with-token/purchase/orders/bulk', { token: this.token, bulk_id: bulkId, status: this.actionCode, activity: activity }, { headers })
this.resources = purchaseOrders
},
async handleApprovalCashAdvance (headers) {
let activity = ''
if (this.action === 'approve') {
Expand Down
21 changes: 15 additions & 6 deletions src/views/purchase/down-payment/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,22 @@
@input="filterSearch"
/>
</div>
<div class="text-center font-size-sm">
<a
href="javascript:void(0)"
@click="isAdvanceFilter = !isAdvanceFilter"
<div class="d-flex justify-content-between">
<router-link
to="/purchase/down-payment/request-approve-all"
class="btn btn-sm btn-light"
>
{{ $t('advance filter') | uppercase }} <i class="fa fa-caret-down" />
</a>
{{ $t('request approve all') | uppercase }}
</router-link>
<div class="font-size-sm mb-10 mt-2">
<a
href="javascript:void(0)"
@click="isAdvanceFilter = !isAdvanceFilter"
>
{{ $t('advance filter') | uppercase }} <i class="fa fa-caret-down" />
</a>
</div>
<div />
</div>
<div
v-show="isAdvanceFilter"
Expand Down
Loading