Page 1 of 1

HookAddCode request for deposit slip reconciliation

Posted: Wed Jun 20, 2012 7:04 pm
by alkhaef
HookAddCode request in "OpenDentBusiness/Data Interface/Payments.cs"

Hello. I just opened a feature request (#2464) for a robust solution to this, but in the meantime I'd like to throw my own little hack together.

Unfortunately, the parameter "command" is a string that I'd like to be able to manipulate, but I tried to follow Dr. Sparks' pattern for this situation below.

Code: Select all

		public static List<Payment> GetForDeposit(DateTime dateStart,long clinicNum,List<long> payTypes) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<List <Payment>>(MethodBase.GetCurrentMethod(),dateStart,clinicNum,payTypes);
			}
			string command=
				"SELECT * FROM payment "
				+"WHERE DepositNum = 0 "
				+"AND PayDate >= "+POut.Date(dateStart)+" ";
			if(clinicNum!=0){
				command+="AND ClinicNum="+POut.Long(clinicNum);
			}
			for(int i=0;i<payTypes.Count;i++) {
				if(i==0) {
					command+=" AND (";
				}
				else {
					command+=" OR ";
				}
				command+="PayType="+POut.Long(payTypes[i]);
				if(i==payTypes.Count-1) {
					command+=")";
				}
			}
			command+=" ORDER BY PayDate";
//BEGIN NEW HOOK HERE PLEASE :) SOMETHING LIKE...
object[] parameters={command};
Plugins.HookAddCode(null, "Payments.GetForDeposit_beforequeryrun", parameters);
command=(string)parameters[0];
//END NEW HOOK HERE PLEASE :)
			return Crud.PaymentCrud.SelectMany(command);
		}
Thanks,
Al

Re: HookAddCode request for deposit slip reconciliation

Posted: Sat Jun 23, 2012 4:32 pm
by jordansparks
Yes, that pattern looks good. We will implement.

Re: HookAddCode request for deposit slip reconciliation

Posted: Fri Jun 29, 2012 2:50 pm
by alkhaef
I just realized 12.2 just went stable :-D. Did this hook get into 12.2 before that? Or will it just go into 12.3?

Thanks,
Al

Re: HookAddCode request for deposit slip reconciliation

Posted: Mon Jul 09, 2012 10:25 pm
by alkhaef
Hi guys,

I downloaded the most recent 12.3 and noticed it wasn't in there yet. So I decided to give it a try locally first to make sure it allows my extension, and it turned out to be a good thing, because I'd like to ask for one more parameter ;). Could I add payTypes to the array like the following?...

Code: Select all

		///<summary>Gets all unattached payments for a new deposit slip.  Excludes payments before dateStart.  There is a chance payTypes might be of length 1 or even 0.</summary>
		public static List<Payment> GetForDeposit(DateTime dateStart,long clinicNum,List<long> payTypes) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<List <Payment>>(MethodBase.GetCurrentMethod(),dateStart,clinicNum,payTypes);
			}
			string command=
				"SELECT * FROM payment "
				+"WHERE DepositNum = 0 "
				+"AND PayDate >= "+POut.Date(dateStart)+" ";
			if(clinicNum!=0){
				command+="AND ClinicNum="+POut.Long(clinicNum);
			}
			for(int i=0;i<payTypes.Count;i++) {
				if(i==0) {
					command+=" AND (";
				}
				else {
					command+=" OR ";
				}
				command+="PayType="+POut.Long(payTypes[i]);
				if(i==payTypes.Count-1) {
					command+=")";
				}
			}
			command+=" ORDER BY PayDate";
//BEGIN NEW HOOK HERE PLEASE :) SOMETHING LIKE...
            object[] parameters = { command, payTypes };
            Plugins.HookAddCode(null, "Payments.GetForDeposit_beforequeryrun", parameters);
            command = (string)parameters[0];
//END NEW HOOK HERE PLEASE :)
            return Crud.PaymentCrud.SelectMany(command);
		}
Thanks again!
-Al

Re: HookAddCode request for deposit slip reconciliation

Posted: Wed Jul 11, 2012 8:05 pm
by jordansparks
Michael will be doing this as soon as he's done with bug fixes.

Re: HookAddCode request for deposit slip reconciliation

Posted: Mon Jul 16, 2012 11:34 am
by michael
The hook has been added. It will be available with version 12.3.3.