first commit + add fe component vue accone
This commit is contained in:
355
test/vuex/acc-one-faktur-v4/module/data.js
Normal file
355
test/vuex/acc-one-faktur-v4/module/data.js
Normal file
@@ -0,0 +1,355 @@
|
||||
import * as api from "../api/data.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
snack: {
|
||||
isOpen: false,
|
||||
color: "success",
|
||||
message: ""
|
||||
},
|
||||
list_staff: {
|
||||
records: [],
|
||||
total: 0
|
||||
},
|
||||
list_po: {
|
||||
records: [],
|
||||
total: 0
|
||||
},
|
||||
list_supplier: {
|
||||
records: [],
|
||||
total: 0
|
||||
},
|
||||
list_ro: {
|
||||
records: [],
|
||||
total: 0
|
||||
},
|
||||
list_item: {
|
||||
records: [],
|
||||
total: 0
|
||||
},
|
||||
selected_item: [],
|
||||
page_item: 1,
|
||||
search_item: "",
|
||||
|
||||
page_list: 1,
|
||||
list_faktur: {
|
||||
records: [],
|
||||
total: 0
|
||||
},
|
||||
filter: {
|
||||
date: moment(new Date()).format("YYYY-MM-DD"),
|
||||
enddate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
supplier: "0",
|
||||
status: "All",
|
||||
nomor: ""
|
||||
},
|
||||
viewfaktur: false,
|
||||
|
||||
dialog_attachment: false,
|
||||
preview_attachment: []
|
||||
},
|
||||
mutations: {
|
||||
update_snack(state, data) {
|
||||
state.snack = data
|
||||
},
|
||||
update_list_staff(state, data) {
|
||||
state.list_staff = data
|
||||
},
|
||||
update_list_po(state, data) {
|
||||
state.list_po = data
|
||||
},
|
||||
update_list_supplier(state, data) {
|
||||
state.list_supplier = data
|
||||
},
|
||||
update_list_ro(state, data) {
|
||||
state.list_ro = data
|
||||
},
|
||||
update_list_item(state, data) {
|
||||
state.list_item = data
|
||||
},
|
||||
update_selected_item(state, data) {
|
||||
state.selected_item = data
|
||||
},
|
||||
update_page_item(state, data) {
|
||||
state.page_item = data
|
||||
},
|
||||
update_search_item(state, data) {
|
||||
state.search_item = data
|
||||
},
|
||||
update_page_list(state, data) {
|
||||
state.page_list = data
|
||||
},
|
||||
update_list_faktur(state, data) {
|
||||
state.list_faktur = data
|
||||
},
|
||||
update_filter(state, data) {
|
||||
state.filter = data
|
||||
},
|
||||
update_viewfaktur(state, data) {
|
||||
state.viewfaktur = data
|
||||
},
|
||||
update_dialog_attachment(state, data) {
|
||||
state.dialog_attachment = data
|
||||
},
|
||||
update_preview_attachment(state, data) {
|
||||
state.preview_attachment = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async getListPO(context) {
|
||||
try {
|
||||
let supid = context.rootState.form.form_faktur.form_supplier.SupplierID
|
||||
let payload = {
|
||||
token: one_token(),
|
||||
supID: supid
|
||||
}
|
||||
|
||||
let response = await api.LookupPO(payload)
|
||||
if (response.status != "OK") {
|
||||
|
||||
} else {
|
||||
let po = response.data
|
||||
context.commit("update_list_po", po)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
},
|
||||
async getListSupplier(context) {
|
||||
try {
|
||||
let payload = {
|
||||
token: one_token(),
|
||||
name: ""
|
||||
}
|
||||
|
||||
let response = await api.LookupSupplier(payload)
|
||||
if (response.status != "OK") {
|
||||
let snacc = {isOpen: true, message: response.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
} else {
|
||||
let sup = response.data
|
||||
context.commit("update_list_supplier", sup)
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
}
|
||||
},
|
||||
async getListStaff(context) {
|
||||
try {
|
||||
let payload = {
|
||||
token: one_token(),
|
||||
name: ""
|
||||
}
|
||||
|
||||
let response = await api.LookupStaff(payload)
|
||||
if (response.status != "OK") {
|
||||
let snacc = {isOpen: true, message: response.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
} else {
|
||||
let staff = response.data
|
||||
context.commit("update_list_staff", staff)
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
}
|
||||
},
|
||||
async getDetailPO(context) {
|
||||
try {
|
||||
let supid = context.rootState.form.form_faktur.form_supplier.SupplierID
|
||||
let numpo = context.rootState.form.form_faktur.form_po.ReceiveOrderPoNumber
|
||||
let payload = {
|
||||
token: one_token(),
|
||||
supID: supid,
|
||||
numPO: numpo,
|
||||
}
|
||||
|
||||
let response = await api.LookupDetailPO(payload)
|
||||
if (response.status != "OK") {
|
||||
let snacc = {isOpen: true, message: response.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
} else {
|
||||
let po = response.data.records
|
||||
let form = context.rootState.form.form_faktur
|
||||
|
||||
let duedate = moment(po.PurchaseOrderDate).add(Number(po.PurchaseOrderPaymentTerm), 'days').format("YYYY-MM-DD")
|
||||
|
||||
form.form_duedate = duedate
|
||||
form.form_refnumber = po.PurchaseOrderRefNumber
|
||||
form.form_tax_percent_pph = po.PurchaseOrderTaxPercentPph
|
||||
form.form_tax_percent_ppn = po.PurchaseOrderTaxPercentPpn
|
||||
form.form_disc_po = po.DiscountType == 'R' ? po.SupplierInvoiceDiscountAmount : po.SupplierInvoiceDiscountPercent
|
||||
form.form_disc_type = po.DiscountType
|
||||
form.form_shipping_cost = po.PurchaseOrderShippingCost
|
||||
|
||||
|
||||
context.commit("form/update_form_faktur", form, {root: true})
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
}
|
||||
},
|
||||
async getListRO(context) {
|
||||
try {
|
||||
let poID = context.rootState.form.form_faktur.form_po.PurchaseOrderID
|
||||
let supID = context.rootState.form.form_faktur.form_supplier.SupplierID
|
||||
|
||||
let payload = {
|
||||
token: one_token(),
|
||||
poID: poID,
|
||||
supplierID: supID
|
||||
}
|
||||
|
||||
var resp = await api.LookupRO(payload)
|
||||
if (resp.status != "OK") {
|
||||
let snacc = {isOpen: true, message: resp.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
} else {
|
||||
context.commit("update_list_ro", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
}
|
||||
},
|
||||
async getListItemRO(context) {
|
||||
try {
|
||||
let payload = {
|
||||
token: one_token(),
|
||||
poID: context.rootState.form.form_faktur.form_po.PurchaseOrderID,
|
||||
roID: context.rootState.form.form_ro.ReceiveOrderPoID,
|
||||
name: context.state.search_item,
|
||||
currpage: context.state.page_item,
|
||||
}
|
||||
|
||||
let resp = await api.LookupItemRO(payload)
|
||||
if (resp.status != "OK") {
|
||||
let snacc = {isOpen: true, message: resp.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
} else {
|
||||
context.commit("update_list_item", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
}
|
||||
},
|
||||
async getListFaktur(context) {
|
||||
try {
|
||||
let payload = {
|
||||
token: one_token(),
|
||||
page: context.state.page_list,
|
||||
nomor: context.state.filter.nomor,
|
||||
status: context.state.filter.status,
|
||||
enddate: context.state.filter.enddate,
|
||||
date: context.state.filter.date,
|
||||
supplier: context.state.filter.supplier
|
||||
}
|
||||
|
||||
let resp = await api.LookupFaktur(payload)
|
||||
if (resp.status != "OK") {
|
||||
let snacc = {isOpen: true, message: resp.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
} else {
|
||||
context.commit("update_list_faktur", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
}
|
||||
},
|
||||
async getDetailFaktur(context, params) {
|
||||
try {
|
||||
params.token = one_token()
|
||||
let resp = await api.LookupFakturDetail(params)
|
||||
if (resp.status != 'OK') {
|
||||
let snacc = {isOpen: true, message: resp.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc)
|
||||
} else {
|
||||
let temp = resp.data
|
||||
let faktur = context.rootState.form.form_faktur
|
||||
faktur.form_date = temp.SupplierInvoiceDate
|
||||
faktur.form_duedate = temp.SupplierInvoiceDueDate
|
||||
faktur.form_draftdate = temp.SupplierInvoiceDraftPaymentDate
|
||||
faktur.form_supplier = {
|
||||
SupplierCode: temp.SupplierCode,
|
||||
SupplierName: temp.SupplierName,
|
||||
SupplierID: temp.SupplierInvoiceSupplierID
|
||||
}
|
||||
faktur.form_po = {
|
||||
PurchaseOrderID: temp.SupplierInvoicePurchaseOrderID,
|
||||
PurchaseOrderDate: temp.PurchaseOrderDate,
|
||||
ReceiveOrderPoID: temp.SupplierInvoiceReceiveOrderPoID,
|
||||
ReceiveOrderPoNumber: temp.ReceiveOrderPoNumber
|
||||
}
|
||||
let po = faktur.form_po
|
||||
console.log(po)
|
||||
context.commit("update_list_po", po)
|
||||
faktur.form_refnumber = temp.SupplierInvoiceRefNumber
|
||||
faktur.form_supplier_invoicenum = temp.SupplierInvoiceSupplierInvoiceNumber
|
||||
faktur.form_supplier_invoicedate = temp.SupplierInvoiceSupplierInvoiceDate
|
||||
faktur.form_tax_percent_pph = temp.SupplierInvoiceTaxPercentPph
|
||||
faktur.form_tax_percent_ppn = temp.SupplierInvoiceTaxPercentPpn
|
||||
faktur.form_disc_po = temp.DiscountType == 'R' ? temp.SupplierInvoiceDiscountAmount : temp.SupplierInvoiceDiscountPercent
|
||||
faktur.form_disc_type = temp.DiscountType
|
||||
faktur.form_note = temp.SupplierInvoiceNote
|
||||
faktur.form_adjust_amount = temp.SupplierInvoiceAdjustmentAmount
|
||||
faktur.form_adjust_note = temp.SupplierInvoiceAdjustmentNote
|
||||
faktur.form_shipping_cost = temp.SupplierInvoiceShippingCost
|
||||
faktur.fakturID = temp.SupplierInvoiceID
|
||||
|
||||
context.commit("form/update_form_faktur", faktur, {root: true})
|
||||
|
||||
let detail = resp.data.detail
|
||||
let mapitem = []
|
||||
detail.forEach(item => {
|
||||
let a = {
|
||||
"PurchaseOrderNumber": item.PurchaseOrderNumber,
|
||||
"ReceiveOrderPoDetailPurchaseOrderID": item.SupplierInvoiceDetailPurchaseOrderID,
|
||||
"ReceiveOrderPoDetailPurchaseOrderSummaryID": item.SupplierInvoiceDetailPurchaseOrderSummaryID,
|
||||
"ReceiveOrderPoDetailReceiveOrderPoID": item.SupplierInvoiceDetailReceiveOrderPoID,
|
||||
"ReceiveOrderPoDetailID": item.SupplierInvoiceDetailReceiveOrderPoDetailID,
|
||||
"M_ItemID": item.SupplierInvoiceDetailItemID,
|
||||
"M_ItemCode": item.M_ItemCode,
|
||||
"M_ItemDesc": item.M_ItemDesc,
|
||||
"ReceiveOrderPoItemUnitID": item.SupplierInvoiceDetailItemUnitID,
|
||||
"ReceiveOrderPoDetailQty": item.SupplierInvoiceDetailQty,
|
||||
"ReceiveOrderPoDetailPrice": item.SupplierInvoiceDetailPrice,
|
||||
"Discount": item.SupplierInvoiceDetailDiscountDiscountType == 'P' ? item.SupplierInvoiceDetailDiscountPercent: item.SupplierInvoiceDetailDiscountDiscountRupiah,
|
||||
"PurchaseOrderSummaryDiscountType": item.SupplierInvoiceDetailDiscountDiscountType,
|
||||
"ReceiveOrderPoDetailDiskonPoProrata": item.SupplierInvoiceDetailDiscountPoProrata,
|
||||
"disc_amount": item.SupplierInvoiceDetailDiscountAmount,
|
||||
"subtotal": item.SupplierInvoiceDetailTotal
|
||||
}
|
||||
|
||||
mapitem.push(a)
|
||||
});
|
||||
|
||||
context.commit("form/update_form_item", mapitem, {root: true})
|
||||
//context.dispatch("getListPO");
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
}
|
||||
},
|
||||
async getListAttachment(context, param) {
|
||||
try {
|
||||
param.token = one_token()
|
||||
|
||||
const resp = await api.LookupAttachment(param)
|
||||
if (resp.status != 'OK') {
|
||||
throw new Error(resp.message);
|
||||
}
|
||||
|
||||
context.commit('update_preview_attachment', resp.data)
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("update_snack", snacc)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
345
test/vuex/acc-one-faktur-v4/module/form.js
Normal file
345
test/vuex/acc-one-faktur-v4/module/form.js
Normal file
@@ -0,0 +1,345 @@
|
||||
import * as api from "../api/form.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
opendialog: false,
|
||||
user: one_user(),
|
||||
form_faktur: {
|
||||
form_date: moment(new Date()).format("YYYY-MM-DD"),
|
||||
form_duedate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
form_draftdate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
form_supplier: {},
|
||||
form_po: {},
|
||||
form_refnumber: "",
|
||||
form_supplier_invoicenum: "",
|
||||
form_supplier_invoicedate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
form_tax_percent_pph: 0.00,
|
||||
form_tax_amount_pph: 0.00,
|
||||
form_tax_percent_ppn: 0.00,
|
||||
form_tax_amount_ppn: 0.00,
|
||||
form_disc_po: 0.00,
|
||||
form_disc_amount: 0.00,
|
||||
form_disc_type: "",
|
||||
form_subtotal: 0.00,
|
||||
form_grandtotal: 0.00,
|
||||
form_note: "",
|
||||
form_adjust_amount: 0.00,
|
||||
form_adjust_note: "",
|
||||
form_shipping_cost: 0.00,
|
||||
},
|
||||
|
||||
// form tambah item
|
||||
dialog_item: false,
|
||||
form_ro: {},
|
||||
form_item: [],
|
||||
is_create: false,
|
||||
},
|
||||
mutations: {
|
||||
update_opendialog(state, data) {
|
||||
state.opendialog = data
|
||||
},
|
||||
update_form_faktur(state, data) {
|
||||
state.form_faktur = data
|
||||
},
|
||||
update_form_ro(state, data) {
|
||||
state.form_ro = data
|
||||
},
|
||||
update_form_item(state, data) {
|
||||
state.form_item = data
|
||||
},
|
||||
update_dialog_item(state, data) {
|
||||
state.dialog_item = data
|
||||
},
|
||||
update_is_create(state, data) {
|
||||
state.is_create = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
resetForm(context) {
|
||||
const form_faktur = {
|
||||
form_date: moment(new Date()).format("YYYY-MM-DD"),
|
||||
form_duedate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
form_draftdate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
form_supplier: {},
|
||||
form_po: {},
|
||||
form_refnumber: "",
|
||||
form_supplier_invoicenum: "",
|
||||
form_supplier_invoicedate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
form_tax_percent_pph: 0.00,
|
||||
form_tax_amount_pph: 0.00,
|
||||
form_tax_percent_ppn: 0.00,
|
||||
form_tax_amount_ppn: 0.00,
|
||||
form_disc_po: 0.00,
|
||||
form_disc_amount: 0.00,
|
||||
form_disc_type: "R",
|
||||
form_subtotal: 0.00,
|
||||
form_grandtotal: 0.00,
|
||||
form_note: "",
|
||||
form_adjust_amount: 0.00,
|
||||
form_adjust_note: "",
|
||||
form_shipping_cost: 0.00,
|
||||
}
|
||||
context.commit("update_form_faktur", form_faktur)
|
||||
context.commit("update_form_ro", {})
|
||||
context.commit("update_form_item", [])
|
||||
context.commit("data/update_list_po", {records: [], total: 0}, {root: true})
|
||||
},
|
||||
async calcSummary(context) {
|
||||
try {
|
||||
let item = context.state.form_item
|
||||
let faktur = context.state.form_faktur
|
||||
if (item.length > 0) {
|
||||
let sub = 0
|
||||
let podisc = 0
|
||||
item.forEach(ite => {
|
||||
let price = Number(ite.ReceiveOrderPoDetailPrice)
|
||||
let disc = Number(ite.Discount)
|
||||
let qty = Number(ite.ReceiveOrderPoDetailQty)
|
||||
|
||||
if (ite.PurchaseOrderSummaryDiscountType == 'P') {
|
||||
disc = (price * Number(ite.Discount)) / 100
|
||||
}
|
||||
|
||||
sub = sub + (qty * (price - disc))
|
||||
podisc = podisc + Number(ite.ReceiveOrderPoDetailDiskonPoProrata)
|
||||
});
|
||||
|
||||
let pph = (sub - podisc) * (Number(faktur.form_tax_percent_pph) / 100)
|
||||
let ppn = (sub - podisc) * (Number(faktur.form_tax_percent_ppn) / 100)
|
||||
let grandtotal = (sub - podisc + pph + ppn) + Number(faktur.form_adjust_amount) + Number(faktur.form_shipping_cost)
|
||||
|
||||
// Store exact values with 2 decimal places using floor instead of rounding
|
||||
// This prevents rounding errors in financial calculations
|
||||
faktur.form_subtotal = sub
|
||||
faktur.form_disc_amount = podisc
|
||||
faktur.form_tax_amount_ppn = ppn
|
||||
faktur.form_tax_amount_pph = pph
|
||||
faktur.form_grandtotal = grandtotal
|
||||
} else {
|
||||
faktur.form_subtotal = 0.00
|
||||
faktur.form_disc_amount = 0.00
|
||||
faktur.form_grandtotal = 0.00
|
||||
faktur.form_tax_amount_pph = 0.00
|
||||
faktur.form_tax_amount_ppn = 0.00
|
||||
faktur.form_adjust_amount = 0.00
|
||||
faktur.form_adjust_note = ""
|
||||
}
|
||||
|
||||
context.commit("update_form_faktur", faktur)
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
}
|
||||
},
|
||||
async createFaktur(context) {
|
||||
try {
|
||||
let item = context.state.form_item
|
||||
let para_item = []
|
||||
|
||||
let param = {
|
||||
SIPoID: context.state.form_faktur.form_po.PurchaseOrderID,
|
||||
SIDate: context.state.form_faktur.form_date,
|
||||
SIDueDate: context.state.form_faktur.form_duedate,
|
||||
SIDraftDate: context.state.form_faktur.form_draftdate,
|
||||
SISupplierID: context.state.form_faktur.form_supplier.SupplierID,
|
||||
SIRefNumber: context.state.form_faktur.form_refnumber,
|
||||
SISupplierInvoiceNumber: context.state.form_faktur.form_supplier_invoicenum,
|
||||
SISupplierInvoiceDate: context.state.form_faktur.form_supplier_invoicedate,
|
||||
SISubTotal: context.state.form_faktur.form_subtotal,
|
||||
SIDiscountPercent: context.state.form_faktur.form_disc_type == 'P' ? context.state.form_faktur.form_disc_po : 0,
|
||||
SIDiscountAmount: context.state.form_faktur.form_disc_amount,
|
||||
SITaxPercentPph: context.state.form_faktur.form_tax_percent_pph,
|
||||
SITaxAmountPph: context.state.form_faktur.form_tax_amount_pph,
|
||||
SITaxPercentPpn: context.state.form_faktur.form_tax_percent_ppn,
|
||||
SITaxAmountPpn: context.state.form_faktur.form_tax_amount_ppn,
|
||||
SIShippingCost: context.state.form_faktur.form_shipping_cost,
|
||||
SIAdjustmentAmount: context.state.form_faktur.form_adjust_amount,
|
||||
SIAdjustmentNote: context.state.form_faktur.form_adjust_note,
|
||||
SIGrandTotal: context.state.form_faktur.form_grandtotal,
|
||||
SINote: context.state.form_faktur.form_note,
|
||||
SIReceiveDate: moment(new Date()).format("YYYY-MM-DD"),
|
||||
SIReceivedBy: context.state.user.M_UserID,
|
||||
SIStatus: 'Draft',
|
||||
SIDetail: [],
|
||||
token: one_token()
|
||||
}
|
||||
|
||||
item.forEach(ele => {
|
||||
let a = {
|
||||
SIDPOID: ele.ReceiveOrderPoDetailPurchaseOrderID,
|
||||
SIDPOSummaryID: ele.ReceiveOrderPoDetailPurchaseOrderSummaryID,
|
||||
SIDROID: ele.ReceiveOrderPoDetailReceiveOrderPoID,
|
||||
SIDRODetailID: ele.ReceiveOrderPoDetailID,
|
||||
SIDItemID: ele.M_ItemID,
|
||||
SIDItemUnitID: ele.ReceiveOrderPoItemUnitID,
|
||||
SIDDescription: ele.M_ItemDesc,
|
||||
SIDQty: ele.ReceiveOrderPoDetailQty,
|
||||
SIDPrice: ele.ReceiveOrderPoDetailPrice,
|
||||
SIDDiscountPercent: ele.PurchaseOrderSummaryDiscountType == 'P' ? ele.Discount: 0,
|
||||
SIDDiscountRupiah: ele.PurchaseOrderSummaryDiscountType == 'R' ? ele.Discount: 0,
|
||||
SIDDiscountType: ele.PurchaseOrderSummaryDiscountType,
|
||||
SIDDiscountAmount: ele.disc_amount,
|
||||
SIDDiscountPOProrata: ele.ReceiveOrderPoDetailDiskonPoProrata,
|
||||
SIDTotal: ele.subtotal
|
||||
}
|
||||
para_item.push(a)
|
||||
});
|
||||
|
||||
param.SIDetail = para_item
|
||||
|
||||
let resp = await api.CreateFaktur(param)
|
||||
if (resp.status != 'OK') {
|
||||
let snacc = {isOpen: true, message: resp.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
} else {
|
||||
let snacc = {isOpen: true, message: 'Success', color: "success"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
context.dispatch("data/getListFaktur", {}, {root: true})
|
||||
context.commit("update_opendialog", false)
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
}
|
||||
},
|
||||
async updateFaktur(context) {
|
||||
try {
|
||||
let faktur = context.state.form_faktur
|
||||
let param = {
|
||||
SIPoID: faktur.form_po.PurchaseOrderID,
|
||||
SIDate: faktur.form_date,
|
||||
SIDueDate: faktur.form_duedate,
|
||||
SIDraftDate: faktur.form_draftdate,
|
||||
SISupplierID: faktur.form_supplier.SupplierID,
|
||||
SIRefNumber: faktur.form_refnumber,
|
||||
SISupplierInvoiceNumber: faktur.form_supplier_invoicenum,
|
||||
SISupplierInvoiceDate: faktur.form_supplier_invoicedate,
|
||||
SISubTotal: faktur.form_subtotal,
|
||||
SIDiscountPercent: faktur.form_disc_type == 'P' ? faktur.form_disc_po : 0,
|
||||
SIDiscountAmount: faktur.form_disc_amount,
|
||||
SITaxPercentPph: faktur.form_tax_percent_pph,
|
||||
SITaxAmountPph: faktur.form_tax_amount_pph,
|
||||
SITaxPercentPpn: faktur.form_tax_percent_ppn,
|
||||
SITaxAmountPpn: faktur.form_tax_amount_ppn,
|
||||
SIShippingCost: faktur.form_shipping_cost,
|
||||
SIAdjustmentAmount: faktur.form_adjust_amount,
|
||||
SIAdjustmentNote: faktur.form_adjust_note,
|
||||
SIGrandTotal: faktur.form_grandtotal,
|
||||
SINote: faktur.form_note,
|
||||
SIStatus: 'Draft',
|
||||
SIDetail: [],
|
||||
fakturID: faktur.fakturID,
|
||||
token: one_token()
|
||||
}
|
||||
|
||||
let item = context.state.form_item
|
||||
let detail = []
|
||||
item.forEach(ele => {
|
||||
let a = {
|
||||
SIDPOID: ele.ReceiveOrderPoDetailPurchaseOrderID,
|
||||
SIDPOSummaryID: ele.ReceiveOrderPoDetailPurchaseOrderSummaryID,
|
||||
SIDROID: ele.ReceiveOrderPoDetailReceiveOrderPoID,
|
||||
SIDRODetailID: ele.ReceiveOrderPoDetailID,
|
||||
SIDItemID: ele.M_ItemID,
|
||||
SIDItemUnitID: ele.ReceiveOrderPoItemUnitID,
|
||||
SIDDescription: ele.M_ItemDesc,
|
||||
SIDQty: ele.ReceiveOrderPoDetailQty,
|
||||
SIDPrice: ele.ReceiveOrderPoDetailPrice,
|
||||
SIDDiscountPercent: ele.PurchaseOrderSummaryDiscountType == 'P' ? ele.Discount: 0,
|
||||
SIDDiscountRupiah: ele.PurchaseOrderSummaryDiscountType == 'R' ? ele.Discount: 0,
|
||||
SIDDiscountType: ele.PurchaseOrderSummaryDiscountType,
|
||||
SIDDiscountAmount: ele.disc_amount,
|
||||
SIDDiscountPOProrata: ele.ReceiveOrderPoDetailDiskonPoProrata,
|
||||
SIDTotal: ele.subtotal
|
||||
}
|
||||
detail.push(a)
|
||||
})
|
||||
param.SIDetail = detail
|
||||
// console.log('param update', param)
|
||||
|
||||
let resp = await api.UpdateFaktur(param)
|
||||
if (resp.status != 'OK') {
|
||||
let snacc = {isOpen: true, message: resp.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
} else {
|
||||
let snacc = {isOpen: true, message: 'Success', color: "success"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
context.dispatch("data/getListFaktur", {}, {root: true})
|
||||
context.commit("update_opendialog", false)
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
}
|
||||
},
|
||||
async deleteFaktur(context, params) {
|
||||
try {
|
||||
params.token = one_token()
|
||||
let resp = await api.DeleteFaktur(params)
|
||||
if (resp.status != 'OK') {
|
||||
let snacc = {isOpen: true, message: resp.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
} else {
|
||||
let snacc = {isOpen: true, message: 'Success', color: "success"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
context.dispatch("data/getListFaktur", {}, {root: true})
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
}
|
||||
},
|
||||
async approveFaktur(context, param) {
|
||||
try {
|
||||
param.token = one_token()
|
||||
let resp = await api.ApproveFaktur(param)
|
||||
if (resp.status != 'OK') {
|
||||
let snacc = {isOpen: true, message: resp.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
} else {
|
||||
let snacc = {isOpen: true, message: 'Success', color: "success"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
context.dispatch("data/getListFaktur", {}, {root: true})
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
}
|
||||
},
|
||||
async rejectFaktur(context, param) {
|
||||
try {
|
||||
param.token = one_token()
|
||||
let resp = await api.RejectFaktur(param)
|
||||
if (resp.status != 'OK') {
|
||||
let snacc = {isOpen: true, message: resp.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
} else {
|
||||
let snacc = {isOpen: true, message: 'Success', color: "success"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
context.dispatch("data/getListFaktur", {}, {root: true})
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
}
|
||||
},
|
||||
async verifyFaktur(context, param) {
|
||||
try {
|
||||
param.token = one_token()
|
||||
let resp = await api.VerifyFaktur(param)
|
||||
if (resp.status != 'OK') {
|
||||
let snacc = {isOpen: true, message: resp.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
} else {
|
||||
let snacc = {isOpen: true, message: 'Success', color: "success"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
context.dispatch("data/getListFaktur", {}, {root: true})
|
||||
}
|
||||
} catch (error) {
|
||||
let snacc = {isOpen: true, message: error.message, color: "error"}
|
||||
context.commit("data/update_snack", snacc, {root: true})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user