diff --git a/src/modules/purchase/down-payment.js b/src/modules/purchase/down-payment.js index 39c6c91f..8a53d751 100644 --- a/src/modules/purchase/down-payment.js +++ b/src/modules/purchase/down-payment.js @@ -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) + }) + }) } } diff --git a/src/modules/purchase/order-history.js b/src/modules/purchase/order-history.js new file mode 100644 index 00000000..74e7eb93 --- /dev/null +++ b/src/modules/purchase/order-history.js @@ -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 +} diff --git a/src/modules/purchase/order.js b/src/modules/purchase/order.js index 6a3cfcda..b4e0b991 100644 --- a/src/modules/purchase/order.js +++ b/src/modules/purchase/order.js @@ -22,6 +22,7 @@ const state = { items: [] }, purchaseOrders: [], + histories: [], pagination: {} } @@ -32,6 +33,9 @@ const getters = { purchaseOrders: state => { return state.purchaseOrders }, + histories: state => { + return state.histories + }, pagination: state => { return state.pagination } @@ -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 }, @@ -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) @@ -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) + }) + }) } } diff --git a/src/views/Approval.vue b/src/views/Approval.vue index a5dccaab..27ba1667 100644 --- a/src/views/Approval.vue +++ b/src/views/Approval.vue @@ -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() } @@ -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') { diff --git a/src/views/ApprovalAll.vue b/src/views/ApprovalAll.vue index 581bd49c..5cd4eb7e 100644 --- a/src/views/ApprovalAll.vue +++ b/src/views/ApprovalAll.vue @@ -202,6 +202,9 @@ export default { if (this.resourceType === 'SalesDeliveryOrder') { this.handleApprovalDeliveryOrder() } + if (this.resourceType === 'PurchaseOrder') { + this.handleApprovalPurchaseOrder() + } if (this.resourceType === 'PaymentCollection') { this.handleApprovalPaymentCollection() } @@ -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') { diff --git a/src/views/purchase/down-payment/Index.vue b/src/views/purchase/down-payment/Index.vue index 00265877..37f3d5bc 100644 --- a/src/views/purchase/down-payment/Index.vue +++ b/src/views/purchase/down-payment/Index.vue @@ -29,13 +29,22 @@ @input="filterSearch" /> -
- + - {{ $t('advance filter') | uppercase }} - + {{ $t('request approve all') | uppercase }} + + +
+ + +
+

+ {{ $t('Cancelled') }} +

+
+ + + + + + + + + + + + +
+ +
+
+ + + + + diff --git a/src/views/purchase/down-payment/RequestApproveAll.vue b/src/views/purchase/down-payment/RequestApproveAll.vue new file mode 100644 index 00000000..ea5774b3 --- /dev/null +++ b/src/views/purchase/down-payment/RequestApproveAll.vue @@ -0,0 +1,382 @@ + + + + + diff --git a/src/views/purchase/down-payment/Show.vue b/src/views/purchase/down-payment/Show.vue index 83b9d0ce..80f43ca3 100644 --- a/src/views/purchase/down-payment/Show.vue +++ b/src/views/purchase/down-payment/Show.vue @@ -41,6 +41,14 @@
+ +
@@ -299,13 +312,15 @@ import Breadcrumb from '@/views/Breadcrumb' import BreadcrumbPurchase from '../Breadcrumb' import PointTable from 'point-table-vue' import { mapGetters, mapActions } from 'vuex' +import PrintForm from './PrintForm' export default { components: { PurchaseMenu, Breadcrumb, BreadcrumbPurchase, - PointTable + PointTable, + PrintForm }, data () { return { @@ -423,6 +438,16 @@ export default { }).catch(error => { console.log(error.message) }) + }, + storeHistoryRecord (history) { + this.storeHistory({ + id: this.id, + activity: history + }).then(response => { + this.$notification.success('history recorded : ' + history) + }).catch(error => { + this.$notification.error(error.message) + }) } } } diff --git a/src/views/purchase/down-payment/routes.js b/src/views/purchase/down-payment/routes.js index e4aae3e9..843002b7 100644 --- a/src/views/purchase/down-payment/routes.js +++ b/src/views/purchase/down-payment/routes.js @@ -1,5 +1,6 @@ export default [ { path: '/purchase/down-payment', name: 'purchase.down-payment.index', component: () => import('./Index') }, + { path: '/purchase/down-payment/request-approve-all', name: 'purchase.down-payment.request-approve-all', component: () => import('./RequestApproveAll') }, { path: '/purchase/down-payment/create', name: 'purchase.down-payment.create', component: () => import('./Create') }, { path: '/purchase/down-payment/:id', name: 'purchase.down-payment.show', component: () => import('./Show') }, { path: '/purchase/down-payment/:id/edit', name: 'purchase.down-payment.edit', component: () => import('./Edit') } diff --git a/src/views/purchase/order/History.vue b/src/views/purchase/order/History.vue new file mode 100644 index 00000000..ddde96a1 --- /dev/null +++ b/src/views/purchase/order/History.vue @@ -0,0 +1,207 @@ + + + diff --git a/src/views/purchase/order/Index.vue b/src/views/purchase/order/Index.vue index 1e9774b0..75f34cd7 100644 --- a/src/views/purchase/order/Index.vue +++ b/src/views/purchase/order/Index.vue @@ -29,13 +29,22 @@ @input="filterSearch" />
-
- + - {{ $t('advance filter') | uppercase }} - + {{ $t('request approve all') | uppercase }} + + +
Form Status + + History +