hr dan payroll
This commit is contained in:
@@ -382,6 +382,7 @@
|
||||
return {
|
||||
item_id: $(".ajax-item").val() || 0,
|
||||
warehouse_id: $(".ajax-warehouse").val() || 0,
|
||||
editing_line_id: Number($("#invoiceLineForm [name=editing_line_id]").val()) || 0,
|
||||
};
|
||||
},
|
||||
);
|
||||
@@ -541,6 +542,10 @@
|
||||
);
|
||||
form.on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
if (Number(form.find("[name=editing_line_id]").val()) > 0) {
|
||||
stageCurrentLine();
|
||||
return;
|
||||
}
|
||||
if (!batchLines.length)
|
||||
return notify("Masukkan minimal satu item ke daftar.", "warning");
|
||||
var date = form.find("[name=service_date]").val(),
|
||||
@@ -678,22 +683,22 @@
|
||||
notify("Item dimasukkan ke daftar.", "success");
|
||||
}
|
||||
function updateExistingLine(line){
|
||||
var form=$("#invoiceLineForm"),id=Number(form.find("[name=editing_line_id]").val()),button=$("#stageInvoiceLine"),data={service_date:form.find("[name=service_date]").val(),description:line.description,unit:line.unit,qty:line.qty,unit_price:line.unit_price,discount_amount:parseMoney(form.find("[name=batch_discount]").val()),tax_rate:line.tax_rate,notes:line.notes,account_id:line.account_id,counter_account_id:line.counter_account_id||""};
|
||||
var form=$("#invoiceLineForm"),id=Number(form.find("[name=editing_line_id]").val()),button=$("#stageInvoiceLine"),data={line_type:line.line_type,service_date:form.find("[name=service_date]").val(),description:line.description,unit:line.unit,qty:line.qty,unit_price:line.unit_price,discount_amount:parseMoney(form.find("[name=batch_discount]").val()),tax_rate:line.tax_rate,notes:line.notes,account_id:line.account_id,counter_account_id:line.counter_account_id||"",item_id:line.item_id||"",warehouse_id:line.warehouse_id||"",barcodes:JSON.stringify(line.barcodes||[])};
|
||||
button.prop("disabled",true).html('<span class="spinner-border spinner-border-sm"></span> Menyimpan...');
|
||||
post(cfg.base+"invoices/update_line/"+cfg.invoiceId+"/"+id,data).done(function(r){if(!r.status)return notify(r.message,"error");notify(r.message,"success");bootstrap.Modal.getOrCreateInstance(document.getElementById("invoiceItemModal")).hide();if(lineTable)lineTable.ajax.reload(null,false)}).fail(error).always(function(){button.prop("disabled",false).html('<i class="bi bi-save"></i> Simpan Perubahan')});
|
||||
post(cfg.base+"invoices/update_line/"+cfg.invoiceId+"/"+id,data).done(function(r){if(!r.status)return notify(r.message,"error");notify(r.message,"success");var refreshPage=Number(form.data("editing-delivery")||0)>0;bootstrap.Modal.getOrCreateInstance(document.getElementById("invoiceItemModal")).hide();if(refreshPage)setTimeout(function(){location.reload();},350);else if(lineTable)lineTable.ajax.reload(null,false)}).fail(error).always(function(){button.prop("disabled",false).html('<i class="bi bi-save"></i> Simpan Perubahan')});
|
||||
}
|
||||
function editExistingLine(row){
|
||||
var form=$("#invoiceLineForm"),savings=row.line_type==="savings";
|
||||
batchLines=[];form.find("[name=editing_line_id]").val(row.id);$("#invoiceItemModal").addClass("editing-line");$("#invoiceItemModal .modal-title").text("Edit Item Nonbarang");$("#invoiceItemModal .modal-header small").text("Perubahan hanya berlaku pada item Draft yang dipilih.");
|
||||
form.find('[name=line_type][value="'+(savings?'savings':'service')+'"]').prop("checked",true).trigger("change");
|
||||
if(row.line_type==="savings")setSelect(".ajax-liability-account",row.account_id,(row.kode_akun||"")+" - "+(row.nama_akun||""));
|
||||
else setSelect(".ajax-account",row.account_id,(row.kode_akun||"")+" - "+(row.nama_akun||""));
|
||||
form.find("[name=service_date]").val(row.service_date);form.find("[name=description]").val(row.nama_item);form.find("[name=unit]").val(row.unit||"Jasa");form.find("[name=qty]").val(fmt(row.qty));form.find("[name=unit_price]").val(fmt(row.harga));form.find("[name=batch_discount]").val(fmt(row.discount_amount));form.find("[name=tax_rate]").val(row.tax_rate||0);form.find("[name=notes]").val(row.keterangan||"");$("#stageInvoiceLine").html('<i class="bi bi-save"></i> Simpan Perubahan');renderBatchLines();bootstrap.Modal.getOrCreateInstance(document.getElementById("invoiceItemModal")).show();
|
||||
var form=$("#invoiceLineForm"),inventory=row.line_type==="inventory",savings=row.line_type==="savings";
|
||||
batchLines=[];form.find("[name=editing_line_id]").val(row.id);form.data("editing-delivery",Number(row.delivery_line_id||0));$("#invoiceItemModal").addClass("editing-line");$("#invoiceItemModal .modal-title").text("Edit Item Invoice");$("#invoiceItemModal .modal-header small").text(inventory?"Reservasi barang dan jurnal lama akan disesuaikan otomatis. Surat Jalan yang sudah diposting tidak dapat diedit.":"Perubahan hanya berlaku pada item Draft yang dipilih.");
|
||||
form.find('[name=line_type][value="'+row.line_type+'"]').prop("checked",true).trigger("change");form.find("[name=line_type]").prop("disabled",true);
|
||||
if(savings)setSelect(".ajax-liability-account",row.account_id,(row.kode_akun||"")+" - "+(row.nama_akun||""));else setSelect(".ajax-account",row.account_id,(row.kode_akun||"")+" - "+(row.nama_akun||""));
|
||||
if(inventory){selectedItem={id:row.items_id,kode_detail:row.item_code,nama_barang:row.nama_item,harga_jual:row.item_sale_price,tracking_type:row.tracking_type,unit:row.item_unit||row.unit};setSelect(".ajax-warehouse",row.warehouse_id,row.warehouse_name||("Gudang #"+row.warehouse_id));setSelect(".ajax-item",row.items_id,(row.item_code?row.item_code+" - ":"")+row.nama_item);selectedBars=(row.barcode_allocations||[]).map(function(bar){var optionText=bar.barcode+(bar.serial_number?" / "+bar.serial_number:"")+" - tersedia "+qty(bar.available);if(!$(".ajax-barcode option[value='"+bar.id+"']").length)$(".ajax-barcode").append(new Option(optionText,bar.id,true,true));return{id:Number(bar.id),barcode:bar.barcode,serial_number:bar.serial_number||"",available:Number(bar.available),qty:Number(bar.qty),tracking_type:bar.tracking_type||row.tracking_type||"UNIT"};});$(".ajax-barcode").val(selectedBars.map(function(bar){return String(bar.id);})).trigger("change.select2");$("#trackingHint").text((row.tracking_type||"UNIT")+" - "+(row.item_unit||row.unit||"-"));renderBars();}
|
||||
form.find("[name=service_date]").val(row.service_date);form.find("[name=description]").val(row.nama_item);form.find("[name=unit]").val(row.unit||(savings?"Tabungan":"Jasa"));form.find("[name=qty]").val(fmt(row.qty));form.find("[name=unit_price]").val(fmt(row.harga));form.find("[name=batch_discount]").val(fmt(row.discount_amount));form.find("[name=tax_rate]").val(row.tax_rate||0);form.find("[name=notes]").val(row.keterangan||"");$("#stageInvoiceLine").html('<i class="bi bi-save"></i> Simpan Perubahan');renderBatchLines();calcBatch();bootstrap.Modal.getOrCreateInstance(document.getElementById("invoiceItemModal")).show();
|
||||
}
|
||||
function scanExact() {
|
||||
var code = $("#barcodeScan").val().trim();
|
||||
if (!code) return notify("Masukkan atau scan barcode.", "warning");
|
||||
$.getJSON(cfg.base + "invoices/lookup_barcodes", { q: code, exact: 1 })
|
||||
$.getJSON(cfg.base + "invoices/lookup_barcodes", { q: code, exact: 1, editing_line_id: Number($("#invoiceLineForm [name=editing_line_id]").val()) || 0 })
|
||||
.done(function (r) {
|
||||
if (!r.results || r.results.length !== 1)
|
||||
return notify(
|
||||
@@ -703,6 +708,10 @@
|
||||
"warning",
|
||||
);
|
||||
var b = r.results[0];
|
||||
if (selectedItem && (String(selectedItem.id) !== String(b.item_id) || String($(".ajax-warehouse").val() || "") !== String(b.warehouse_id))) {
|
||||
selectedBars = [];
|
||||
renderBars();
|
||||
}
|
||||
setSelect(".ajax-warehouse", b.warehouse_id, b.warehouse_name);
|
||||
setSelect(
|
||||
".ajax-item",
|
||||
@@ -736,7 +745,7 @@
|
||||
});
|
||||
$("#invoiceItemModal").on("hidden.bs.modal", function () {
|
||||
var form=$("#invoiceLineForm");if(!form.length||!form.find("[name=editing_line_id]").val())return;
|
||||
form.find("[name=editing_line_id]").val("");$(this).removeClass("editing-line");$(this).find(".modal-title").text("Tambah Beberapa Item Invoice");$(this).find(".modal-header small").text("Susun maksimal 100 barang, jasa, atau tabungan dalam satu kali penyimpanan.");$("#stageInvoiceLine").html('<i class="bi bi-plus-lg"></i> Masukkan ke Daftar');batchLines=[];form.find("[name=batch_discount]").val("0");form.find('[name=line_type][value="inventory"]').prop("checked",true).trigger("change");resetComposer();renderBatchLines();
|
||||
form.find("[name=editing_line_id]").val("");form.removeData("editing-delivery");form.find("[name=line_type]").prop("disabled",false);$(this).removeClass("editing-line");$(this).find(".modal-title").text("Tambah Beberapa Item Invoice");$(this).find(".modal-header small").text("Susun maksimal 100 barang, jasa, atau tabungan dalam satu kali penyimpanan.");$("#stageInvoiceLine").html('<i class="bi bi-plus-lg"></i> Masukkan ke Daftar');batchLines=[];form.find("[name=batch_discount]").val("0");form.find('[name=line_type][value="inventory"]').prop("checked",true).trigger("change");resetComposer();renderBatchLines();
|
||||
});
|
||||
function setSelect(selector, value, text) {
|
||||
var select = $(selector),
|
||||
@@ -1017,8 +1026,10 @@
|
||||
render: function (d, t, r) {
|
||||
if(cfg.mode !== "edit" || !cfg.permissions.update)return "-";
|
||||
var buttons="";
|
||||
if(["service","savings"].indexOf(r.line_type)>=0)buttons += '<button class="btn btn-sm btn-outline-primary edit-line" data-id="'+r.id+'"><i class="bi bi-pencil"></i></button> ';
|
||||
buttons += '<button class="btn btn-sm btn-outline-danger remove-line" data-id="'+r.id+'"><i class="bi bi-trash"></i></button>';
|
||||
var inventoryLocked=r.line_type==="inventory" && (!!r.stock_posted_at || Number(r.stock_log_id||0)>0);
|
||||
if(inventoryLocked)return '<span class="badge text-bg-secondary" title="Mutasi stok sudah diposting; gunakan retur atau koreksi persediaan"><i class="bi bi-lock"></i> Terkunci</span>';
|
||||
if(["inventory","service","savings"].indexOf(r.line_type)>=0)buttons += '<button type="button" class="btn btn-sm btn-outline-primary edit-line" data-id="'+r.id+'" title="Edit item"><i class="bi bi-pencil"></i></button> ';
|
||||
buttons += '<button type="button" class="btn btn-sm btn-outline-danger remove-line" data-id="'+r.id+'" title="Hapus item"><i class="bi bi-trash"></i></button>';
|
||||
return buttons;
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user