title: how to maintain different counter in same table in ralis
body: <p>i created <code>invoice</code> model which has attributes <code>invoice_type</code> which takes value like 1 for tax_invoice and 2 for proforma_invoice. now i want to maintain separate unique increment counter in same table . how can i do this in rails 5 application.
  <br></p>
  <p>my current model code looks like this:</p>
  <pre><code> def set_invoice_number
     self.update_attribute(:invoice_number, 'abc/2020-21/' + id.to_s)
   end
  </code></pre>
  <p>Example :
  for type 1 invoice i want to maintain counter 1,2,3.... based on previous created type 1 invoice created.</p>
  <p>for type 2 invoice i want to maintain counter 1,2,3.... based on previous created type 2 invoice created.</p>
  <p>i want to append id in format like <code>'abc/2020-21/' + id.to_s</code> and save to invoice table in invoice_number attribute.</p>