HookAddCode request for deposit slip reconciliation

This forum is for programmers who have questions about the source code.
Post Reply
alkhaef
Posts: 105
Joined: Fri Jul 02, 2010 10:37 am
Location: Los Angeles, CA

HookAddCode request for deposit slip reconciliation

Post by alkhaef » Wed Jun 20, 2012 7:04 pm

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
Al
Help! I've OD'ed on OD! :)

User avatar
jordansparks
Site Admin
Posts: 5746
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: HookAddCode request for deposit slip reconciliation

Post by jordansparks » Sat Jun 23, 2012 4:32 pm

Yes, that pattern looks good. We will implement.
Jordan Sparks, DMD
http://www.opendental.com

alkhaef
Posts: 105
Joined: Fri Jul 02, 2010 10:37 am
Location: Los Angeles, CA

Re: HookAddCode request for deposit slip reconciliation

Post by alkhaef » Fri Jun 29, 2012 2:50 pm

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
Al
Help! I've OD'ed on OD! :)

alkhaef
Posts: 105
Joined: Fri Jul 02, 2010 10:37 am
Location: Los Angeles, CA

Re: HookAddCode request for deposit slip reconciliation

Post by alkhaef » Mon Jul 09, 2012 10:25 pm

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
Al
Help! I've OD'ed on OD! :)

User avatar
jordansparks
Site Admin
Posts: 5746
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: HookAddCode request for deposit slip reconciliation

Post by jordansparks » Wed Jul 11, 2012 8:05 pm

Michael will be doing this as soon as he's done with bug fixes.
Jordan Sparks, DMD
http://www.opendental.com

michael
Posts: 38
Joined: Wed Aug 04, 2010 8:49 am

Re: HookAddCode request for deposit slip reconciliation

Post by michael » Mon Jul 16, 2012 11:34 am

The hook has been added. It will be available with version 12.3.3.

Post Reply