add modules folder based on s_menu
This commit is contained in:
293
test/vuex/acc-one-approve-po/api/po.js
Normal file
293
test/vuex/acc-one-approve-po/api/po.js
Normal file
@@ -0,0 +1,293 @@
|
||||
const URL = "/one-api/mockup/purchase/order/PurchaseOrderV2/";
|
||||
const URLRO = "/one-api/mockup/receive-item-po/receiveitempo/";
|
||||
|
||||
export async function getSupplier(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "getSupplier", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function getItemCategory(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "getItemCategory", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function getWarehouse(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "getWarehouse", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function getItem(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "getItem", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function getItemUpdate(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "getItemUpdate", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function saveOrder(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "saveOrder", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function search(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "search", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function requestOrder(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "requestOrder", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function deleteOrder(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "deleteOrder", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function updateOrder(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "updateOrder", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function approvePOrder(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "approvePOrder", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function isValidMultipleWarehouse(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "isValidMultipleWarehouse", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateItemPO(params) {
|
||||
try {
|
||||
var response = await axios.post(URLRO + "generateItemPo", params);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getApprovalLevel(params) {
|
||||
try {
|
||||
var response = await axios.post(URL + 'getApproveLevel', params);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getDefaultSupplierPrice(payload) {
|
||||
try {
|
||||
var response = await axios.post(URL + "getDefaultSupplierPrice", payload);
|
||||
if (response.status !== 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: response.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
let data = response.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
593
test/vuex/acc-one-approve-po/components/dialogView.vue
Normal file
593
test/vuex/acc-one-approve-po/components/dialogView.vue
Normal file
@@ -0,0 +1,593 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- Dialog View -->
|
||||
<v-dialog v-model="dialogView" persistent width="85vw">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
DETAIL PURCHASE ORDER {{ selectedPO.PurchaseOrderNumber ?? "" }}
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text>
|
||||
<v-layout row wrap class="px-2 py-2">
|
||||
<!-- HEADER PO VIEW -->
|
||||
<v-layout row wrap class="pa-0 ma-0">
|
||||
<!-- Tanggal -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Nomor PO</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="value">: {{ selectedPO.PurchaseOrderNumber }}</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<!-- Tanggal -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Tanggal</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="value">: {{ selectedPO.DisplayDate }}</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
|
||||
<!-- Nomor Referensi -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Nomor Referensi</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="value">: {{ selectedPO.PurchaseOrderRefNumber }}</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
|
||||
<!-- Pajak Pendapatan (PPN) -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Pajak Pendapatan (PPN):</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="value">: {{ selectedPO.PurchaseOrderTaxPercentPpn }}%</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
|
||||
<!-- Pajak Penghasilan (PPH) -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Pajak Penghasilan (PPH)</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="value">: {{ selectedPO.PurchaseOrderTaxPercentPph }}%</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
|
||||
<!-- Vendor -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Vendor</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">: {{ selectedPO.SupplierCode }}
|
||||
{{ selectedPO.SupplierName }}
|
||||
</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
|
||||
<!-- Diskon Vendor -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Diskon Vendor(Tipe Diskon)</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span v-if="selectedPO.DiscountType == 'Percentage'" class="label">: {{ selectedPO.PurchaseOrderDiscountPercent }}% (Percentage)</span>
|
||||
<span v-if="selectedPO.DiscountType == 'Absolute'" class="label">: Rp {{ selectedPO.PurchaseOrderDiscountAmount }} (Absolut)</span>
|
||||
<span v-if="selectedPO.DiscountType == ''" class="label">: - (-)</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
|
||||
<!-- Jangka Waktu Pembayaran -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Jangka Waktu Pembayaran</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="value">: {{ selectedPO.PurchaseOrderPaymentTerm }} hari</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
|
||||
<!-- Tipe Gudang -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Tipe Gudang</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<!-- Tipe Gudang -->
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="value">: {{ selectedPO.PurchaseOrderWarehouseType }}</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
|
||||
<!-- Gudang -->
|
||||
<v-flex xs3 v-if="selectedPO.PurchaseOrderWarehouseType === 'Single'">
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Gudang</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9 v-if="selectedPO.PurchaseOrderWarehouseType === 'Single'">
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="value">: {{ selectedPO.WarehouseName }}</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
|
||||
<!-- Keterangan -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Biaya Ekspedisi</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="value">: {{ selectedPO && selectedPO.PurchaseOrderShippingCost != null
|
||||
? oneMoney(selectedPO.PurchaseOrderShippingCost) : '0' }}
|
||||
<span v-if="selectedPO.PurchaseOrderShippingCostStatus === 'Y'">Sudah dibayar
|
||||
</span>
|
||||
<span v-if="selectedPO.PurchaseOrderShippingCostStatus === 'N'">Belum dibayar
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
|
||||
<!-- Keterangan -->
|
||||
<v-flex xs3>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="label">Keterangan</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs9>
|
||||
<div class="label-value subheading mb-2">
|
||||
<span class="value">: {{ selectedPO.PurchaseOrderNote }}</span>
|
||||
</div>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<!-- TABEL ITEM VIEW -->
|
||||
<v-flex xs12>
|
||||
<v-data-table v-if="summary.length > 0" :headers="summaryHeaders" :items="summary" :loading="loading"
|
||||
hide-actions class="elevation-1 mt-4" expand item-key="M_ItemID">
|
||||
|
||||
<!-- Tabel Item -->
|
||||
<template slot="items" slot-scope="props">
|
||||
<tr @click="props.expanded = !props.expanded">
|
||||
<td class="text-xs-center">
|
||||
<v-icon>{{
|
||||
props.expanded
|
||||
? "keyboard_arrow_down"
|
||||
: "keyboard_arrow_right"
|
||||
}}</v-icon>
|
||||
</td>
|
||||
<td class="">
|
||||
<kbd>{{ props.item.M_ItemCode }}</kbd>
|
||||
{{ props.item.M_ItemDesc }}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-center">
|
||||
{{ props.item.TotalPoQty }} {{ props.item.PoItemUnitName }}
|
||||
</td>
|
||||
<td class="text-xs-center">
|
||||
{{ oneMoney(props.item.RealPrice) }}
|
||||
</td>
|
||||
<td class="text-xs-right">
|
||||
<div v-if="props.item.discountType === 'R'">
|
||||
{{ oneMoney(props.item.discount) }}
|
||||
</div>
|
||||
<div v-if="props.item.discountType === 'P'">
|
||||
<kbd>{{ props.item.discount }}%</kbd>
|
||||
{{ oneMoney(props.item.summaryDiscountAmount) }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-xs-right">
|
||||
{{ oneMoney(props.item.Price) }}
|
||||
</td>
|
||||
<td class="text-xs-right">
|
||||
{{ oneMoney(props.item.Total) }}
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<!-- Detail per Baris Item -->
|
||||
<template slot="expand" slot-scope="props">
|
||||
<v-card flat>
|
||||
<v-card-text class="pl-3">
|
||||
<div class="ml-3 mb-3">
|
||||
<v-data-table :headers="detailHeaders" :items="props.item.Details" hide-actions
|
||||
class="elevation-0">
|
||||
<template slot="items" slot-scope="detailProps">
|
||||
<td class="">
|
||||
<kbd>{{ detailProps.item.M_ItemCode }}</kbd>
|
||||
|
||||
{{ detailProps.item.M_ItemDesc }}
|
||||
</td>
|
||||
<td class="">
|
||||
{{
|
||||
detailProps.item.PurchaseRequestNumber
|
||||
}}
|
||||
</td>
|
||||
<td class="">
|
||||
{{
|
||||
detailProps.item.M_BranchName ??
|
||||
detailProps.item.S_RegionalName
|
||||
}}
|
||||
</td>
|
||||
<td class="py-1">
|
||||
{{ detailProps.item.warehouse.WarehouseName }}
|
||||
</td>
|
||||
<td class="text-xs-center">
|
||||
{{ detailProps.item.PoQty }}
|
||||
{{ detailProps.item.PoItemUnitName }}
|
||||
</td>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<!-- Tabel di bawah Item -->
|
||||
<template v-slot:footer>
|
||||
<tr>
|
||||
<td :colspan="4">
|
||||
<strong class="ml-2">TOTAL HARGA TANPA DISKON</strong>
|
||||
</td>
|
||||
<td :colspan="3" class="text-xs-right">
|
||||
<strong>{{
|
||||
selectedPO && selectedPO.TotalRealPrice != null
|
||||
? oneMoney(selectedPO.TotalRealPrice) : '0'
|
||||
}}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td :colspan="4">
|
||||
<strong class="ml-2">TOTAL DISKON PER ITEM</strong>
|
||||
</td>
|
||||
<td :colspan="3" class="text-xs-right">
|
||||
<strong>{{
|
||||
selectedPO && selectedPO.TotalDiskonPerItem != null
|
||||
? oneMoney(selectedPO.TotalDiskonPerItem) : '0'
|
||||
}}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td :colspan="4">
|
||||
<strong class="ml-2">DISKON VENDOR</strong>
|
||||
</td>
|
||||
<td :colspan="3" class="text-xs-right">
|
||||
<strong>{{
|
||||
selectedPO && selectedPO.DiscountAmount != null
|
||||
? oneMoney(selectedPO.DiscountAmount) : '0'
|
||||
}}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td :colspan="4">
|
||||
<strong class="ml-5">PAJAK PENDAPATAN(PPN)</strong>
|
||||
</td>
|
||||
<td :colspan="3" class="text-xs-right">
|
||||
<strong>{{
|
||||
selectedPO && selectedPO.PurchaseOrderTaxAmountPpn != null
|
||||
? oneMoney(selectedPO.PurchaseOrderTaxAmountPpn) : '0'
|
||||
}}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td :colspan="4">
|
||||
<strong class="ml-5">PAJAK PENGHASILAN(PPH)</strong>
|
||||
</td>
|
||||
<td :colspan="3" class="text-xs-right">
|
||||
<strong>{{
|
||||
selectedPO && selectedPO.PurchaseOrderTaxAmountPph != null
|
||||
? oneMoney(selectedPO.PurchaseOrderTaxAmountPph) : '0'
|
||||
}}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td :colspan="4">
|
||||
<strong class="ml-2">PAJAK</strong>
|
||||
</td>
|
||||
<td :colspan="3" class="text-xs-right">
|
||||
<strong>{{ selectedPO && selectedPO.TaxAmount != null
|
||||
? oneMoney(selectedPO.TaxAmount) : '0' }}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td :colspan="4">
|
||||
<strong>TOTAL</strong>
|
||||
</td>
|
||||
<td :colspan="3" class="text-xs-right">
|
||||
<strong>{{
|
||||
selectedPO && selectedPO.PurchaseOrderGrandTotal != null
|
||||
? oneMoney(selectedPO.PurchaseOrderGrandTotal) : '0'
|
||||
}}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
|
||||
<v-divider></v-divider>
|
||||
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="green" flat @click="dialogView = false">
|
||||
TUTUP
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
selectedDateForm: null,
|
||||
refNumber: "",
|
||||
taxPpn: 0,
|
||||
taxPph: 0,
|
||||
selectedSupplier: {},
|
||||
paymentTerm: 0,
|
||||
warehouseType: "",
|
||||
selectedWarehouse: {},
|
||||
note: "",
|
||||
selectedItem: [],
|
||||
detailHeaders: [
|
||||
// {
|
||||
// text: "KODE ITEM",
|
||||
// align: "center",
|
||||
// sortable: false,
|
||||
// value: "M_ItemCode",
|
||||
// width: "15%",
|
||||
// class: "blue lighten-4 black--text",
|
||||
// },
|
||||
{
|
||||
text: "NAMA PRODUK",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "M_ItemDesc",
|
||||
width: "20%",
|
||||
class: "blue lighten-4 black--text",
|
||||
},
|
||||
{
|
||||
text: "PR NUMBER",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "M_ItemDesc",
|
||||
width: "10%",
|
||||
class: "blue lighten-4 black--text",
|
||||
},
|
||||
{
|
||||
text: "CABANG",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "M_BranchName",
|
||||
width: "20%",
|
||||
class: "blue lighten-4 black--text",
|
||||
},
|
||||
{
|
||||
text: "GUDANG",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "M_BranchName",
|
||||
width: "30%",
|
||||
class: "blue lighten-4 black--text",
|
||||
},
|
||||
// {
|
||||
// text: "UNIT",
|
||||
// align: "center",
|
||||
// sortable: false,
|
||||
// value: "ItemUnitName",
|
||||
// width: "10%",
|
||||
// class: "blue lighten-4 black--text",
|
||||
// },
|
||||
{
|
||||
text: "QTY",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "PoQty",
|
||||
width: "15%",
|
||||
class: "blue lighten-4 black--text",
|
||||
},
|
||||
],
|
||||
summaryHeaders: [
|
||||
{
|
||||
text: "",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "expand",
|
||||
width: "5%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "ITEM",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "M_ItemCode",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "QTY",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "PoQty",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "HARGA",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "price",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "DISKON",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "price",
|
||||
width: "20%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "HARGA SETELAH DISKON",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "price",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "TOTAL",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "Total",
|
||||
width: "20%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
statusOptions() {
|
||||
return this.$store.state.po.statusOptions;
|
||||
},
|
||||
dialogView: {
|
||||
get() {
|
||||
return this.$store.state.po.dialogView;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_dialogView", val);
|
||||
},
|
||||
},
|
||||
selectedPO: {
|
||||
get() {
|
||||
return this.$store.state.po.selectedPO;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_selectedPO", val);
|
||||
},
|
||||
},
|
||||
summary: {
|
||||
get() {
|
||||
return this.$store.state.po.summary;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_summary", val);
|
||||
},
|
||||
},
|
||||
loading: {
|
||||
get() {
|
||||
return this.$store.state.po.loading;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_loading", val);
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
roundToThreeSignificantDigits(num) {
|
||||
if (num === 0) return 0;
|
||||
|
||||
// Hitung jumlah digit
|
||||
const absNum = Math.abs(num);
|
||||
const magnitude = Math.floor(Math.log10(absNum)) + 1;
|
||||
|
||||
// Jika kurang dari 3 digit, tidak perlu dibulatkan
|
||||
if (magnitude <= 3) return num;
|
||||
|
||||
// Hitung faktor pembulatan
|
||||
const factor = Math.pow(10, magnitude - 3);
|
||||
|
||||
// Bulatkan
|
||||
return Math.round(num / factor) * factor;
|
||||
},
|
||||
oneMoney(value) {
|
||||
//return one_money(value);
|
||||
// let splitValue = value.toString().split(".");
|
||||
// if(splitValue.length > 1) {
|
||||
// let val = splitValue[0]
|
||||
// return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".") + "," + this.roundToThreeSignificantDigits(splitValue[1]);
|
||||
// } else {
|
||||
// return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
// }
|
||||
// Ubah ke float jika belum angka
|
||||
if (typeof value !== 'number') {
|
||||
value = parseFloat(value);
|
||||
}
|
||||
|
||||
if (isNaN(value)) return '0,00';
|
||||
|
||||
// Bulatkan dulu ke 2 desimal
|
||||
const fixed = value.toFixed(2); // hasil string, misal "16200000.00" atau "123456.70"
|
||||
const splitValue = fixed.split(".");
|
||||
|
||||
const val = splitValue[0]; // bagian ribuan
|
||||
const decimal = splitValue[1]; // bagian desimal
|
||||
|
||||
const formatted = val.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
|
||||
return `${formatted},${decimal}`;
|
||||
},
|
||||
formatDate(date) {
|
||||
if (!date) return null;
|
||||
|
||||
const [year, month, day] = date.split("-");
|
||||
return `${day}-${month}-${year}`;
|
||||
},
|
||||
formatRupiah(angka) {
|
||||
const format = new Intl.NumberFormat("id-ID", {
|
||||
style: "currency",
|
||||
currency: "IDR",
|
||||
minimumFractionDigits: 0,
|
||||
});
|
||||
return "Rp " + format.format(angka).replace("Rp", "").trim();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.label-value subheading mb-2 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-weight: bold;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: 1rem;
|
||||
}
|
||||
</style>
|
||||
713
test/vuex/acc-one-approve-po/components/po.vue
Normal file
713
test/vuex/acc-one-approve-po/components/po.vue
Normal file
@@ -0,0 +1,713 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-dialog v-model="dialogDelete" persistent width="500">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
KONFIRMASI
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text>
|
||||
Apakah anda yakin untuk menghapus
|
||||
<span style="font-weight: bold;">{{
|
||||
selectedPO.PurchaseOrderNumber
|
||||
}}</span>
|
||||
??
|
||||
</v-card-text>
|
||||
|
||||
<v-divider></v-divider>
|
||||
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="red" :disabled="loading" :loading="loading" flat @click="dialogDelete = false">
|
||||
Tidak
|
||||
</v-btn>
|
||||
<v-btn color="green" :disabled="loading" :loading="loading" flat @click="deletePO()">
|
||||
Ya
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<v-dialog v-model="dialogConfirmation" persistent width="500">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2" primary-title>
|
||||
KONFIRMASI
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text>
|
||||
Apakah anda yakin untuk mengunci
|
||||
<span style="font-weight: bold;">{{
|
||||
selectedPO.PurchaseOrderNumber
|
||||
}}</span>
|
||||
untuk melanjutkan ke proses approve?
|
||||
<p style="font-style: italic;" class="mt-3">
|
||||
*Setelah dikunci PO tidak dapat di edit
|
||||
</p>
|
||||
</v-card-text>
|
||||
|
||||
<v-divider></v-divider>
|
||||
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="red" :disabled="loading" :loading="loading" flat @click="dialogConfirmation = false">
|
||||
Tidak
|
||||
</v-btn>
|
||||
<v-btn color="green" :disabled="loading" :loading="loading" flat @click="requestOrder()">
|
||||
Ya
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<v-snackbar v-model="snackbar.state" :color="snackbar.type" :timeout="3000" multi-line top>
|
||||
{{ snackbar.message }}
|
||||
<v-btn flat @click="snackbar.state = false">
|
||||
Close
|
||||
</v-btn>
|
||||
</v-snackbar>
|
||||
|
||||
<v-toolbar color="primary" dark>
|
||||
<v-toolbar-title class="white--text">PURCHASE ORDER APPROVE</v-toolbar-title>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn v-if="(flag == 'G')" @click="goBack()" color="orange darken-2" title="Kembali ke listing pending approval" dark>
|
||||
<v-icon dark left>arrow_back</v-icon>Back
|
||||
</v-btn>
|
||||
</v-toolbar>
|
||||
|
||||
<v-card>
|
||||
<v-layout row wrap class="px-2 py-2">
|
||||
<v-flex xs3>
|
||||
<v-menu v-model="menuSelectedDate" :close-on-content-click="false" transition="scale-transition"
|
||||
:nudge-right="40" lazy offset-y max-width="290px" min-width="290px">
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-text-field :value="selectedDateFormatted" label="Tanggal Mulai" readonly class="mr-2"
|
||||
outline hide-details v-on="on"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker no-title hide-details v-model="selectedDate"
|
||||
@input="menuSelectedDate = false"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-flex>
|
||||
<v-flex xs3>
|
||||
<v-menu v-model="menuSelectedDateEnd" :close-on-content-click="false" transition="scale-transition"
|
||||
:nudge-right="40" lazy offset-y max-width="290px" min-width="290px">
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-text-field :value="endDateFormatted" label="Tanggal Akhir" readonly class="mr-2" outline
|
||||
hide-details v-on="on"></v-text-field>
|
||||
</template>
|
||||
<v-date-picker no-title hide-details v-model="selectedDateEnd"
|
||||
@input="menuSelectedDateEnd = false"></v-date-picker>
|
||||
</v-menu>
|
||||
</v-flex>
|
||||
<v-flex xs3>
|
||||
<v-select :items="statusOptions" label="Status" hide-details class="mini-select mr-2" v-model="selectedStatus"
|
||||
item-text="title" return-object outline></v-select>
|
||||
</v-flex>
|
||||
<v-flex xs3>
|
||||
<v-text-field v-model="search" label="Cari..." placeholder="NO. PO" class="mr-2" outline hide-details>
|
||||
</v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card>
|
||||
|
||||
<v-card class="pa-2 mt-2">
|
||||
<div style="height: 60vh; overflow-y: scroll;">
|
||||
<v-data-table :headers="headers" :items="poList" :loading="loading" hide-actions class="elevation-1">
|
||||
<template v-slot:items="props">
|
||||
<td class="text-xs-center">{{ props.item.PurchaseOrderNumber }}</td>
|
||||
<td class="text-xs-center">{{ props.item.PurchaseOrderDate }}</td>
|
||||
<td class="text-xs-left">{{ props.item.SupplierName }}</td>
|
||||
<td class="text-xs-center">
|
||||
<p class="my-0 p-0">
|
||||
<kbd>{{ props.item.PurchaseOrderWarehouseType }}</kbd>
|
||||
</p>
|
||||
<p class="my-0 p-0">
|
||||
{{ props.item.WarehouseName }}
|
||||
</p>
|
||||
</td>
|
||||
<td class="text-xs-left">{{ props.item.PurchaseOrderNote }}</td>
|
||||
<td class="text-xs-right">
|
||||
Rp. {{ props.item.PurchaseOrderGrandTotal != null ? oneMoney(props.item.PurchaseOrderGrandTotal) : '0' }}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-center">
|
||||
<v-chip color="blue" v-if="props.item.PurchaseOrderStatus === 'Draft'" text-color="white">{{
|
||||
props.item.PurchaseOrderStatus }}
|
||||
</v-chip>
|
||||
<v-chip color="warning" v-else-if="props.item.PurchaseOrderStatus === 'Pending'" text-color="white">{{
|
||||
props.item.PurchaseOrderStatus }}
|
||||
</v-chip>
|
||||
<v-chip color="green" v-else-if="props.item.PurchaseOrderStatus === 'Approved'" text-color="white">{{
|
||||
props.item.PurchaseOrderStatus }}
|
||||
</v-chip>
|
||||
<v-chip color="red" v-else-if="props.item.PurchaseOrderStatus === 'Rejected'" text-color="white">{{
|
||||
props.item.PurchaseOrderStatus }}
|
||||
</v-chip>
|
||||
<v-chip color="primary" v-else-if="props.item.PurchaseOrderStatus === 'Completed'" text-color="white">{{
|
||||
props.item.PurchaseOrderStatus }}
|
||||
</v-chip>
|
||||
<v-chip v-else text-color="white">{{ props.item.PurchaseOrderStatus }}
|
||||
</v-chip>
|
||||
</td>
|
||||
|
||||
<td class="text-xs-center">
|
||||
<!-- Belum Approve -->
|
||||
<div v-if="props.item.PurchaseOrderStatus === 'Pending'">
|
||||
<v-btn
|
||||
:disabled="loading || props.item.PurchaseOrderStatus == 'Approved' || approve_level != '1'"
|
||||
@click="approvePO(props.item)" round color="primary" small :outline="isApproved(props.item, 'M')"
|
||||
>
|
||||
{{ props.item.PurchaseOrderApprovedManagerUserID == '0' ? 'Approve (Manager)' : 'Approved (Manager)'}}
|
||||
<v-icon
|
||||
small right dark
|
||||
v-if="props.item.PurchaseOrderApprovedManagerUserID != '0'"
|
||||
>done_all</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<v-btn
|
||||
:disabled="loading || props.item.PurchaseOrderStatus == 'Approved' || approve_level != '2'"
|
||||
@click="approvePO(props.item)" round color="primary" small :outline="isApproved(props.item, 'K')"
|
||||
>
|
||||
Approve (Kepala Reg)
|
||||
<v-icon
|
||||
small right dark
|
||||
>done</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-btn icon :disabled="loading" @click="openDialogView(props.item)" v-on="on">
|
||||
<v-icon color="blue">visibility</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<span>View PO</span>
|
||||
</v-tooltip>
|
||||
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-btn icon :disabled="loading || props.item.PurchaseOrderStatus == 'Approve'" @click="openDialogEdit(props.item)" v-on="on">
|
||||
<v-icon color="blue">edit</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<span>Edit PO</span>
|
||||
</v-tooltip>
|
||||
</div>
|
||||
|
||||
<div v-if="props.item.PurchaseOrderStatus == 'Approved'">
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-btn icon :disabled="loading" @click="openDialogView(props.item)" v-on="on">
|
||||
<v-icon color="blue">visibility</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<span>View PO</span>
|
||||
</v-tooltip>
|
||||
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-btn icon :disabled="loading" @click="doPrint(props.item)" v-on="on">
|
||||
<v-icon color="red">picture_as_pdf</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<span>PDF PO</span>
|
||||
</v-tooltip>
|
||||
</div>
|
||||
</td>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</div>
|
||||
</v-card>
|
||||
<v-card class="text-xs-left pa-2">
|
||||
<v-pagination v-model="selectedPage" :length="totalPage"></v-pagination>
|
||||
</v-card>
|
||||
<po-form></po-form>
|
||||
<po-view></po-view>
|
||||
<one-dialog-print :title="printtitle" :width="printwidth" :height="700" :status="openprint" :urlprint="urlprint"
|
||||
@close-dialog-print="openprint = false"></one-dialog-print>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.date-type-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.flex-items-center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.table.v-table tbody td,
|
||||
.table.v-table tbody tr {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
components: {
|
||||
"po-form": httpVueLoader("./poForm.vue"),
|
||||
"po-view": httpVueLoader("./dialogView.vue"),
|
||||
'one-dialog-print': httpVueLoader('../../common/oneDialogPrintX.vue')
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
menuSelectedDate: false,
|
||||
menuSelectedDateEnd: false,
|
||||
msgAlertDeleteOrReject: "",
|
||||
dialogAlertRejectRequest: false,
|
||||
dialogAlertDeleteDetail: false,
|
||||
amountRules: [(v) => v >= 0 || "Jumlah harus diisi"],
|
||||
validationDetail: false,
|
||||
formatreport: "pdf",
|
||||
urlprint: "",
|
||||
printtitle: '',
|
||||
printwidth: '100%',
|
||||
headers: [
|
||||
{
|
||||
text: "NO PO",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "5%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "TANGGAL",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "VENDOR",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "20%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "GUDANG",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "KETERANGAN",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "",
|
||||
width: "20%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "TOTAL",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "STATUS",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "",
|
||||
width: "10%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "AKSI",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
],
|
||||
detailHeaders: [
|
||||
{
|
||||
text: "KODE ITEM",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "no",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "NAMA ITEM",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "requestDate",
|
||||
width: "35%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "QTY",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "requestDate",
|
||||
width: "15%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
{
|
||||
text: "HARGA",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "requestDate",
|
||||
width: "25%",
|
||||
class: "blue lighten-3 white--text",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch("po/searchData");
|
||||
this.$store.dispatch("po/getItemCategory");
|
||||
this.$store.dispatch("po/getApprovalLevel");
|
||||
},
|
||||
computed: {
|
||||
flag() {
|
||||
return this.$store.state.po.flag;
|
||||
},
|
||||
status() {
|
||||
return this.$store.state.po.status;
|
||||
},
|
||||
xstartdate() {
|
||||
return this.$store.state.po.xstartdate;
|
||||
},
|
||||
statusOptions() {
|
||||
return this.$store.state.po.statusOptions;
|
||||
},
|
||||
selectedDate: {
|
||||
get() {
|
||||
return this.$store.state.po.selectedDate;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_selectedDate", val);
|
||||
this.$store.dispatch("po/searchData");
|
||||
},
|
||||
},
|
||||
selectedStatus: {
|
||||
get() {
|
||||
return this.$store.state.po.selectedStatus;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_selectedStatus", val);
|
||||
this.$store.dispatch("po/searchData");
|
||||
},
|
||||
},
|
||||
statusOptions: {
|
||||
get() {
|
||||
return this.$store.state.po.statusOptions;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_statusOptions", val);
|
||||
},
|
||||
},
|
||||
selectedPO: {
|
||||
get() {
|
||||
return this.$store.state.po.selectedPO;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_selectedPO", val);
|
||||
},
|
||||
},
|
||||
dialogConfirmation: {
|
||||
get() {
|
||||
return this.$store.state.po.dialogConfirmation;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_dialogConfirmation", val);
|
||||
},
|
||||
},
|
||||
selectedDateEnd: {
|
||||
get() {
|
||||
return this.$store.state.po.selectedDateEnd;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_selectedDateEnd", val);
|
||||
this.$store.dispatch("po/searchData");
|
||||
},
|
||||
},
|
||||
|
||||
search: {
|
||||
get() {
|
||||
return this.$store.state.po.search;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_search", val);
|
||||
this.$store.dispatch("po/searchData");
|
||||
},
|
||||
},
|
||||
selectedDateFormatted() {
|
||||
return this.formatDate(this.selectedDate);
|
||||
},
|
||||
endDateFormatted() {
|
||||
return this.formatDate(this.selectedDateEnd);
|
||||
},
|
||||
poList() {
|
||||
return this.$store.state.po.poList;
|
||||
},
|
||||
snackbar: {
|
||||
get() {
|
||||
return this.$store.state.po.snackbar;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_snackbar", val);
|
||||
},
|
||||
},
|
||||
totalPage: {
|
||||
get() {
|
||||
return this.$store.state.po.totalPage;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_totalPage", val);
|
||||
},
|
||||
},
|
||||
selectedPage: {
|
||||
get() {
|
||||
return this.$store.state.po.selectedPage;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_selectedPage", val);
|
||||
this.$store.dispatch("po/searchData");
|
||||
},
|
||||
},
|
||||
loading: {
|
||||
get() {
|
||||
return this.$store.state.po.loading;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_loading", val);
|
||||
},
|
||||
},
|
||||
dialogForm: {
|
||||
get() {
|
||||
return this.$store.state.po.dialogForm;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_dialogForm", val);
|
||||
},
|
||||
},
|
||||
dialogFormAct: {
|
||||
get() {
|
||||
return this.$store.state.po.dialogFormAct;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_dialogFormAct", val);
|
||||
},
|
||||
},
|
||||
dialogDelete: {
|
||||
get() {
|
||||
return this.$store.state.po.dialogDelete;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_dialogDelete", val);
|
||||
},
|
||||
},
|
||||
dialogView: {
|
||||
get() {
|
||||
return this.$store.state.po.dialogView;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_dialogView", val);
|
||||
},
|
||||
},
|
||||
openprint: {
|
||||
get() {
|
||||
return this.$store.state.po.open_print;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("po/update_open_print", val);
|
||||
},
|
||||
},
|
||||
approve_level() {
|
||||
return this.$store.state.po.approve_level
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goBack() {
|
||||
window.history.back();
|
||||
// location.href = "/one-ui/test/vuex/one-accone-approve-all/"
|
||||
},
|
||||
doPrint(val) {
|
||||
// console.log(val)
|
||||
this.printwidth = 1028
|
||||
this.printtitle = ""
|
||||
let user = one_user()
|
||||
tm = Date.now()
|
||||
var rptname = 'rpt_po_001'
|
||||
var formatrpt = this.formatreport
|
||||
|
||||
this.urlprint = "/birt/run?__report=report/one/accounting/" + rptname + ".rptdesign&__format=" + formatrpt + "&PID=" + val.PurchaseOrderID + "&username=" + user.M_StaffName + "&tm=" + tm
|
||||
// console.log(this.urlprint)
|
||||
|
||||
this.$store.commit("po/update_open_print", true)
|
||||
},
|
||||
roundToThreeSignificantDigits(num) {
|
||||
if (num === 0) return 0;
|
||||
|
||||
// Hitung jumlah digit
|
||||
const absNum = Math.abs(num);
|
||||
const magnitude = Math.floor(Math.log10(absNum)) + 1;
|
||||
|
||||
// Jika kurang dari 3 digit, tidak perlu dibulatkan
|
||||
if (magnitude <= 3) return num;
|
||||
|
||||
// Hitung faktor pembulatan
|
||||
const factor = Math.pow(10, magnitude - 3);
|
||||
|
||||
// Bulatkan
|
||||
return Math.round(num / factor) * factor;
|
||||
},
|
||||
oneMoney(value) {
|
||||
//return one_money(value);
|
||||
// let splitValue = value.toString().split(".");
|
||||
// if(splitValue.length > 1) {
|
||||
// let val = splitValue[0]
|
||||
// return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".") + "," + this.roundToThreeSignificantDigits(splitValue[1]);
|
||||
// } else {
|
||||
// return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
// }
|
||||
// Ubah ke float jika belum angka
|
||||
if (typeof value !== 'number') {
|
||||
value = parseFloat(value);
|
||||
}
|
||||
|
||||
if (isNaN(value)) return '0,00';
|
||||
|
||||
// Bulatkan dulu ke 2 desimal
|
||||
const fixed = value.toFixed(2); // hasil string, misal "16200000.00" atau "123456.70"
|
||||
const splitValue = fixed.split(".");
|
||||
|
||||
const val = splitValue[0]; // bagian ribuan
|
||||
const decimal = splitValue[1]; // bagian desimal
|
||||
|
||||
const formatted = val.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
|
||||
return `${formatted},${decimal}`;
|
||||
},
|
||||
openDialogConfirmation(data) {
|
||||
this.selectedPO = data;
|
||||
this.dialogConfirmation = true;
|
||||
},
|
||||
openDialogDelete(data) {
|
||||
this.selectedPO = data;
|
||||
this.dialogDelete = true;
|
||||
},
|
||||
async requestOrder() {
|
||||
await this.$store.dispatch("po/requestOrder");
|
||||
await this.$store.dispatch("po/searchData");
|
||||
|
||||
// Wait for DOM to update
|
||||
this.$nextTick(() => {
|
||||
this.$forceUpdate();
|
||||
});
|
||||
},
|
||||
deletePO() {
|
||||
this.$store.dispatch("po/deleteOrder");
|
||||
},
|
||||
openDialogAdd() {
|
||||
this.$store.dispatch("po/resetForm");
|
||||
this.dialogForm = true;
|
||||
},
|
||||
openDialogView(data) {
|
||||
this.selectedPO = data;
|
||||
this.$store.dispatch("po/resetForm");
|
||||
this.dialogView = true;
|
||||
this.$store.dispatch("po/getItemUpdate");
|
||||
},
|
||||
openDialogEdit(data) {
|
||||
this.selectedPO = data;
|
||||
this.dialogFormAct = "EDIT";
|
||||
this.dialogForm = true;
|
||||
this.$store.dispatch("po/assignEdit");
|
||||
this.$store.dispatch("po/getItemUpdate");
|
||||
},
|
||||
formatRupiah(angka) {
|
||||
const format = new Intl.NumberFormat("id-ID", {
|
||||
style: "currency",
|
||||
currency: "IDR",
|
||||
minimumFractionDigits: 0,
|
||||
});
|
||||
return "Rp " + format.format(angka).replace("Rp", "").trim();
|
||||
},
|
||||
formatDate(date) {
|
||||
if (!date) return null;
|
||||
|
||||
const [year, month, day] = date.split("-");
|
||||
return `${day}-${month}-${year}`;
|
||||
},
|
||||
deFormatedDate(date) {
|
||||
if (!date) return null;
|
||||
|
||||
const [day, month, year] = date.split("-");
|
||||
return `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
||||
},
|
||||
async approvePO(data) {
|
||||
try {
|
||||
if (this.approve_level == '1' && data.PurchaseOrderApprovedManagerUserID != '0') {
|
||||
this.snackbar = {
|
||||
state: true,
|
||||
type: "warning",
|
||||
message: "Sudah diapprove oleh manager"
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.PurchaseOrderID != '' && data.PurchaseOrderStatus != 'Approved') {
|
||||
await this.$store.dispatch("po/approveOrder", { poID: data.PurchaseOrderID });
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000); // Short delay to allow the snackbar to be visible
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error approving order:", error);
|
||||
this.snackbar = {
|
||||
state: true,
|
||||
type: "error",
|
||||
message: "Gagal mengapprove Purchase Order"
|
||||
};
|
||||
}
|
||||
},
|
||||
isApproved(data, type) {
|
||||
if (!data) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (data.PurchaseOrderStatus == 'Approved') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (type == 'M') {
|
||||
if (data.PurchaseOrderApprovedManagerUserID == '0') {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (type == 'K') {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogApprove(val, old) { },
|
||||
},
|
||||
};
|
||||
</script>
|
||||
1509
test/vuex/acc-one-approve-po/components/poForm.vue
Normal file
1509
test/vuex/acc-one-approve-po/components/poForm.vue
Normal file
File diff suppressed because it is too large
Load Diff
475
test/vuex/acc-one-approve-po/functions/functions.js
Normal file
475
test/vuex/acc-one-approve-po/functions/functions.js
Normal file
@@ -0,0 +1,475 @@
|
||||
/**
|
||||
* Utility functions for the ACC One Purchase Order application
|
||||
*/
|
||||
|
||||
// /**
|
||||
// * Groups an array of objects by a specified key
|
||||
// * @param {Array} array - The array of objects to group
|
||||
// * @param {String} key - The key to group by
|
||||
// * @returns {Object} - An object with keys representing the grouped values and arrays as values
|
||||
// */
|
||||
// export const groupBy = (array, key) => {
|
||||
// return array.reduce((result, item) => {
|
||||
// const groupKey = item[key];
|
||||
// if (!result[groupKey]) {
|
||||
// result[groupKey] = [];
|
||||
// }
|
||||
// result[groupKey].push(item);
|
||||
// return result;
|
||||
// }, {});
|
||||
// };
|
||||
/**
|
||||
* Groups an array of objects by one or multiple keys
|
||||
* @param {Array} array - The array of objects to group
|
||||
* @param {Function|String|Array} key - The key(s) to group by. Can be a string, array of strings, or a function.
|
||||
* @returns {Object} - An object with keys representing the grouped values and arrays as values
|
||||
*/
|
||||
export const groupBy = (array, key) => {
|
||||
return array.reduce((result, item) => {
|
||||
let groupKey;
|
||||
|
||||
// Handle single key (string), multiple keys (array), or custom function
|
||||
if (typeof key === 'function') {
|
||||
groupKey = key(item);
|
||||
} else if (Array.isArray(key)) {
|
||||
groupKey = key.map(k => item[k]).join('_'); // Combine multiple keys with underscore
|
||||
} else {
|
||||
groupKey = item[key];
|
||||
}
|
||||
|
||||
if (!result[groupKey]) {
|
||||
result[groupKey] = [];
|
||||
}
|
||||
result[groupKey].push(item);
|
||||
return result;
|
||||
}, {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Groups purchase request data by M_ItemID
|
||||
* Terjadi jika ada beberapa item yang sama, maka akan digabungkan berdasarkan M_ItemID dan PoItemUnitID
|
||||
* @param {Array} purchaseRequestData - Array of purchase request objects
|
||||
* @returns {Array} - Array of objects with M_ItemID, M_ItemCode, M_ItemDesc, unit information, converted PoQty, and Details array
|
||||
*/
|
||||
export const groupPurchaseRequestsByItemId_old = (purchaseRequestData) => {
|
||||
const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'PoItemUnitID']);
|
||||
console.log("grouped");
|
||||
console.log(grouped);
|
||||
|
||||
return Object.keys(grouped).map(itemId => {
|
||||
const items = grouped[itemId];
|
||||
const firstItem = items[0];
|
||||
|
||||
/* Sebelum Kalkulasi Konversi Item di BE */
|
||||
// // Calculate total PoQty from all items
|
||||
// const totalPoQty = calculateTotalQuantity(items, 'PoQty');
|
||||
// // Get the conversion factor from the first item
|
||||
// const conversionFactor = Number(firstItem.DefaultPurchase.UnitConvertAmount) || 1;
|
||||
// // Convert the total quantity and round up if it's a decimal
|
||||
// const convertedPoQty = Math.ceil(convertUnits(totalPoQty, conversionFactor));
|
||||
|
||||
/* Sesudah Kalkulasi Konversi Item di BE getItem() */
|
||||
const convertedPoQty = calculateTotalQuantity(items, 'PoQty')
|
||||
console.log("Total PoQty for itemId", itemId, " : ", convertedPoQty);
|
||||
|
||||
let price = 0;
|
||||
|
||||
if (parseFloat(firstItem.discount) > 0) {
|
||||
if (firstItem.discountType === 'P') {
|
||||
price = Number(firstItem.DefaultPurchase.SupplierPricePrice) - (Number(firstItem.discount) * (Number(firstItem.DefaultPurchase.SupplierPricePrice) / 100));
|
||||
}
|
||||
if (firstItem.discountType === 'R') {
|
||||
price = Number(firstItem.DefaultPurchase.SupplierPricePrice) - Number(firstItem.discount);
|
||||
}
|
||||
|
||||
} else {
|
||||
price = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0;
|
||||
}
|
||||
|
||||
// Get the price from the first item
|
||||
const realPrice = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0;
|
||||
|
||||
// Calculate the total (PoQty * price)
|
||||
const total = convertedPoQty * price;
|
||||
|
||||
const itemParts = itemId.split('_');
|
||||
const M_ItemID = itemParts[0];
|
||||
|
||||
return {
|
||||
keyID: itemId,
|
||||
M_ItemID: M_ItemID,
|
||||
PurchaseOrderID: firstItem.PurchaseOrderID ?? 0,
|
||||
PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0,
|
||||
M_ItemCode: firstItem.M_ItemCode,
|
||||
M_ItemDesc: firstItem.M_ItemDesc,
|
||||
discount: firstItem.discount,
|
||||
discountType: firstItem.discountType,
|
||||
PoItemUnitID: firstItem.DefaultPurchase.ItemUnitID,
|
||||
ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode,
|
||||
PoItemUnitName: firstItem.DefaultPurchase.ItemUnitName,
|
||||
TotalPoQty: convertedPoQty,
|
||||
Price: price,
|
||||
RealPrice: realPrice,
|
||||
PriceAfterDiscount: price,
|
||||
Total: total,
|
||||
Details: items
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
export const groupPurchaseRequestsByItemId = async (purchaseRequestData, context) => {
|
||||
const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'PoItemUnitID']);
|
||||
console.log("grouped", grouped);
|
||||
|
||||
const results = await Promise.all(Object.keys(grouped).map(async (itemId) => {
|
||||
const items = grouped[itemId];
|
||||
const firstItem = items[0];
|
||||
|
||||
const convertedPoQty = calculateTotalQuantity(items, 'PoQty');
|
||||
console.log("Total PoQty for itemId", itemId, ":", convertedPoQty);
|
||||
|
||||
// Fetch the default supplier price based on the first item's M_ItemID and the converted quantity
|
||||
// penambahan multi harga di PO (untuk mendapatkan harga sesuai qty)
|
||||
const supplierPrice = await context.dispatch('getDefaultSupplierPrice', {
|
||||
itemID: firstItem.M_ItemID,
|
||||
qty: convertedPoQty
|
||||
});
|
||||
|
||||
if (supplierPrice == null) {
|
||||
let snackbar = {
|
||||
state: true,
|
||||
type: "warning",
|
||||
message: `Jumlah Quantity tidak tersedia di rentang harga supplier untuk item ${firstItem.M_ItemDesc}!`,
|
||||
};
|
||||
context.commit("update_snackbar", snackbar);
|
||||
context.commit("update_supplierPriceSave", supplierPrice);
|
||||
context.commit("update_itemDesc", firstItem.M_ItemDesc);
|
||||
} else {
|
||||
context.commit("update_supplierPriceSave", supplierPrice);
|
||||
context.commit("update_itemDesc", '');
|
||||
}
|
||||
|
||||
let price = 0;
|
||||
|
||||
if (parseFloat(firstItem.discount) > 0) {
|
||||
if (firstItem.discountType === 'P') {
|
||||
price = Number(supplierPrice?.SupplierPricePrice || 0) - (Number(firstItem.discount) * (Number(supplierPrice?.SupplierPricePrice || 0) / 100));
|
||||
} else if (firstItem.discountType === 'R') {
|
||||
price = Number(supplierPrice?.SupplierPricePrice || 0) - Number(firstItem.discount);
|
||||
}
|
||||
} else {
|
||||
price = Number(supplierPrice?.SupplierPricePrice || 0) || 0;
|
||||
}
|
||||
|
||||
const total = convertedPoQty * price;
|
||||
|
||||
const itemParts = itemId.split('_');
|
||||
const M_ItemID = itemParts[0];
|
||||
|
||||
return {
|
||||
keyID: itemId,
|
||||
M_ItemID: M_ItemID,
|
||||
PurchaseOrderID: firstItem.PurchaseOrderID ?? 0,
|
||||
PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0,
|
||||
M_ItemCode: firstItem.M_ItemCode,
|
||||
M_ItemDesc: firstItem.M_ItemDesc,
|
||||
discount: firstItem.discount,
|
||||
discountType: firstItem.discountType,
|
||||
PoItemUnitID: firstItem.DefaultPurchase.ItemUnitID,
|
||||
ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode,
|
||||
PoItemUnitName: firstItem.DefaultPurchase.ItemUnitName,
|
||||
TotalPoQty: convertedPoQty,
|
||||
Price: price,
|
||||
RealPrice: Number(supplierPrice?.SupplierPricePrice || 0),
|
||||
PriceAfterDiscount: price,
|
||||
Total: total,
|
||||
Details: items
|
||||
};
|
||||
}));
|
||||
|
||||
return results; // hasil sudah dalam bentuk array berisi semua item lengkap
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats a number as currency (IDR)
|
||||
* @param {Number} amount - The amount to format
|
||||
* @returns {String} - Formatted currency string
|
||||
*/
|
||||
export const formatCurrency = (amount) => {
|
||||
return new Intl.NumberFormat('id-ID', {
|
||||
style: 'currency',
|
||||
currency: 'IDR',
|
||||
minimumFractionDigits: 0
|
||||
}).format(amount);
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats a date to a localized string
|
||||
* @param {Date|String} date - The date to format
|
||||
* @param {Object} options - Intl.DateTimeFormat options
|
||||
* @returns {String} - Formatted date string
|
||||
*/
|
||||
export const formatDate = (date, options = {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
}) => {
|
||||
if (!date) return '';
|
||||
const dateObj = typeof date === 'string' ? new Date(date) : date;
|
||||
return new Intl.DateTimeFormat('id-ID', options).format(dateObj);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the total value of purchase requests
|
||||
* @param {Array} items - Array of purchase request items
|
||||
* @returns {Number} - Total value
|
||||
*/
|
||||
export const calculateTotal = (items) => {
|
||||
return items.reduce((sum, item) => sum + (Number(item.Total) || 0), 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the total quantity of items
|
||||
* @param {Array} items - Array of purchase request items
|
||||
* @param {String} qtyField - The field name containing quantity (e.g., 'PoQty')
|
||||
* @returns {Number} - Total quantity
|
||||
*/
|
||||
export const calculateTotalQuantity = (items, qtyField = 'PoQty') => {
|
||||
console.log("Items in calculateTotalQuantity:", items);
|
||||
return items.reduce((sum, item) => sum + (Number(item[qtyField]) || 0), 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts units based on the conversion factor
|
||||
* @param {Number} quantity - The quantity to convert
|
||||
* @param {Number} conversionFactor - The conversion factor
|
||||
* @returns {Number} - Converted quantity
|
||||
*/
|
||||
export const convertUnits = (quantity, conversionFactor) => {
|
||||
return quantity / conversionFactor;
|
||||
};
|
||||
|
||||
/**
|
||||
* Filters purchase requests by branch
|
||||
* @param {Array} items - Array of purchase request items
|
||||
* @param {String|Array} branchCodes - Branch code(s) to filter by
|
||||
* @returns {Array} - Filtered items
|
||||
*/
|
||||
export const filterByBranch = (items, branchCodes) => {
|
||||
if (!branchCodes) return items;
|
||||
|
||||
const codes = Array.isArray(branchCodes) ? branchCodes : [branchCodes];
|
||||
return items.filter(item => codes.includes(item.BranchCode));
|
||||
};
|
||||
|
||||
/**
|
||||
* Filters purchase requests by regional
|
||||
* @param {Array} items - Array of purchase request items
|
||||
* @param {String|Array} regionalIds - Regional ID(s) to filter by
|
||||
* @returns {Array} - Filtered items
|
||||
*/
|
||||
export const filterByRegional = (items, regionalIds) => {
|
||||
if (!regionalIds) return items;
|
||||
|
||||
const ids = Array.isArray(regionalIds) ? regionalIds : [regionalIds];
|
||||
return items.filter(item => ids.includes(item.S_RegionalID));
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates if a purchase request item has all required fields
|
||||
* @param {Object} item - Purchase request item
|
||||
* @returns {Boolean} - True if valid, false otherwise
|
||||
*/
|
||||
export const validatePurchaseRequestItem = (item) => {
|
||||
const requiredFields = [
|
||||
'M_ItemID',
|
||||
'M_ItemCode',
|
||||
'M_ItemDesc',
|
||||
'Price',
|
||||
'RequestQty'
|
||||
];
|
||||
|
||||
return requiredFields.every(field => item[field] !== undefined && item[field] !== null);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sorts purchase request items by a specified field
|
||||
* @param {Array} items - Array of purchase request items
|
||||
* @param {String} field - Field to sort by
|
||||
* @param {Boolean} ascending - Sort direction (true for ascending, false for descending)
|
||||
* @returns {Array} - Sorted items
|
||||
*/
|
||||
export const sortPurchaseRequests = (items, field = 'M_ItemDesc', ascending = true) => {
|
||||
return [...items].sort((a, b) => {
|
||||
const valueA = a[field];
|
||||
const valueB = b[field];
|
||||
|
||||
if (typeof valueA === 'string' && typeof valueB === 'string') {
|
||||
return ascending
|
||||
? valueA.localeCompare(valueB)
|
||||
: valueB.localeCompare(valueA);
|
||||
}
|
||||
|
||||
return ascending
|
||||
? (valueA - valueB)
|
||||
: (valueB - valueA);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates purchase order data before saving
|
||||
* @param {Object} context - Vuex context object
|
||||
* @returns {Boolean} - Returns true if validation passes, false otherwise
|
||||
*/
|
||||
export const validatePurchaseOrder = (context) => {
|
||||
if (context.state.loading) {
|
||||
let snackbar = {
|
||||
state: true,
|
||||
type: "warning",
|
||||
message: 'Loading sedang berlangsung harap menunggu ...',
|
||||
};
|
||||
context.commit("update_snackbar", snackbar);
|
||||
return false;
|
||||
}
|
||||
|
||||
let warningMsg = [];
|
||||
if (context.state.selectedItem.length == 0) {
|
||||
warningMsg.push('Belum memilih item');
|
||||
}
|
||||
if (!context.state.refNumber || context.state.refNumber.trim() === '') {
|
||||
warningMsg.push('Nomor Referensi belum diisi');
|
||||
}
|
||||
if (!context.state.selectedWarehouse || !context.state.selectedWarehouse.WarehouseID && context.state.warehouseType !== 'Multiple') {
|
||||
warningMsg.push('Tipe Gudang Single Harus memilih Gudang');
|
||||
}
|
||||
if (!context.state.selectedSupplier || !context.state.selectedSupplier.SupplierID) {
|
||||
warningMsg.push('Supplier belum dipilih');
|
||||
}
|
||||
if (context.state.discountType === 'Percentage') {
|
||||
const discountValue = (context.state.itemTotal.total * context.state.discountAmount) / 100;
|
||||
if (discountValue > context.state.itemTotal.total) {
|
||||
warningMsg.push('Diskon tidak boleh melebihi total');
|
||||
}
|
||||
} else if (context.state.discountType === 'Absolute') {
|
||||
if (context.state.discountAmount > context.state.itemTotal.total) {
|
||||
warningMsg.push('Diskon tidak boleh melebihi total');
|
||||
}
|
||||
}
|
||||
|
||||
context.state.summary.forEach(element => {
|
||||
if (Number(element.discount) < 0) {
|
||||
warningMsg.push('Diskon ' + element.M_ItemDesc + ' tidak boleh kurang dari 0');
|
||||
}
|
||||
if (element.discountType === 'P') {
|
||||
if (Number(element.discount) > 100) {
|
||||
warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi 100');
|
||||
}
|
||||
}
|
||||
if (element.discountType === 'R') {
|
||||
if (Number(element.discount) > Number(element.RealPrice)) {
|
||||
warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi dari harga');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (warningMsg.length > 0) {
|
||||
let snackbar = {
|
||||
state: true,
|
||||
type: "warning",
|
||||
message: warningMsg.join(", "),
|
||||
};
|
||||
context.commit("update_snackbar", snackbar);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Menghitung total summary untuk purchase order
|
||||
* @param {Array} summary - Array data summary
|
||||
* @param {Number} taxPpn - Persentase pajak PPN
|
||||
* @param {Number} taxPph - Persentase pajak PPH
|
||||
* @param {String} discountType - Tipe diskon ('Percentage' atau 'Absolute')
|
||||
* @param {Number} discountAmount - Jumlah diskon
|
||||
* @returns {Object} - Object summaryTotal
|
||||
*/
|
||||
export const calculateSummaryTotal = (summary, taxPpn = 0, taxPph = 0, discountType = 'Percentage', discountAmount = 0) => {
|
||||
if (!summary || summary.length === 0) {
|
||||
return {
|
||||
total: 0,
|
||||
tax: 0,
|
||||
ppn: 0,
|
||||
pph: 0,
|
||||
discount: 0,
|
||||
finalTotal: 0,
|
||||
};
|
||||
}
|
||||
|
||||
// Hitung total dari item summary
|
||||
const total = summary.reduce((acc, item) => acc + (Number(item.Total) || 0), 0);
|
||||
|
||||
// Hitung diskon berdasarkan tipe
|
||||
let discount = discountAmount;
|
||||
if (discountType === 'Percentage') {
|
||||
discount = (discountAmount / 100) * total;
|
||||
}
|
||||
|
||||
// Hitung pajak
|
||||
const newTotal = total - discount;
|
||||
const ppn = (taxPpn / 100) * newTotal;
|
||||
const pph = (taxPph / 100) * newTotal;
|
||||
const tax = ppn + pph;
|
||||
const finalTotal = newTotal + tax;
|
||||
|
||||
// Return object summaryTotal
|
||||
return {
|
||||
total: total,
|
||||
tax: tax,
|
||||
ppn: ppn,
|
||||
pph: pph,
|
||||
discount: discount,
|
||||
finalTotal: finalTotal,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Menghapus item dari summary dan selectedItem berdasarkan itemId atau detailId
|
||||
* @param {Array} summary - Array data summary
|
||||
* @param {Array} selectedItem - Array data selectedItem
|
||||
* @param {String} itemId - ID item yang akan dihapus (opsional)
|
||||
* @param {String} detailId - ID detail yang akan dihapus (opsional)
|
||||
* @returns {Object} - Object berisi summary dan selectedItem yang sudah diupdate
|
||||
*/
|
||||
export const deleteItemFromSummary = (summary, selectedItem, itemId = null, detailId = null) => {
|
||||
// Jika itemId ada, hapus seluruh item dan detailsnya
|
||||
if (itemId) {
|
||||
const newSummary = summary.filter(item => item.M_ItemID !== itemId);
|
||||
const newSelectedItem = selectedItem.filter(item => item.M_ItemID !== itemId);
|
||||
|
||||
return {
|
||||
summary: newSummary,
|
||||
selectedItem: newSelectedItem
|
||||
};
|
||||
}
|
||||
|
||||
// Jika detailId ada, hapus detail spesifik
|
||||
if (detailId) {
|
||||
// Hapus dari selectedItem
|
||||
const newSelectedItem = selectedItem.filter(item => item.PurchaseRequestFlagID !== detailId);
|
||||
|
||||
// Regenerate summary dari selectedItem yang baru
|
||||
const newSummary = groupPurchaseRequestsByItemId(newSelectedItem);
|
||||
|
||||
return {
|
||||
summary: newSummary,
|
||||
selectedItem: newSelectedItem
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
summary,
|
||||
selectedItem
|
||||
};
|
||||
};
|
||||
69
test/vuex/acc-one-approve-po/index.php
Normal file
69
test/vuex/acc-one-approve-po/index.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/google-fonts.css">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/icomoon-fonts.css">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/vuetify.min.css">
|
||||
<title>One</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div v-cloak id="app">
|
||||
<v-app id="smartApp">
|
||||
<one-navbar></one-navbar>
|
||||
<v-content style="background: #F5E8DF!important">
|
||||
<v-container fluid fill-height class="pl-1 pr-1 pt-2 pb-2">
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 class="left" fill-height pa-1>
|
||||
<po></po>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-container>
|
||||
</v-content>
|
||||
<one-footer></one-footer>
|
||||
</v-app>
|
||||
</div>
|
||||
|
||||
<!-- Vendor -->
|
||||
<script src="../../../libs/vendor/moment.min.js"></script>
|
||||
<script src="../../../libs/vendor/numeral.min.js"></script>
|
||||
<script src="../../../libs/vendor/moment-locale-id.js"></script>
|
||||
<script src="../../../libs/vendor/lodash.js"></script>
|
||||
<script src="../../../libs/vendor/axios.min.js"></script>
|
||||
<script src="../../../libs/vendor/vue.js"></script>
|
||||
<script src="../../../libs/vendor/vuex.js"></script>
|
||||
<script src="../../../libs/vendor/vuetify.js"></script>
|
||||
<script src="../../../libs/vendor/httpVueLoader.js"></script>
|
||||
<script src="../../../libs/one_global.js"></script>
|
||||
|
||||
<!-- App Script -->
|
||||
<script type="module">
|
||||
import {
|
||||
store
|
||||
} from './store.js';
|
||||
window.store = store;
|
||||
new Vue({
|
||||
store,
|
||||
el: "#app",
|
||||
methods: {},
|
||||
components: {
|
||||
'one-navbar': httpVueLoader('../../../apps/components/oneNavbarComponent.vue'),
|
||||
'one-footer': httpVueLoader('../../../apps/components/oneFooter.vue'),
|
||||
// 'request-listing': httpVueLoader('./components/requestListing.vue'),
|
||||
// 'request-kacab': httpVueLoader('./components/acconeprkacab.vue'),
|
||||
'po': httpVueLoader('./components/po.vue')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
1439
test/vuex/acc-one-approve-po/modules/po.js
Normal file
1439
test/vuex/acc-one-approve-po/modules/po.js
Normal file
File diff suppressed because it is too large
Load Diff
14
test/vuex/acc-one-approve-po/store.js
Normal file
14
test/vuex/acc-one-approve-po/store.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// import manager from "./modules/manager.js";
|
||||
// import prkacab from "./modules/prkacab.js"
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
import po from "./modules/po.js";
|
||||
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
po: po,
|
||||
system: system
|
||||
},
|
||||
state: {},
|
||||
mutations: {},
|
||||
actions: {},
|
||||
});
|
||||
Reference in New Issue
Block a user