Answers.Body: <p>We found a solution.</p>
  <p>CiviCRM will create a zero invoice (as indicated by @Ramesh in the comments).</p>
  <p>But we found that webform_civicrm doesn't create a Civi contribution (and hence no invoice) if totalContribution evaluates as true (not 0).</p>
  <p>To fix it my dev changed the file includes/wf_crm_webform_postprocess.inc
  In webform_civicrm version: 7.x-5.8 it's at line 165.</p>
  <p>Changed this</p>
  <blockquote>
  <pre><code>if (empty($this-&gt;ent['contribution'][1]['id']) &amp;&amp; **$this-&gt;totalContribution**) {
    $this-&gt;createDeferredPayment();
  }
  </code></pre>
  <p>to this</p>
  <pre><code>if (empty($this-&gt;ent['contribution'][1]['id']) &amp;&amp; **count($this-&gt;line_items**)) {
    $this-&gt;createDeferredPayment();
  }
  </code></pre>
  </blockquote>
  <p>$this-&gt;totalContribution refers to the total amount after adding up the line items (when contribution amount is used it serves as a line item)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-07T15:21:09.017Z
Answers.LastActivityDate: 2022-07-07T15:21:09.017Z
Answers.UserDisplayName: Davy Ivins
Answers.Body: <p>when you register for an Event using discount code - even the amount is Zero CiviCRM will create an Invoice and it will send a email to the member</p>
  <p>If this behavior is not working in your version then try upgrading to the latest version</p>
  <p>login to <a href="https://dmaster.demo.civicrm.org/" rel="nofollow noreferrer">https://dmaster.demo.civicrm.org/</a>
  username/password: demo/demo</p>
  <p>I have created a example - which has an Invoice too</p>
  <p>I guess this helps !!!</p>
  <p>Thanks</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-21T19:16:35.620Z
Answers.Text: Thanks Ramesh - good to know that Civi should generate a zero invoice. I can't fully check the functionality in the demo site because we are using webform for the registration and I wonder if that may have an impact? We've also edited the default Contributions - Invoice message template so perhaps we changed something by mistake there.
Answers.UserDisplayName: Davy Ivins
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-21T19:39:32.693Z
Answers.Text: @DavyIvins try to register the event using CiviCRM link without webform - where you can test the functionality first then once you know CiviCRM is working correctly then test with Drupal webform - If you need help feel free to ask me - Thanks
Answers.UserDisplayName: Ramesh - ARTECH Consultancy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-07T15:54:47.330Z
Answers.Text: Hi Ramesh - we found the cause of the missing invoice. Posted it as an answer. Thanks for your help
Answers.UserDisplayName: Davy Ivins
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-20T13:11:35.920Z
Answers.LastActivityDate: 2022-06-20T13:11:35.920Z
Answers.UserDisplayName: Ramesh - ARTECH Consultancy
Body: <p>Our event uses webform for registrations.
  Some delegates receive 100% discounts that reduces the cost to zero.</p>
  <p>In these cases CiviCRM does not create or send an invoice - is this standard, and is there a way to force an invoice even if the amount payable is zero?</p>
  <p>Using latest D7 and current Civi.</p>
  
Tags: <civievent><civicontribute><webform-civicrm>
Title: How to create Event Invoice with zero amount owing
ThreadText: # How to create Event Invoice with zero amount owing
  
  (Asked by: username_0 on 2022-06-20)
  
  Our event uses webform for registrations.
  Some delegates receive 100% discounts that reduces the cost to zero.
  
  In these cases CiviCRM does not create or send an invoice - is this standard, and is there a way to force an invoice even if the amount payable is zero?
  
  Using latest D7 and current Civi.
  
  **Tags:** civievent, civicontribute, webform-civicrm
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2022-07-07. Score: 1 | Accepted answer
  
  We found a solution.
  
  CiviCRM will create a zero invoice (as indicated by @username_1 in the comments).
  
  But we found that webform\_civicrm doesn't create a Civi contribution (and hence no invoice) if totalContribution evaluates as true (not 0).
  
  To fix it my dev changed the file includes/wf\_crm\_webform\_postprocess.inc
  In webform\_civicrm version: 7.x-5.8 it's at line 165.
  
  Changed this
  
  > ```
  > if (empty($this->ent['contribution'][1]['id']) && **$this->totalContribution**) {
  >   $this->createDeferredPayment();
  > }
  >
  > ```
  >
  > to this
  >
  > ```
  > if (empty($this->ent['contribution'][1]['id']) && **count($this->line_items**)) {
  >   $this->createDeferredPayment();
  > }
  >
  > ```
  
  $this->totalContribution refers to the total amount after adding up the line items (when contribution amount is used it serves as a line item)
  
  
  ---
  
  ### Answer by username_1 on 2022-06-20. Score: 0
  
  when you register for an Event using discount code - even the amount is Zero CiviCRM will create an Invoice and it will send a email to the member
  
  If this behavior is not working in your version then try upgrading to the latest version
  
  login to <https://dmaster.demo.civicrm.org/>
  username/password: demo/demo
  
  I have created a example - which has an Invoice too
  
  I guess this helps !!!
  
  Thanks
  
  > **Comments:**
  > **username_0**: Thanks username_1 - good to know that Civi should generate a zero invoice. I can't fully check the functionality in the demo site because we are using webform for the registration and I wonder if that may have an impact? We've also edited the default Contributions - Invoice message template so perhaps we changed something by mistake there.  
  > **username_1**: @username_0 try to register the event using CiviCRM link without webform - where you can test the functionality first then once you know CiviCRM is working correctly then test with Drupal webform - If you need help feel free to ask me - Thanks  
  > **username_0**: Hi username_1 - we found the cause of the missing invoice. Posted it as an answer. Thanks for your help  
  
  ---
  
  