101

(3 replies, posted in Banking and General Ledger)

I found the quick entries for supplier invoices, they are, of all places, under supplier invoices.

Hi,

Relating to quick entries:

if I pay a phone bill the long way, as I understand it I would go under purchases=>supplier invoices to do so.

If I want to setup a quick entry for this; according to the wiki page, I would create a bank payment instead of a supplier invoice.  However, at the bottom of the wiki page is a link to a screen shot where the quick entry for a phone payment shows the entry type as supplier invoice, not bank payment. 

It seems to me that the quick entry should be a supplier invoice and not a bank payment, since that is how I would enter it the long way, but when I set it so, then go under "banking and general ledger=>payments=>pay to quick entry" I cannot select a supplier invoice type.

On the wiki, which is the correct information; the image or the text?  And is there a reason why I shouldn't set a quick entry for a phone bill as a supplier invoice?

apmuthu wrote:

Hence currently, no code change is required except for setting the last parameter as false in reports that need to be emailed to multiple entities!

Either I am misunderstanding what this means, or this is not the case.

I think this means that in rep107.php if I change this line:

$contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true);

to this:

$contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], false);

the mail should send to both contacts.  I had actually tried this before, based on the content of one of the posts you pointed me at earlier.  If I put the sales/includes/db/branches_db.inc file back to how it was originally and change true to false as described above, it throws this error on the screen when I send an email:

You have no email contact defined for this type of document for 'Computerisms'.

If I am misunderstanding, can you please clarify?

tm wrote:

I would suggest reorganising that bit to first create the message and then loop over the recipients while adding the "To" headers.

(CC is probably best avoided here, as it implies "FYI" rather than "Here's a message for you. Please do something with it". So, who is the "real" recipient, and who gets CC'ed?)

While multiple To headers would work just fine, CC would actually be more appropriate in most of my cases for the exact reason you state.  Most of my customers are small businesses, so I send the invoice to the accounting person/department, who need to do something about it, but need to send a copy of the invoice to the manager/owner so they are informed.

Maybe having a CC check box in the contacts section or something would be cool.

But really, To vs CC is minutia when compared to getting every thing bundled into a single mail...

while it is unfortunate there is a bug in the code, I can't say how happy I am to know that it wasn't stupid-user syndrome.  I am also super-happy that I was able to find it and point it out.  Thanks again for your guidance on that apmuthu.

I have two follow-up questions:

1.  I have tried commenting each part(s) of the stanza in the get_branch_contacts function but seems I have to comment the whole thing for email to work.  Can I make a change there to fix this properly, or am I to understand from your reply that the problem is more involved than that?

2.  There is a CC function in class.mail.inc, but I don't find any way to use it.  it seems when a mail is sent to multiple contacts, it make a separate mail for each individual, such that nobody can see if the other recipients got it.  Can this be adjusted?  I have one client who says I need to send by snailmail if it can't, and I am not sure if I remember how to use a stamp wink

I figured out what this broke, by commenting the entire block, it now sends mail to every contact.  when a new customer is added, ti creates a contact in the customer and the branch, and now invoices mail to both.  Still; easier at this point to remove all the contacts I dont' want than to not having it mail to all the contacts I do want...

Thank you *very* much for staying with me on this.  been busy making money so haven't had time to work on this the last couple days.

apmuthu wrote:

I am not clear as to how you populated your contact data.

I am populating my contacts through the web interface.  my primary methodology is using the procedure defined in this link:

http://www.kvcodes.com/2014/10/send-invoice-multiple-recipient-frontaccounting/

Whch was kindly provided early in my investigation of this problem.  I have also consulted the wiki pages on the topic and based on my understanding of branch contacts overriding customer contacts and the invoice vs general type of contact, I have spent many hours trying various combinations of stuff; at first trying to get it working as per the instructions, and then just to try it all since following the instructions weren't working.  I think at this point I have tried everything that the program will let me do.

apmuthu wrote:

All email addresses must reside in the #_crm_persons table. All many-to-many linkages are in the #_crm_contacts table where the entity_id will indicate the source table's id (customer => debtor_master table, branch => cust_branch table, supplier, etc). The person_id refers to the id of the crm_persons table. The ERD is self-explanatory.

Now please check your relevant records in the crm_contacts, crm_persons, cust_branch and debtors_master tables and list the sequence you undertook to populate them.

Try to trace the source sql for the $contactData in the pdf_report.inc file.

Manually execute the SELECT sql obtained above and see what gives.

Everything about the database is within my skill set and understanding.  Tracing the code that does the queries... well, I am learning.  probably I did this the longest hardest way.

I started by examining the tables in mysql; the first thing I noted is I don't have a #_ prefix.  not sure if that matters. I found that both contacts are listed in crm_persons, and it looks to me like crm_contacts has everything linked up correctly.  Next I logged all mysql queries and sent my invoice, and found only one query checking the crm_contacts, and I used that query to figure out there is a function called get_branch_contacts in a file sales/includes/db/branches_db.inc.  From there, I find reporting/rep103.php and reporting/rep107 through rep113 call this function, and thanks to the handy little title at the top of each file (thanks Joe Hunt), 107 is the one to do with invoices.

Phew.

pdf_report uses the $contacts variable to populate $contactData.  the $contacts variable is populated by this line in rep107.php:

$contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true);

so, dig out the ol' print_r; put one before this line to find the values of $branch, put one after to find the values of $contacts.  $branch correctly dumps the company, $contacts dumps only one contact.  hrm...

On to branches_db.inc.  Here I dump the $sql statement, find the string "&TB_PREF&" in the variable twice.  Not sure why they are there, but clearly they are not being passed to mysql else there would be no contacts.  remove those strings and run the sql statement manually and it returns all contacts.  dump the $results a line or three down, and it returns 2 arrays of data.  Hmm, so the database is being queried for all contacts and is returning them. 

In the next stanza there is an interesting comment:

// select first available contact in $defs order

Sooooo... selecting only the first contact is by design?  Seems to describe what is happening.  Playing with that for a bit, I ended up commenting the whole block starting at line 203 that reads:

if ($results && $default) {

And now when I send the email, it lists at the top of the page that it is sending to both contacts, and even more importantly, email is received at both addresses.  /me does the genius dance...

Surely that block of code is there for a reason, what am I wrecking by commenting it?  it seems like it is making sure it is only sending to contacts that are either invoice or general type?  If that is the case, then I consider this solved, but it may not be a suitable solution for others.

PS, I found this in tmp/errors.log, I produced it by adding a contact to the customer, however the contact did add, and as far as I can tell it is in the database correctly.

[07-Feb-2015 22:35:44 UTC] 0:bob:simple_crud_class.inc:116: key() expects parameter 1 to be array, string given

Anyway, thank you very very much apmuthu, I really appreciate your guidance.

Thank you again for your insights, and for the breakdown.  I understand the words, now to see if I can apply the meaning.

I have my test situation where I have my company added as a customer, with one contact being my real info, and another contact going to my hotmail address.  I have tried putting contacts in both the branch and the customer, but as of now I have them just in the branch.

The email class' methods to(), cc() and bcc() are the ones that add email addresses to the respectively named class properties that get into the mail header before being sent.

If I understand this correctly, then I should be able to capture all email addresses that FA is adding from within these functions.

In class.mail.inc I adjust the to() function and the cc() function:

    function to($mail)
    {
        $this->to[] = $mail;
$tooutput = print_r($this->to, true);
file_put_contents('/var/www/fa.computerisms.ca/tmp/tooutput.txt', $tooutput, FILE_APPEND);

    }
    function cc($mail)
    {
        $this->cc[] = $mail;
$ccoutput = print_r($this->cc, true);
file_put_contents('/var/www/fa.computerisms.ca/tmp/ccoutput.txt', $ccoutput, FILE_APPEND);
    }

I send an invoice, and tail -f the tooutput.txt and the ccoutput.txt files and get:

Array
(
    [0] => Bob Miller <bob@computerisms.ca>
)

so it is reasonable to assume that FA is not picking up the 2nd contact?  I am not a practised coder, so please point out any fallacies in my assumptions.

If I set one contact to invoice and the other to general, the email goes to the one set as invoice.  If I have them set the same, it goes to the first contact.  regardless, only one address ever shows up in the output files I have set up.

Therefore the calling wrapper functions/methods must properly populate the email addresses into the appropriate array argument's to be passed on to the actuator functions in the email class.

Given my above test, I am working on the assumption that the wrapper function is not populating the addresses.  In pdf_report.inc at line 976 I find a line  if ($email == 1), and it seems to my untrained eye this is the block that deals with obtaining the addresses to deliver to and crafting the mail.  I see a line "foreach($contactData as $contact)" which makes me think it should be looping through more than one contact if it exists, but dumping the  $contactData and $contact variables only adds details on one contact to the output file, not the 2nd.  If I dump the $to variable, only one address shows up in my dump file, but I expect two.

I am not sure yet how to work backwards from here.  based on what I have read, I am looking through the rep files, but I don't have any insights to share yet.

I am also still thinking that if this code is working correctly for others, the problem must be in my environment.  But what kind of setting could prevent the code from picking up the 2nd bit of data, maybe an encoding issue in the database?  am I going about this all wrong looking in the code for the answer to the problem?

109

(3 replies, posted in Accounts Receivable)

Aha.  thank you.

I guess this won't change the existing invoice, though, presumably I will have to void that one and make another?

Thank you so much for your reply.

apmuthu wrote:

See if the function that gets the email addresses returns a scalar / one address only.

Okay, so I am not 1000% sure exactly which function that is.  I am still swimming in code. 

But; in mail.class.inc, the email address also shows as a single element in an array, both in the to($mail) function at the top, and in the foreach at the bottom.  so by my understanding of the term, not a scalar

in pdf_report.inc there is a function called End, in it I *think* it is supposed to loop through each contact.  I dumped a bunch of stuff in here, but none of it returned anything from my secondary contacts, only from the one.

Poking around some more, in rep103, the branch contacts show all the components of one contact, but do not print anything about the 2nd contact.

Not sure if that is what you mean?  but I will keep poking at the code, maybe an epiphany is waiting to happen...

apmuthu wrote:

Also see if your sys_prefs table has this entry.

Check:

| grn_clearing_act           | glsetup.purchase  | varchar  |     15 | 0                                    |
| bcc_email                  | setup.company     | varchar  |    100 |                                      |
+----------------------------+-------------------+----------+--------+--------------------------------------+
52 rows in set (0.00 sec)

I have also verified that the bcc function works.


apmuthu wrote:

Also check if this post is relevant to this issue.

This post refers to complete failure to send mail, where as I can reliably send.  I checked to make sure I do not have suhosin installed, and I don't.  But I find it interesting that he messed with the format of his headers, I need to stick that idea in my back pocket.  But I don't think the failure to send is due to malformed headers, as I still have no indication that there is a 2nd address to malform them with.


apmuthu wrote:

You may have to manually hard code in 2 or more email addresses into the routine that emails out and see if the emails sent actually get through php in the first place.

I am guessing by this you are suggesting I follow the example in the above post?  shouldn't I verify that FA is actually finding two addresses to send to before I figure out if it can send them?  and doesn't the fact that I can send to single contacts indicate that php is successfully sending mail?  maybe I am missing your point, I am pretty good at overlooking the obvious...


apmuthu wrote:

Some issues discussed in this post may be relevant as well.

The fixes suggested in this post already appear to be implemented in the files on my installation. 

Thank you again for taking the time to respond, I truly appreciate it

111

(3 replies, posted in Accounts Receivable)

Hi,

I sent an invoice, and then was informed that they are a tax exempt organization.  I do not find a way to change the tax group, is this possible, or do I have to create them as a new customer?

Under your sales tab, go to sales order inquiry.  Your invoice will be listed as the last one.  put the check mark in the tmpl column.  From there you can go back under the sales tab to recurrent invoices and when you set up the recurring transaction, the template will be listed.

I am sorry to resurrect an old topic, but this starts to turn into a sliver in my toe. 

I never did solve the problem at the end of last time I worked on it, instead I was just manually saving the invoices and mailing them.  But now a good chunk of my customers are loaded into the program and I simply don't have enough RAM in my brain to keep track of who needs multiple recipients. 

I have been through the diagram provided by kvvaradha (and thank you for providing that) multiple times across multiple customer additions now.  The only discrepancy between that diagram and what I enter is that I cannot enter just an email address, I must also enter a name and reference.  But in no customer where two contacts are setup does it ever send two emails.

This afternoon I started by verifying all my previous observations and ensuring that any changes I have made are not the culprit.  turns out all my changes are limited to the doctext.inc and header2.inc files.  I also upgrade from 2.3.21 to 2.3.22.  So my environment is clean, and the problem is still that FA is sending only one mail to one recipient.

I am running FA on a debian server with exim4.  Exim4 is configured to use my main mail server as a smarthost.  One observation I can add to previous ones is that the php mail() function uses sendmail, which in this case is linked to exim4, which in turn creates an smtp session to may mail server.  I was unable to find a way to get mail() to send via another route, nor from here was I able to find any proof that FA was sending to multiple recipients.

I curse myself that after all my time playing with linux servers I haven't ever become truly proficient in php.  but I got to poking around, and I believe that class.mail.inc and pdf_report.inc are the two files, or at least two of the files, that are responsible for determining the recipients and mailing to them.

I am not clear if the secondary recipients of the mail are supposed to be cc'd, or if an individual mail is supposed to be created for each recipient.  I put a print_r statement in the foreach loop at the bottom of class.mail.inc; $this->header shows no CC entry, and $this->to contains only one entry in the array.  If I put my print_r statement in pdf_report.inc at around line 1000, $this->contactData also only shows one entry in the array.  I have dumped several of the variables but I can find nothing that  indicates FA is finding a 2nd recipient.

Maybe I am not checking the right variables, or in the right place, but this seems to confirm my suspicion that FA is indeed only sending one email to one recipient.  But I am still no closer to figuring out how to fix it.  If this is working for everyone else, then I must have a configuration error in my apache or php or something, but what could it be?  As before, suggestions would be greatly appreciated....

acknowledged, thank you for pointing me at that.  I hadn't really investigated that part, just thought I would add it in case it was relevant, which I see now it wasn't....

By good fortune I manage a couple mail servers, and I have been rootin' through the logs trying to figure out what exactly is up with how FA deals with mail.  But as of now I can't decide if I am more confused or less confused than I was.  I am pretty comfortable with email, but I am not sure what this php mailer is up too...

First, I have found that while the from header of delivered mails contains my address, the actual sender of the mail is the username that apache is running under.  by way of example, I use mpm-itk on my server and run frontaccounting under user fa, so bounces go to fa@domain.tld instead of my mail address.

I also found that you cannot use multiple email addresses in one field, whether separated by semi colon or comma.  FA will say that it is sent, and in the strictest sense that is true, however, the mail will be bounced back as malformed.  Though I did find it quite consistently successfully delivered the mail to the first recipient in the list when using semi colons.  Having dealt with emailing from Perl scripts, I suppose this isn't too big of a surprise.

I found consistently that when multiple contacts exist within a branch, regardless if they all have the same contact category, only one of the contacts will have mail sent to it.  I found consistently the same with customer contacts.  I found that deleting all contacts from the branch and using only customer contacts was the same as deleting all contacts from the customer and using only contacts from the branch.  I found that setting a contact's contact category to invoice will cause it to be prioritized over general contact category in both cases.

I can demonstrate through smtp sessions on the recipient mail server and through the exim logs on the server where front accounting resides that no attempt is made to deliver mail to the 2nd recipient.  it is not that the mail fails to send, it is that it is not sent, at least as far as I can tell.

I have found that while only one contact will be sent too, the auto-BCC function works perfectly. 

I think I have tried all combinations of contact category, branch contact, customer contact, and under no circumstance can I get FA to send two emails at the same time.  At this point, the only successful way I have sent one invoice to multiple recipients is to save the invoice as a pdf and attach it manually.

Any suggestions as to further things I could try would be most welcome.

BTW; when a mail gets sent, it starts with "Dear ," and in my experimenting it gets populated with the last name of the recipient.  For example, if I populate a contact with first name Bob and last name Miller, the mail will be addressed Dear Miller, .  Not sure if this is the intended design, or if this indicates I have a misconfiguration somewhere; and if I do have a misconfiguration, perhaps it is related to my inability to send multiple mail?

Hi tm,

Thank you for your response.

In the testing I have been doing, it starts to look like separating the email addresses with a comma isn't actually working as expected.  I have been phoning around to find who has gotten invoices and who hasn't, and it seems the mail does not actually send when the email field contains comma separated values.

hence why I am working on getting this thing figured today....

kvvaradha:

Thank you for your instructions.

I have set up another customer following the 8 steps you outlined.  I think your instructions are clear and I (think I) understand what it supposed to happen. 

Now that it is setup, when I look under customer branches, select the customer, I see one item in the list with a short name, tax group, etc., and a single email address.  I then click the edit icon, select the contacts tab, and I can see both contacts, each with their individual email, exactly as the picture you setup shows it should be.  Then I go to customer reports to email an invoice, and it gets sent only to the first contact. 

Do I need to delete the contacts under manage customers or something to make this work?

Thanks for your reply.

when I added the 2nd contact to the branch, I had done what you did up to step 5.  After that, I selected the existing contact, cloned it, and then changed the email address.  that did give me a list of two contacts, each with different email addresses.  But it still only sent to one address.

I have deleted the clone and followed your instructions; unfortnately I have no more invoices to send them right now, but I will test this in the near future...

Hello,

I read the wiki, but I am confused about emailing contacts.  I have customers where the invoice needs to be sent to more than one individual.  So far I have been able to work around that by simply entering a comma-separated list of email addresses into a single contact.  Today, I discovered I have a customer whos domain name is too long to enter two addresses into one field.

So I created a 2nd contact and set the assignment to general.  I understood the wiki to mean that invoices would be sent to all contacts with assignment of general or invoice.  But when I create a direct invoice and email it, it only sends to the 2nd contact's address.  So I added the 2nd contact in the branch, then  I did another invoice, but it also sends to only the 2nd contact.

Clearly I am missing something, but I don't understand what it is.  Any chance someone can enlighten me?

120

(13 replies, posted in Accounts Payable)

awesome sauce, found it.  Thank you very much...

121

(13 replies, posted in Accounts Payable)

Hi,

I apologize if I am just being a little bit dense, but I am a touch confused between the terminology in the wiki and forums and the actual FA interface, and I want to make sure I understand before I start dabbling.  Specifically from the wiki entry:

>>Best way to pay utility bill / rent:
>>Setup Supplier, use GL Items for it

I see "GL Items" referred to several times.  When I navigate to Purchases=>suppliers, I can find nothing called "* Items", nor can I find a field labeled GL Items anywhere else in FA.  However, I see Accounts Payable Account:, Purchase Account: and Purchase Discount Account: listed under Accounts.  Is this what is being referred too?  For example, to pay my phone bill, I should enter my telco as a supplier, leave the AP account as is, and change the purchase account to 5780 or whatever my telephone account in the GL is?

>>Preset the Cost Account in Supplier setup

Again, I do not find any term "cost account" when I look through the details for a supplier I have created.  Does this refer to the Purchase Account under the accounts section?

>>Can also raise an order on supplier for service (Create Service Item and set it as a Service)

From what I have been reading, I believe I am obligated to create a Service Item (called "one month of telephone service" or similar) in order to create the vendor invoice.  Do I understand this correctly, or can the phone bill be entered without actually creating a service item?