Trigger Accountbilltrigger on Account__c (after update,after insert) {Account__c bill = trigger.new[0]; The payment method in the service order is not in cash, and the service order produces a receivable, and the status of the receivable is not clear, and the receivable after the production of a week still no receivables tracking record if (bill.createweek__c== ' 1 ' &&bill.statue__ c== ' not cleared ') {if (bill.servicenumber__c!=null) {customerservicelist__c cusser =[select id,name,paymentmeth
Od__c,createdbyid from Customerservicelist__c WHERE Id=:bill.servicenumber__c];
System.debug (' Cusser: ' +cusser); if (cusser.paymentmethod__c!= ' cash ') {list<debtrecord__c> deb =[select ID from Debtrecord__c WHERE ser
Vicenumber__c=:bill.servicenumber__c]; if (Deb.size () ==0) {String msg = ' +cusser.name+ ' service order generated receivables by the end of the week there is no Dunning records, please prompt and follow up the situation recorded in the system, thank you.
';
Chattersender.send (cusser.createdbyid,msg,cusser.id);
User U=[select Phone from user WHERE Id=:cusser.createdbyid];
Sms.dofuturesend (U.PHONE,MSG); }}}}else if (bill.createweek__c== ' 2 ' &&bill.statue__c== ' not cleared ') {if (Bill.serv Icenumber__c!=null) {Customerservicelist__c cusser =[select Id,name,paymentmethod__c,createdbyid from Customer
Servicelist__c WHERE Id=:bill.servicenumber__c];
System.debug (' Cusser: ' +cusser); if (cusser.paymentmethod__c!= ' cash ') {list<debtrecord__c> deb =[select ID from Debtrecord__c WHERE ser
Vicenumber__c=:bill.servicenumber__c]; if (Deb.size () <2) {String msg = ' +cusser.name+ ' service order generated receivables by the end of two weeks, but did not meet the requirements of the company two weeks followed by two times the system, please prompt and will follow up the situation in mind Recorded in the system, thank you.
';
Chattersender.send (cusser.createdbyid,msg,cusser.id);
User U=[select Phone from user WHERE Id=:cusser.createdbyid];
Sms.dofuturesend (U.PHONE,MSG); }}}//Cash more than 7 days without emptying reminder technician if (bill.remind__c==true&&trigger.old[0].remind__c!=True) {if (bill.servicenumber__c!=null) {customerservicelist__c cus=[select Id,name,createdbyid from CU
Stomerservicelist__c WHERE Id=:bill.servicenumber__c]; User U=[select Phone from user WHERE Id=:cus.
Createdbyid]; String msg= ' number is: ' +cus. Name+ ' Service list for cash collection, currently more than seven days of outstanding, please timely payment to the financial to write off, thank you.
';
Sms.dofuturesend (U.PHONE,MSG); }//Cash more than 4000 remind technician if (bill.statue__c== ' &&bill.price3__c>=4000) {if (Bill.servicenu Mber__c!=null) {Customerservicelist__c cus=[select id,name,createdbyid,paymentmethod__c from Customerserviceli
St__c WHERE Id=:bill.servicenumber__c];
if (cus.paymentmethod__c== ' cash ') {Boolean issendsms = true;
if (trigger.isinsert) {issendsms = true; } if (trigger.isupdate) {if (trigger.old[0].statue__c== ' not cleared ' &&trigger.old[0].pri
ce3__c>=4000) { issendsms = false;//update will not relapse SMS}} if (Issendsms) { User U=[select Phone from user WHERE Id=:cus.
Createdbyid]; String msg= ' number is: ' +cus. Name+ ' Service list for cash collection and the amount of payment to meet 4000, please timely make money to the financial verification, thank you.
';
Sms.dofuturesend (U.PHONE,MSG);
}}}}//Receivables and reminders (30 days) if (bill.dealline1__c&&bill.dealline1__c!=true) { if (bill.servicenumber__c!=null) {Customerservicelist__c cus=[select Id,name,createdbyid from Customerservic
Elist__c WHERE Id=:bill.servicenumber__c]; User U=[select Phone from user WHERE Id=:cus.
Createdbyid]; String msg= ' number is: ' +cus. Name+ ' Service list of receivables generated by the current 30 days have not been cleared, please prompt, thank you.
';
Sms.dofuturesend (U.PHONE,MSG); }}//Receivables and reminders (50 days) if (bill.deadline2__c&&bill.deadline2__c!=true) {if (bill.servicenumber__c!= NULL) {Customerservicelist__c cus=[sElect Id,name,createdbyid from Customerservicelist__c WHERE Id=:bill.servicenumber__c]; User U=[select Phone from user WHERE Id=:cus.
Createdbyid]; String msg= ' number is: ' +cus. Name+ ' Service list of receivables generated by the current 50 days have not been cleared, please prompt, thank you.
';
Sms.dofuturesend (U.PHONE,MSG); }}//Receivables and reminders (70 days) if (bill.deadline3__c&&bill.deadline3__c!=true) {if (bill.servicenumber__c!= NULL) {Customerservicelist__c cus=[select Id,name,createdbyid from Customerservicelist__c WHERE Id=:bill.servi
Cenumber__c]; User U=[select Phone from user WHERE Id=:cus.
Createdbyid]; String msg= ' number is: ' +cus. Name+ ' Service list of receivables generated by the current 70 days have not been cleared, please prompt, thank you.
';
Sms.dofuturesend (U.PHONE,MSG); }
}
}