Fiş
Fiş Script
(async () => {
this._receiptNote = 0;
const primary = this.recordService.formGroup.controls.ID;
const statusControl = this.recordService.formGroup.controls.STATUS;
const recordClass =".ang-record-" + this.recordService.component.recordID;
const awaitIf = async (fn, ms = 100) => {
let result = false;
while(!result){
try {
result = fn();
} catch (e) {
console.error(e);
}
if(!result)
await rxjs.timer(ms).toPromise();
}
};
const accountGrid = this.allGrids["accounting-receipt-detail"];
this.recordService.component.buttonsForTemplate.clone="disabled";
const cloneVisible = async() => {
try {
if (!accountGrid) {
throw new Error("accountGridNull");
}
setTimeout(() => {
this.recordService.component.buttonsForTemplate.clone=true;
}, 5000);
} catch (e) {
console.error("cloneVisible", e);
}
};
cloneVisible();
console.log("this", this);
const visibleButton = async (visibility) => {
try {
if (!accountGrid) {
throw new Error("accountGridNull");
}
await awaitIf(() => accountGrid.grid && accountGrid.grid.agGrid);
accountGrid.grid.buttonsForTemplate.addButton = visibility;
accountGrid.grid.buttonsForTemplate.deleteButton = visibility;
accountGrid.grid.buttonsForTemplate.editButton = visibility;
} catch (e) {
console.error("buttonVisible", e);
}
};
const accountListBtnDisable = async(v,type)=>{
document.querySelector(recordClass + " #splitByQty").disabled = v;
this.recordService.component.angusDialog;
if(v){
let msg = this.languageService.staticTranslator.translate(
"This fiche is created by "+type+" integration. Changes can only be made in "+type+" form."
);
angus.serviceWorkerService.snackBar.open(msg, "(x)", { duration: 5e3 });
}
}
const gridFicheDetailDisable = async(v)=>{
if (v) {
disabledFields("disable");
document.querySelector(recordClass + " #splitByQty").disabled = true;
let msg = this.languageService.staticTranslator.translate(
"This fiche is approved, you cannot make changes"
);
angus.serviceWorkerService.snackBar.open(msg, "(x)", { duration: 5e3 });
visibleButton(false);
await rxjs.timer(1000).toPromise();
accountGrid.grid.agGrid.defaultColDef.editable = false;
const defs = accountGrid.grid.agGrid.columnApi
.getAllColumns()
.map((col) => col.getColDef());
for (const def of defs) {
def.editable = false;
}
await rxjs.timer(10).toPromise();
accountGrid.grid.agGrid.api.setColumnDefs(defs);
accountGrid.grid.agGrid.api.refreshCells({force:true});
visibleButton(false);
return;
}
else
{
disabledFields("enable");
visibleButton(true);
}
}
const disabledFields = (isActive) => {
try {
if (isActive == "enable") {
this.recordService.formGroup.controls.OPERATIONID_NAME.enable();
if(angus.api.tenant.RECEIPTNUMBER_MANUAL){
this.recordService.formGroup.controls.RECEIPTNUMBER.enable();
}else{
this.recordService.formGroup.controls.RECEIPTNUMBER.disable();
}
this.recordService.formGroup.controls.DOCNO.enable();
this.recordService.formGroup.controls.DOCDATE.enable();
this.recordService.formGroup.controls.DOCTYPE.enable();
this.recordService.formGroup.controls.SPECIALCODEID_NAME.enable();
this.recordService.formGroup.controls.EXPENSEID_NAME.enable();
this.recordService.formGroup.controls.BRANCHID_NAME.enable();
this.recordService.formGroup.controls.PAYMENTMETHOD.enable();
this.recordService.formGroup.controls.STATUS.enable();
this.recordService.formGroup.controls.RECEIPTDATE.enable();
this.recordService.formGroup.controls.NOTES.enable();
this.recordService.formGroup.controls.TOTALBALANCE.enable();
this.recordService.formGroup.controls.TOTALCREDIT.enable();
this.recordService.formGroup.controls.TOTALDEBIT.enable();
this.recordService.formGroup.controls.TYPEID.enable();
} else if (isActive == "disable") {
this.recordService.formGroup.controls.OPERATIONID_NAME.disable();
this.recordService.formGroup.controls.RECEIPTNUMBER.disable();
this.recordService.formGroup.controls.DOCNO.disable();
this.recordService.formGroup.controls.DOCDATE.disable();
this.recordService.formGroup.controls.DOCTYPE.disable();
this.recordService.formGroup.controls.SPECIALCODEID_NAME.disable();
this.recordService.formGroup.controls.EXPENSEID_NAME.disable();
this.recordService.formGroup.controls.BRANCHID_NAME.disable();
this.recordService.formGroup.controls.PAYMENTMETHOD.disable();
this.recordService.formGroup.controls.STATUS.disable();
this.recordService.formGroup.controls.RECEIPTDATE.disable();
this.recordService.formGroup.controls.NOTES.disable();
this.recordService.formGroup.controls.TOTALBALANCE.disable();
this.recordService.formGroup.controls.TOTALCREDIT.disable();
this.recordService.formGroup.controls.TOTALDEBIT.disable();
this.recordService.formGroup.controls.TYPEID.disable();
}
} catch (e) {
console.error("disabledFields", e);
}
};
const chequeControlExist = async() =>{
debugger;
let cheqeueIdFind = false;
await awaitIf(() => accountGrid.grid && accountGrid.grid.agGrid);
await awaitIf(() => accountGrid.grid && accountGrid.grid.agGrid);
await awaitIf(() => accountGrid.grid && accountGrid.grid.agGrid);
await accountGrid.grid.gridShareds.onRowLoad.pipe(rxjs.first((x) => x)).toPromise();//grid data yüklenene kadar bekle
accountGrid.api.forEachNode(rowNode => {
if(rowNode.data.CHEQUEID){
cheqeueIdFind= true
}
});
if(cheqeueIdFind){
accountGrid.grid.agGrid.columnApi.setColumnsVisible(['CHEQUEID_INFO','CHEQUEACTIONID'], true);
}
}
this.recordService.formGroup.controls.RECEIPTDATE.valueChanges.pipe(rxjs.skip(2)).subscribe(
(v) => {
console.log('RECEIPTDATE subscribe',v);
if(!angus.api.tenant.RECEIPTNUMBER_MANUAL)
{
let ficheDate = moment(this.recordService.formGroup.controls.RECEIPTDATE.value).format('MMDD');
if(this.recordService.formGroup.controls.RECEIPTNUMBER.value)
{
if(this.recordService.formGroup.controls.RECEIPTNUMBER.value.length>=4)
if(this.recordService.formGroup.controls.RECEIPTNUMBER.value.substring(0,4) != ficheDate)
{
this.recordService.formGroup.controls.RECEIPTNUMBER.setValue('0');
this.recordService.formGroup.controls.RECEIPTNUMBER.setValue(null);
this.recordService.formGroup.controls.RECEIPTNUMBER.markAsDirty();
}
}
else
{
if(this.recordService.lastData)
if(moment(this.recordService.lastData.RECEIPTDATE).format('YYYY-MM-DD') == moment(this.recordService.formGroup.controls.RECEIPTDATE.value).format('YYYY-MM-DD') && !this.recordService.formGroup.controls.RECEIPTNUMBER.value)
{
this.recordService.formGroup.controls.RECEIPTNUMBER.setValue(this.recordService.lastData.RECEIPTNUMBER);
this.recordService.formGroup.controls.RECEIPTNUMBER.markAsDirty();
}
}
}
}
);
primary.valueChanges
.pipe(
rxjs.startWith(primary.value),
rxjs.debounceTime(100),
rxjs.takeUntil(this.isDestroy$)
)
.subscribe(async (statusId) => {
let ficheMustBeDisabled = false;
let snackBarMsg = "";
if (!this.recordService.lastData) {
this.allFormControls["STATUS"].setValue(2);
this.allFormControls["RECEIPTDATE"].setValue(moment());
}
await awaitIf(() => accountGrid.grid && accountGrid.grid.agGrid);
await awaitIf(() => accountGrid.grid && accountGrid.grid.agGrid);
await awaitIf(() => accountGrid.grid && accountGrid.grid.agGrid);
await accountGrid.grid.gridShareds.onRowLoad.pipe(rxjs.first((x) => x)).toPromise();//grid data yüklenene kadar bekle
if (statusControl.value == 3){
ficheMustBeDisabled=true;
}
if(!ficheMustBeDisabled){
const countingId = this.recordService.formGroup.get("COUNTINGID").value;
if (countingId && !angus.api.tenant.ACCOUNTING_ALLOWCHANGE_COUNTINGACCRECEIPT){
snackBarMsg='Counting';
ficheMustBeDisabled=true;
}
}
if(!ficheMustBeDisabled){
const invoiceId = this.recordService.formGroup.get("INVOICEID").value;
const ServiceInvoice = ( invoiceId && (this.recordService.formGroup.controls.SOURCETYPEID.value == 7 && !angus.api.tenant.ACCOUNTING_ALLOWCHANGE_SERVICEINVOICEACCRECEIPT));
const StockInvoice = (invoiceId && (this.recordService.formGroup.controls.SOURCETYPEID.value == 6 && !angus.api.tenant.ACCOUNTING_ALLOWCHANGE_STOCKINVOICEACCRECEIPT));
const HotelInvoice = (invoiceId && (this.recordService.formGroup.controls.SOURCETYPEID.value == 5 && !angus.api.tenant.ACCOUNTING_ALLOWCHANGE_HOTELINVOICEACCRECEIPT));
if ( (ServiceInvoice==true || StockInvoice==true || HotelInvoice==true) )
{
snackBarMsg='Invoice';
ficheMustBeDisabled=true;
}
}
gridFicheDetailDisable(ficheMustBeDisabled);
accountListBtnDisable(ficheMustBeDisabled,snackBarMsg);
chequeControlExist();
});
document.querySelector(
`.ang-record-${this.recordID} .ang-panel-P3`
).style.display = "none";
document.querySelector(
`.ang-record-${this.recordID} .ang-panel-P3`
).parentElement.style.display = "none";
document.querySelector(
`.ang-record-${this.recordID} .dynamic-container`
).style.gridTemplateAreas = `"P1" "P2"`;
document.querySelector("#splitByQty .mat-icon").style.transform =
"rotate(0deg)";
let docTypeControl = this.allFormControls["DOCTYPE"];
const typeOthercontrol = this.allFormControls["DOCTYPEOTHER"];
docTypeControl.valueChanges
.pipe(rxjs.startWith(docTypeControl.value), rxjs.takeUntil(this.isDestroy$))
.subscribe((v) => {
if (v == 8) {
typeOthercontrol.enable();
} else {
typeOthercontrol.disable();
}
});
})();
Last updated