Author Topic: Applying a Payment to multiple invoices - Sample  (Read 6374 times)

Chris

  • God
  • Member
  • *****
  • Posts: 83
Applying a Payment to multiple invoices - Sample
« on: August 03, 2011, 08:54:29 AM »
#
# This script snippet demonstrates applying a received payment to multiple invoices.
# It assumes that the FileMaker solution has a 'join' table between the payment and the invoice(s), and from the
# join table the txn id of the invoice is accessible.
#
PCQB_RqNew( "ReceivePaymentAdd" )
#adding the remainder of the fields left out of this sample in the interest of brevity
#ensure to add them in your script.
#
#now apply this payment to the invoices..
#go to the related records that indicate which invoices the current FM payment is applied to
#from these records it will be necessary to have access to the invoice txn id and the amount applied to the invoice - design your fm schema accordingly
#
Go to Related Record.....
Go to Record/Request/Page[ First ]
#create the 'related records' to the request
Loop
 # use pcqb_rqaddrelatedrecord to add an application of the payment to a transaction/invoice
 PCQB_RqAddRelatedRecord( "AppliedToTxnAdd" )
 #
 # now add the transaction id for the invoice - this tells QB that this is the invoice to which we are applying part of the payment
 PCQB_RqAddFieldWithValue( "TxnId" ; INV_PMT::Invoice_TXNID )
 #note that INV_PMT::Invoice_TXNID is a place holder for your table/field holding the txnid for the invoice
 #
 # now add the payment amount - the part of the payment applied to the invoice
 PCQB_RqAddFieldWithValue( "PaymentAmount" : INV_PMT::Applied_Amount )
 #note that INV_PMT::Applied_Amount is a place holder for your table/field holding the amount of the current payment that is applied to the invoice
 #
 #very important! - close the related record in the request
 PCQB_RqCloseRelatedRecord
 #
 #and navigate to the next invoice to which the payment is to be applied
 Go to Record/Request/Page[ Next ; Exit After Last ]
End Loop
#
#


 

msbertrand

  • Member
  • *
  • Posts: 8
Re: Applying a Payment to multiple invoices - Sample
« Reply #1 on: October 17, 2011, 11:05:39 AM »
Hi Chris,

 

I have successfuly organized my FM application to add/update customers, add invoices... but unable to apply a payment.

 

I think my issue is relating to missing the TXNID, that I should 'pull' on InvoiceADD, but I am not sure yet.  Your help is appreciated,

 

Regards

Chris

  • God
  • Member
  • *****
  • Posts: 83
Re: Applying a Payment to multiple invoices - Sample
« Reply #2 on: October 20, 2011, 03:21:27 PM »
Yes,you can capture the TxnId of the invoice after posting it to QB....

#run the script to post the invoice
PCQB_RqExecute...
...
#after testing to ensure that the execute fn worked use the following to get the TxnID from the response...
PCQB_RsOpenFirstRecord
PCQB_RsGetFirstFieldValue( "TxnID" ) //save this result as the txnid for the invoice you just posted.



Chris

msbertrand

  • Member
  • *
  • Posts: 8
Re: Applying a Payment to multiple invoices - Sample
« Reply #3 on: October 21, 2011, 07:12:21 PM »
Tks Chris, I will try that.  I am new to your forum and did not see your message below.

Regards, help is appreciated. 

FYI, I sold 3 other systems that will use your plug-in, so this is time well invested...


msbertrand

  • Member
  • *
  • Posts: 8
Re: Applying a Payment to multiple invoices - Sample
« Reply #4 on: October 23, 2011, 04:35:34 PM »
Ok, kinda there, looks like I am not getting the 'open next record' properly, but will get there... I am getting the same TxnID for each invoice line items, so I am not handling the 'open next record properly.

I will try a bit harder.  Tks

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: Applying a Payment to multiple invoices - Sample
« Reply #5 on: October 24, 2011, 08:07:00 AM »
If you're trying to extract a Line Item's TxnID, you should be using PCQB_RsOpenFirstRelatedRecord for the first line, and PCQB_RsOpenNextRelatedRecord for all subsequent lines. PCQB_RsOpenNextRecord would be used only when you've issued a Query Request that returned multiple matching records.

HTH!

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852

msbertrand

  • Member
  • *
  • Posts: 8
Re: Applying a Payment to multiple invoices - Sample
« Reply #6 on: October 25, 2011, 05:57:15 AM »
Ok, understand that the TxnID is a unique ID for the entire invoice, with Geoff help and using the Xml response in data viewer I realized that I was not clear in my questions.

First, I am now able to see and get the TxnID, I thought it was a 'unique' number for each line of the invoice.  What I am trying to so is to pull a 'unique identifier' for 'each line' of my invoice, so I can apply payment to the appropriate line when doing so.

My system includes 'multiple' records for each invoices, therefore I believe I need the 'TxnLineID' also, and will need to understand how to use; open related record, open next related record.

Regards, I am getting somewhere with this now!

LoraineSmith56

  • Member
  • *
  • Posts: 1
Re: Applying a Payment to multiple invoices - Sample
« Reply #7 on: December 09, 2011, 11:48:21 PM »
Is it necessary for you maintain multiple records for each invoice, can't you avoid them?

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: Applying a Payment to multiple invoices - Sample
« Reply #8 on: December 12, 2011, 09:32:36 AM »
What do you mean?

If you're asking whether you need to specify the Invoices to which you want a Payment applied, the answer may be "no." Specifying an "IsAutoApply" element with the value "true" will apply the ReceivePaymentAdd's TotalAmount value to the specified Customer's Invoices starting from the oldest to the newest. You'll give up any way of overriding the "Remittance Advice" that may be on the check stub, but you gain the convenience of not having to track each Invoice's TxnID value.

Does that answer your question?

HTH!

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852

msbertrand

  • Member
  • *
  • Posts: 8
Re: Applying a Payment to multiple invoices - Sample
« Reply #9 on: April 13, 2012, 08:16:33 PM »
Wow... time fly by!

Tks for the response.  I have been pulled away for a big sale, finally came through...

I have left aside this project but also data entered all 'received payment', 'apply payment' and 'deposit payments'. 

My question was incorrect, first I need to receive payment prior to apply.  Do you have an example as well for this feature?

Much appreciated!

Regards

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: Applying a Payment to multiple invoices - Sample
« Reply #10 on: April 14, 2012, 01:26:38 PM »
Not sure I understand your question. You can send a ReceivePaymentAdd Request to QB without specifying its distribution. I haven't done this, but I'm pretty sure you can send a ReceivePaymentMod Request later and specify the distribution. Is that what you're trying to do?

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852

msbertrand

  • Member
  • *
  • Posts: 8
Re: Applying a Payment to multiple invoices - Sample
« Reply #11 on: April 23, 2012, 07:51:10 PM »
Well, in QB when you are receiving money from a customer you first 'receive a payment', than you 'apply' than you 'deposit' which consist in general of 3 operations.

Based on the previous script you sent me, I read and now understand it consist of '2' operations at once, which is 'receive' than 'apply'the received money, based on the criteria and script step included in the request.  If so than I answered my own question, and I will try a little harder.

In the event I need help to finish this, what would be the cost to have someone look my script, and what would be the accepted payment method?  My database is quite 'organized' and properly designed.  All I need is to 'push' the data to apply a payment, and deposit one or many received payment based on a simple query.

Regards,
Martin B


Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: Applying a Payment to multiple invoices - Sample
« Reply #12 on: April 24, 2012, 05:50:35 AM »
I'd be happy to talk with you about the remaining issues and how you'd like to see them resolved. A phone conversation usually works better than email because it takes less time to reach an unambiguous understanding of what needs to be done. Once the scope of work is identified, I'll let you know what it will cost to complete.

If all you need is a little technical support, I have a "by-the-minute" support agreement available.

My email is listed in my forum profile. Here's the rest of my contact info...

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852