You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

357 lines
10 KiB
JavaScript

var acc = _json('acc').map(function(a){
return {
id:a.kode,
text:a.nama,
app:a.app,
}
});
export const dtData = {
val : {},
set: function(a){
this.val = a;
return this;
}
,clear : function(){
this.val = {};
return this;
}
}
export const totSaldo = {
val: 0,
set: function(a){
if(typeof a === 'number'){
this.val = a
}
return this;
}
, clear: function () {
this.val = 0;
return this;
}
}
export const formData = [
{
title: 'Jenis Transaksi',
type: 'radio',
name: 'kodesp',
down: true,
downcols: 3,
row: 12,
data: JSON.parse(_id('jpinjam').innerHTML).cond('0', 'status'),
readonly: false,
action: function (a) {
if (_id('kode').value != '') {
var data = JSON.parse(_id('anggota').innerHTML).cond(_id('kode').value, 'id')[0];
var r = _master('jpinjam', 'jpinjam')
.cond(globalThis['kodesp'].parent.value, 'id');
if (r.length > 0) {
r = r[0];
};
try {
window._setval('jumlah', data[r.rw].number(2).currency(0));
} catch(e){
window._setval('jumlah', 0);
}
} else {
var cash = acc[0].id;
_setval('cash', cash);
};
var f = tanggal(_getval('tgl')).sekarang2.split(' ');
var kodesp = a;
_setval('keterangan', kodesp + ' ' + f[1] + ' ' + f[2]);
if (_getval('dk') == 'D') {
globalThis._news.code({
code: 'BKM',
row: 'faktur',
table: 'msimpan',
data: a,
pad: 5
});
if (globalThis['kode'].parent.value != '') {
var ft = `SELECT ifnull((SELECT sum(if(dk='K',jumlah*-1,jumlah)) total FROM msimpan
WHERE kode = '${globalThis['kode'].parent.value}' AND kodesp = '${globalThis['kodesp'].parent.value}'),0) total`;
AuditDevQuery(ft, function (a) {
totSaldo.set(a[0].total.number(2));
var jml = _getval('jumlah').number();
if (_getval('dk') === 'K') {
_setval('saldo', (totSaldo.val - jml).currency(0));
} else {
_setval('saldo', (totSaldo.val + jml).currency(0));
}
});
};
} else {
globalThis._news.code({
code: 'BKK',
row: 'faktur',
table: 'msimpan',
data: a,
pad:5
});
if (globalThis['kode'].parent.value != '') {
var ft = `SELECT ifnull((SELECT sum(if(dk='K',jumlah*-1,jumlah)) total FROM msimpan
WHERE kode = '${globalThis['kode'].parent.value}' AND kodesp = '${globalThis['kodesp'].parent.value}'),0) total`;
AuditDevQuery(ft, function (a) {
totSaldo.set(a[0].total.number(2));
var jml = _getval('jumlah').number();
if (_getval('dk') === 'K') {
_setval('jumlah', (totSaldo.val).currency(0));
_setval('saldo', (0).currency(0));
} else {
_setval('saldo', (totSaldo.val + jml).currency(0));
}
});
};
};
},
}
, {
title: 'Tgl. Simpanan',
type: 'date',
name: 'tgl',
row: 4,
readonly: false,
action: function () {
},
}
, {
title: 'No. Anggota',
type: 'select',
name: 'kode',
row: 4,
data: JSON.parse(_id('anggota').innerHTML),
readonly: false,
unchange: true,
action: function (a) {
_Evchange(a, function(){
let dt = dtData.val;
var val = this.value;
var data = JSON.parse(_id('anggota').innerHTML).cond(val, 'id');
if(data.length > 0){
data = data[0];
_setval('golkar', data.golkar);
var ft = `SELECT ifnull((SELECT sum(if(dk='K',jumlah*-1,jumlah)) total FROM msimpan
WHERE kode = '${_getval('kode')}'
AND kodesp = '${_getval('kodesp')}'
AND status <> 1
),0) `;
if (dt.jumlah != undefined) {
ft = `SELECT ifnull((SELECT sum(if(dk='K',jumlah*-1,jumlah)) total FROM msimpan
WHERE kode = '${_getval('kode')}'
AND kodesp = '${_getval('kodesp')}'
AND status <> 1
AND faktur <> '${dt.faktur}'
),0) `;
}
if(_getval('kodesp') == 'BW'){
ft += " - ifnull((SELECT sum(debet) total FROm totsl WHERE kodesc = '" + _getval('kode') +"' AND faktur NOT LIKE 'FS%' AND debet <> 0),0)";
}
ft += ' total ';
console.log(ft);
AuditDevQuery(ft, function (a) {
totSaldo.set( a[0].total.number(2) );
var jml = _getval('jumlah').number();
if(dt.jumlah != undefined){
if (_getval('dk') === 'K') {
console.log(totSaldo);
_setval('jumlah', dt.jumlah.number(2).currency(0));
_setval('saldo', ( totSaldo - dt.jumlah.number(2) ).currency(0));
} else {
console.log(jml);
_setval('saldo', (totSaldo.val + jml).currency(0));
}
}else{
if (_getval('dk') === 'K') {
_setval('jumlah', (totSaldo.val).currency(0));
_setval('saldo', (0).currency(0));
} else {
_setval('saldo', (totSaldo.val + jml).currency(0));
}
}
})
var ang = JSON.parse(_id('anggota').innerHTML).cond(val, 'id')[0];
_setval('nip', ang.nip);
_setval('unitkerja', ang.unitkerja);
_setval('golgaji', ang.golongan);
var r = _master('jpinjam', 'jpinjam').cond(_getval('kodesp'), 'id');
if (r.length > 0) {
r = r[0];
};
try{
_setval('jumlah', data[r.rw].number(2).currency(0));
}catch(e){
console.log(e);
}
}
})
},
}
, {
title: 'Cash',
type: 'select',
name: 'cash',
row: 4,
data: acc,
readonly: true,
action: function () {
},
}
, {
title: 'NIP',
type: 'text',
name: 'nip',
row: 4,
unfollow: true,
readonly: true,
action: function () {
},
}
, {
title: 'Unit Kerja',
type: 'text',
name: 'unitkerja',
row: 4,
unfollow: true,
readonly: true,
action: function () {
},
}
, {
title: 'Status',
type: 'text',
name: 'status',
row: 2,
unfollow: false,
readonly: true,
action: function () {
},
}
, {
title: 'Gol. Gaji',
type: 'text',
name: 'golgaji',
row: 2,
unfollow: false,
readonly: true,
action: function () {
},
}
, {
title: 'No.Bukti Kwintansi',
type: 'text',
name: 'faktur',
row: 4,
readonly: true,
action: function () {
},
}
, {
title: 'Keterangan',
type: 'text',
name: 'keterangan',
row: 8,
readonly: false,
action: function () {
},
}
, {
title: 'Nominal',
type: 'number',
name: 'jumlah',
row: 6,
readonly: false,
action: function (a) {
if (_getval('dk') === 'K') {
_setval('saldo', (totSaldo.val - a).currency(0));
} else {
_setval('saldo', (totSaldo.val + a).currency(0));
}
},
}
, {
title: 'Saldo Akhir',
type: 'number',
name: 'saldo',
row: 6,
readonly: true,
unfollow: true,
info: 'Saldo akhir merupakan saldo (+/-) nominal',
action: function () {
},
}
, {
title: 'user',
type: 'text',
name: 'username',
row: 4,
display: 'none',
readonly: true,
action: function () {
},
}
, {
title: 'user',
type: 'text',
name: 'userlog',
row: 4,
display: 'none',
readonly: true,
action: function () {
},
}
, {
title: 'user',
type: 'text',
name: 'dk',
row: 4,
display: 'none',
readonly: true,
action: function () {
},
}
, {
title: 'user',
type: 'text',
name: 'golkar',
row: 4,
display: 'none',
readonly: true,
action: function () {
},
}
, {
title: 'Kasir',
type: 'text',
name: 'kasir',
row: 6,
readonly: true,
action: function () {
},
}
, {
title: 'Jam',
type: 'text',
name: 'jam',
row: 6,
readonly: true,
action: function () {
},
}
];