update koneksi DB
This commit is contained in:
@@ -135,7 +135,9 @@
|
||||
'"><i class="bi bi-truck"></i> Buat Surat Jalan</button>';
|
||||
if (p.export)
|
||||
html +=
|
||||
'<button class="btn btn-sm btn-outline-danger open-invoice-pdf" data-url="' +
|
||||
'<button class="btn btn-sm btn-outline-danger open-invoice-pdf" data-id="' +
|
||||
row.id +
|
||||
'" data-url="' +
|
||||
cfg.base +
|
||||
"invoices/pdf/" +
|
||||
row.id +
|
||||
@@ -230,6 +232,7 @@
|
||||
render: function (d,t,r) {
|
||||
if(r.invoice_purpose==="loan")return "Tagihan Pinjaman";
|
||||
if(r.invoice_purpose==="savings")return "Tagihan Tabungan";
|
||||
if(r.invoice_purpose==="mixed")return "Penjualan + Tabungan";
|
||||
return esc(
|
||||
r.recognition_policy === "accrual"
|
||||
? "Diakui saat Posted"
|
||||
@@ -456,7 +459,7 @@
|
||||
$(".invoice-batch-common").toggleClass("d-none", savings);
|
||||
$("#nonInventoryDescriptionLabel").html(savings ? 'Deskripsi <span class="text-danger">*</span>' : 'Nama Jasa / Deskripsi <span class="text-danger">*</span>');
|
||||
$("#lineValueLabel").text(savings ? "Nominal" : "Harga Satuan / Nominal");
|
||||
if(savings){form.find("[name=tax_rate]").val("0");form.find("[name=qty]").val("1");form.find("[name=unit]").val("Tabungan");form.find("[name=batch_discount]").val("0");}
|
||||
if(savings){form.find("[name=tax_rate]").val("0");form.find("[name=qty]").val("1");form.find("[name=unit]").val("Tabungan");}
|
||||
else if(!inventory)form.find("[name=unit]").val("Jasa");
|
||||
selectedItem = null;
|
||||
selectedBars = [];
|
||||
@@ -537,7 +540,7 @@
|
||||
var date = form.find("[name=service_date]").val(),
|
||||
discount = parseMoney(form.find("[name=batch_discount]").val()),
|
||||
gross = batchLines.reduce(function (s, x) {
|
||||
return s + x.qty * x.unit_price;
|
||||
return s + (x.line_type === "savings" ? 0 : x.qty * x.unit_price);
|
||||
}, 0);
|
||||
if (!date) return notify("Tanggal transaksi wajib diisi.", "warning");
|
||||
if (discount < 0 || discount > gross)
|
||||
@@ -663,7 +666,6 @@
|
||||
}
|
||||
if(type === "savings")line.tax_rate=0;
|
||||
if(Number(form.find("[name=editing_line_id]").val())>0)return updateExistingLine(line);
|
||||
if(batchLines.length){var firstSavings=batchLines[0].line_type==="savings",currentSavings=line.line_type==="savings";if(firstSavings!==currentSavings)return notify("Barang/Jasa dan Tabungan harus dibuat pada invoice terpisah agar jurnalnya jelas.","warning");}
|
||||
batchLines.push(line);
|
||||
resetComposer();
|
||||
renderBatchLines();
|
||||
@@ -831,23 +833,26 @@
|
||||
function calcBatch() {
|
||||
var form = $("#invoiceLineForm");
|
||||
if (!form.length) return;
|
||||
var gross = batchLines.reduce(function (s, x) {
|
||||
return s + x.qty * x.unit_price;
|
||||
}, 0),
|
||||
var displayGross = batchLines.reduce(function (s, x) {
|
||||
return s + x.qty * x.unit_price;
|
||||
}, 0),
|
||||
gross = batchLines.reduce(function (s, x) {
|
||||
return s + (x.line_type === "savings" ? 0 : x.qty * x.unit_price);
|
||||
}, 0),
|
||||
discount = parseMoney(form.find("[name=batch_discount]").val()),
|
||||
last = -1,
|
||||
used = 0,
|
||||
total = 0;
|
||||
batchLines.forEach(function (x, i) {
|
||||
if (x.qty * x.unit_price > 0) last = i;
|
||||
if (x.line_type !== "savings" && x.qty * x.unit_price > 0) last = i;
|
||||
});
|
||||
batchLines.forEach(function (x, i) {
|
||||
var share = allocatedDiscount(x, i, gross, discount, last, used);
|
||||
var share = x.line_type === "savings" ? 0 : allocatedDiscount(x, i, gross, discount, last, used);
|
||||
used += share;
|
||||
total +=
|
||||
Math.max(0, x.qty * x.unit_price - share) * (1 + x.tax_rate / 100);
|
||||
});
|
||||
$("#batchGrossTotal").text(money(gross));
|
||||
$("#batchGrossTotal").text(money(displayGross));
|
||||
$("#batchDiscountTotal").text(money(discount));
|
||||
$("#lineLiveTotal").text(money(total));
|
||||
var valid = batchLines.length > 0 && discount >= 0 && discount <= gross;
|
||||
@@ -1227,11 +1232,51 @@
|
||||
});
|
||||
});
|
||||
});
|
||||
$(document).on("click", ".open-invoice-pdf", function () {
|
||||
$("#invoicePdfModal iframe").attr("src", $(this).data("url"));
|
||||
function openInvoicePdf(url) {
|
||||
$("#invoicePdfModal iframe").attr("src", url);
|
||||
bootstrap.Modal.getOrCreateInstance(
|
||||
document.getElementById("invoicePdfModal"),
|
||||
).show();
|
||||
}
|
||||
$(document).on("click", ".open-invoice-pdf", function () {
|
||||
var button = $(this),
|
||||
url = String(button.data("url") || ""),
|
||||
id = Number(button.data("id") || url.split("/").filter(Boolean).pop());
|
||||
if (!id || !url) return notify("Invoice tidak valid.", "error");
|
||||
button.prop("disabled", true);
|
||||
$.getJSON(cfg.base + "invoices/pdf_options/" + id)
|
||||
.done(function (response) {
|
||||
if (!response.status) return notify(response.message, "error");
|
||||
var option = response.data || {};
|
||||
if (Number(option.count || 0) < 1)
|
||||
return openInvoicePdf(url + "?include_previous=0");
|
||||
Swal.fire({
|
||||
title: "Pilihan PDF Invoice",
|
||||
html:
|
||||
"Customer memiliki <b>" +
|
||||
esc(option.count) +
|
||||
" invoice sebelumnya</b> yang belum lunas dengan total " +
|
||||
esc(money(option.total)) +
|
||||
".",
|
||||
icon: "question",
|
||||
input: "checkbox",
|
||||
inputValue: 0,
|
||||
inputPlaceholder:
|
||||
"Sertakan daftar tagihan sebelumnya pada PDF",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "Tampilkan PDF",
|
||||
cancelButtonText: "Batal",
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed)
|
||||
openInvoicePdf(
|
||||
url + "?include_previous=" + (result.value ? "1" : "0"),
|
||||
);
|
||||
});
|
||||
})
|
||||
.fail(error)
|
||||
.always(function () {
|
||||
button.prop("disabled", false);
|
||||
});
|
||||
});
|
||||
$("#invoicePdfModal").on("hidden.bs.modal", function () {
|
||||
$(this).find("iframe").attr("src", "about:blank");
|
||||
|
||||
Reference in New Issue
Block a user