any chance of porting this module tp D7?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fuerst’s picture

Status: Active » Postponed

Not from my side - currently. I welcome any other party to work on that.

aacraig’s picture

FileSize
7.32 KB

Here is a port for D7. Not having used this module for D6, I've taken the liberty of simply rewriting it using standard D7 / UC3 practices.

This version certainly can be expanded and improved upon, (for instance, adding Rules integration and a pane on the order page) but you can create an invoice number that displays on the invoice tab, the client email and in the print version.

Further, the invoice number is incremental, resets at the beginning of the calendar year, and allows some basic configuration, such as prefix / suffix strings.

mandreato’s picture

I like #2, but it seems not to increase the invoice number.

Neo13’s picture

Nice work! I would like to ask if you plan to continue working on this? If yes could you please implement an option to set current year as prefix? Also rules integration and pane on the order page as mentiond would help.

Thanks.

aacraig’s picture

I would like to keep developing this, but hopefully after it's been accepted by the maintainer and turned into a proper release. This will allow us to have an issue queue to manage bug reports and feature requests.

Neo13’s picture

Maybe it would be good to post your module as a new module?

Neo13’s picture

It has been accepted, check this commit :)

Neo13’s picture

FileSize
4.49 KB

Hi,
I am enclosing my altered version. It uses basic customer templates from ubercart, not custom. It provides variable for invoice creation time to use in invoice template. Also it provides integration with Views module. Please feel free to use this and correct my errors.

Thank you!

tfranz’s picture

Hi Neo13,

thank you for all your great work!!
Your module does the job but i think it needs just some usability-changes ...

I tried your module with Ubercart 7.x 3.2 and can't find the "Create"-button or the invoice-number in the order-pages.

Visiting the page "/admin/store/99/create-invoice" does the job: i can create the invoice-number.
Shouldn't it be "/admin/store/orders/99/create-invoice" ?
BTW: i don't mind, but the "Order Details" seem not to use my custom template "uc-order--customer.tpl.php" in my custom theme.
And revisiting the page "create-invoice" should tell me that there is already an invoice-number. At least i can't create a second one for the same order-id. :-)

The "Date"-function seems not to work?! Visiting the page "admin/store/orders/99/edit" i get the following error:

Notice: Trying to get property of non-object in theme_uc_invoice_number() (Zeile 19 von /xyz/uc_invoice/uc_invoice.theme.inc)

Deleting line 19 "solves" the problem.

I'm using the following snippet to print the invoice-number in my custom "uc-order--customer.tpl.php":

$invoice = '';
$result = db_query('SELECT invoice_number FROM {uc_invoice} WHERE order_id = :oid', array(':oid' => $order->order_id)); 
foreach ($result as $row) {
  	 $invoice = $row->invoice_number; 
}
if ($invoice) print t('Invoice-Number: ').$invoice; 

Or is there a better way? Would be great if i could just use $order->uc_invoice ...

Thanks for your help,

Tobias

Neo13’s picture

Hi Tobias,

I am no programmer myself, so I just edited this module for my needs. There is no button for creating invoices, because I am generating them with rules.

I am using following variables to print invoice number and date - $invoice_number->invoice_number and $invoice_number->date in my own custom uc-order--customer.tpl.php and it works without any problems.

Best regards,
Tomas.

tfranz’s picture

"Rules" is a good idea – would you mind to export your rule, so i can have a look?

I changed line 19 of uc_invoice.theme.inc, and the error disappeared when viewing an order without invoice_number:

-   $invoice_date =  $invoice_number->date;
+   if ($invoice_number) $invoice_date =  $invoice_number->date;

I changed the script in my custom uc-order--customer.tpl.php and it indeed works:
if ($invoice_number->invoice_number) print '<br />Re-Nr. '.$invoice_number->invoice_number.'<br />Re-Date: '.date('d.m.Y',$invoice_number->date);

Thanks for your reply!

Neo13’s picture

Error with inovice date was just a notice when there is not any invoice, your fix is fine.

Here is the rule:

{ "rules_vygenerovanie_fakt_ry" : {
    "LABEL" : "Vygenerovanie faktúry",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "uc_invoice", "uc_order" ],
    "ON" : [ "uc_order_status_update" ],
    "IF" : [
      { "data_is" : { "data" : [ "updated_order:order-status" ], "value" : "processing" } },
      { "NOT data_is" : { "data" : [ "order:order-status" ], "value" : "in_checkout" } }
    ],
    "DO" : [ { "uc_invoice_action_generate_invoice" : { "order" : [ "order" ] } } ]
  }
}
tfranz’s picture

Perfect! ... for me: nothing else to do ... :-))
Thank you very much for sharing your work!!!

Neo13’s picture

FileSize
5.65 KB

I reworked it a little. Now invoice number does not depend on set variable but only on last invioce number in database which is in my opinon better because you can delete som invoices or alter them without problems. There is also set that invoices start with year, for exmaple 130001 would be the first invoice for this year. I was also trying to provide order pane but without luck.

remkovdz’s picture

Hi thanks a lot, this works just fine! However, where can I find the admin screen for this module?

Will you also be working on a way to create Credit Notes?

remkovdz’s picture

BTW, I think these add-ons would make this module perfect:
- Move the front-end functionality to the Invoice tab
- Show a button to easily create an invoice