Topic: Recurrent Sales Orders

I have looked at the template option, but don't think that will work.  We manufacture a product that all of our customers order annually.  In QB we'd been opening an old order and copying it so that we didn't have to enter every line item every year.  Is there any way to do that in FA with Sales Orders?  We're almost ready to go live with this, but have a few snags to iron out yet.  Thanks!

Re: Recurrent Sales Orders

Sounds like FA does exactly what you want.
make a template for the client from a sales order / invoice. Then Template delivery or invoice depending on your sales flow.

Do it like this
make a sales order, direct delivery, or direct invoice then--> open 'sales order inquiry' and set 'tmpl' checkbox

After that anytime you want to recreate it do Template Delivery or Template Invoice

You can also make it recurrent and it will remind you to create it at a years time but I dont like how the UI Select only has the order number in the drop down list and not the customer or branch so I usually don't do this since it takes time to reference.

3 (edited by jeskremer 04/22/2024 05:27:46 pm)

Re: Recurrent Sales Orders

Yes and no.  Every customer orders different items.  Every year, the customers adjust the quantities of their items.  If I use the template option, I would have to have a template for every customer that does repeat business for me rather than just being able to duplicate and edit a prior Sales Order.

As an example, we sell diplomas and graduation products.  They order annually, but every customer orders different styles, colors, etc.

Re: Recurrent Sales Orders

Ok So it does what you want but with the extra step "create template" and you want to copy a new order right away right?

the "Cart" of an order can be copied by adding the order # to the url like so

https://{your-url}/sales/sales_order_entry.php?NewDelivery=0 (this is the direct delivery url)
Change the 0 to the order with the cart you want to copy.

'NewDelivery' is for direct deliveries
'NewInvoice' is for direct invoice

If I wanted to make this a super easy single click I would add a copy link to the table of the page you like to look at past orders like the Customer Transaction Inquiry

Re: Recurrent Sales Orders

Ok so how I just did it is like this...

edit in file "/sales/inquiry/customer_inquiry.php"

add this copy function around the other link functions like "edit link"

function copy_link($row)
{
    global $page_nested;

    if ($page_nested)
        return '';
  if ($row['type'] == ST_CUSTDELIVERY)
    return pager_link(_('Copy Delivery'), "/sales/sales_order_entry.php?NewDelivery=" 
      .$row['order_'], ICON_DOC);
  else if ($row['type'] == ST_SALESINVOICE)
    return pager_link(_("Copy Invoice") ,
    "/sales/sales_order_entry.php?NewInvoice=". $row['order_'], ICON_DOC);
}

then add "array('insert'=>true, 'fun'=>'copy_link')," $cols array at the bottom of the page my finished $cols looks like this

$cols = array(
    _("Type") => array('fun'=>'systype_name', 'ord'=>''),
    _("#") => array('fun'=>'trans_view', 'ord'=>'', 'align'=>'right'),
    _("Order") => array('fun'=>'order_view', 'align'=>'right'), 
    _("Reference"), 
    _("Date") => array('name'=>'tran_date', 'type'=>'date', 'ord'=>'desc'),
    _("Due Date") => array('type'=>'date', 'fun'=>'due_date'),
    _("Customer") => array('ord'=>''), 
    _("Branch") => array('ord'=>''), 
    _("Currency") => array('align'=>'center'),
    _("Amount") => array('align'=>'right', 'fun'=>'fmt_amount'), 
    _("Balance") => array('align'=>'right', 'type'=>'amount'),
        array('insert'=>true, 'fun'=>'gl_view'),
        array('insert'=>true, 'fun'=>'edit_link'),
        array('insert'=>true, 'fun'=>'copy_link'),
        array('insert'=>true, 'fun'=>'credit_link'),
        array('insert'=>true, 'fun'=>'prt_link')
    );

@apmuthu and @joe
this is a simple change and would probably be handy for many people. I would consider adding it to core if you dont think it clutters the table to much.

Re: Recurrent Sales Orders

Oh, awesome.  Thank you!  I was getting ready to find a programmer.  I'll give it a try.

Re: Recurrent Sales Orders

@joe: appears to be a useful feature. Care to place it in the core with an toggle flag in the per company options?

Re: Recurrent Sales Orders

Will do.

Joe

Re: Recurrent Sales Orders

This has been implemented as a new feature. Pushed to stable repo. Not needed to be an extra flag in company setup. It will be official from minor 2.4.19.

You can download the files /sales/inquiry/customer_inquiry.php and /lang/new_language_template/empty.po and replace on your server and it will work immediately.

Thanks @trafficpest for proposing this. Very good!

Joe

Re: Recurrent Sales Orders

I did try this and it works great for Direct Invoice.  What would you recommend adjusting to replicate a Sales Order?

Re: Recurrent Sales Orders

It will auto create a new sales order for you.
It works on delivery or invoice both will make an new order for you.
Im guessing you get a order and schedule a delivery?

12 (edited by jeskremer 05/08/2024 03:03:59 pm)

Re: Recurrent Sales Orders

Yes, that is correct.  We get an order, schedule delivery, and then invoice.  Thus, the need to replicate the Sales Order end of things first.

I have been using this for a little bit now, but still can't find a duplicate button for Sales Orders when I query them.  There is one when searching customer transactions for the Sales Invoice and Delivery Note, but nothing next to Sales Order.

13 (edited by trafficpest 05/15/2024 05:28:59 pm)

Re: Recurrent Sales Orders

CAUTION
I just want to give a heads up for people using this.

If you have a client that you have updated the mailing address and you use this copy invoice or delivery. IT WILL NOT HAVE THE NEW ADDRESS. It will copy the mailing address from the prior order so, take caution.

While the order is open you can press F3 to open the branch & verify the current mailing address on file to be safe

Otherwise I have been using daily with no other notes.

Re: Recurrent Sales Orders

I also noticed that it does not create an actual reference number.  It just calls it "auto".

Re: Recurrent Sales Orders

That should only be on direct invoice the direct delivery gets an auto for ref but the invoice gets the next number.
That is normal behavior when you skip the delivery step. if you copy the delivery it will get a ref number than invoice against that invoice.

Re: Recurrent Sales Orders

I was doing some looking at the code tonight and can't quite figure it out.  Obviously with this code posted previously by @trafficpest, we're copying an order from the "Customer Transactions" tab.

This is working great, however, we have one little hiccup.  I was trying to see if I could do the following from the Sales Order Inquiry screen or Customers tab:

Copy a Sales Order so that it gets an actual unique reference number instead of auto.

What you are doing now works great, except that, we are really close to getting a software called ShipSync to connect to ShipStation and post tracking back to Front Accounting.  The problem?  It does need a unique reference number or it won't work.

It is working great on unique and new orders, but if we start copying orders and only getting auto, it won't work.

We have dumped Quick Books for your software and are really excited to get this fully implemented in our business.  I think there is a HUGE market for Open Source programs like this.  I'd even be willing to pay someone a few bucks to help fine tune the end product for us.

Re: Recurrent Sales Orders

sorry to take so long on this just saw this

this one is a little more involved so do this.
if you need I can make a branch of the repo to see the changes, so let me know.

in 'sales/inquiry/sales_orders_view.php' do much like you did before. create a copy function and paste it near the edit function about line 115 in the page

function copy_link($row) 
{
    global $page_nested;

  return pager_link(_("Copy Order") ,
      "/sales/sales_order_entry.php?CopyOrder=". $row['order_no'], ICON_DOC); 
}

then in that same file call it in the salesorder if statement around line 330 at the end of the file. (you could add it to other vues on the page if desired. the changed elseif should look like this. NOTE: it has the closing bracket from the last elseif above.

} elseif ($trans_type == ST_SALESORDER) {
     array_append($cols,array(
            _("Tmpl") => array('insert'=>true, 'fun'=>'tmpl_checkbox'),
                    array('insert'=>true, 'fun'=>'edit_link'),
                    array('insert'=>true, 'fun'=>'copy_link'),
                    array('insert'=>true, 'fun'=>'dispatch_link'),
                    array('insert'=>true, 'fun'=>'prt_link')));
};

Now the problem is the cart doesn't support copying orders like it did on deliveries/invoices. so we will add it.
in file 'sales/sales_order_entry.php' in the top array about line 36 add a CopyOrder type. the finished array should look like this.

    array(    'NewOrder' => 'SA_SALESORDER',
            'CopyOrder' => 'SA_SALESORDER',
            'ModifyOrderNumber' => 'SA_SALESORDER',
            'AddedID' => 'SA_SALESORDER',
            'UpdatedID' => 'SA_SALESORDER',
            'NewQuotation' => 'SA_SALESQUOTE',
            'ModifyQuotationNumber' => 'SA_SALESQUOTE',
            'NewQuoteToSalesOrder' => 'SA_SALESQUOTE',
            'AddedQU' => 'SA_SALESQUOTE',
            'UpdatedQU' => 'SA_SALESQUOTE',
            'NewDelivery' => 'SA_SALESDELIVERY',
            'AddedDN' => 'SA_SALESDELIVERY', 
            'NewInvoice' => 'SA_SALESINVOICE',
            'AddedDI' => 'SA_SALESINVOICE'
            )

in the same file the function create_cart() needs to be modified to allow this new 'CopyOrder' type to pass as a template. change the function to look like this

function create_cart($type, $trans_no)
{ 
    global $Refs, $SysPrefs;

    if (!$SysPrefs->db_ok) // create_cart is called before page() where the check is done
        return;

    processing_start();

    if (isset($_GET['NewQuoteToSalesOrder']))
    {
        $trans_no = $_GET['NewQuoteToSalesOrder'];
        $doc = new Cart(ST_SALESQUOTE, $trans_no, true);
        $doc->Comments = _("Sales Quotation") . " # " . $trans_no;
        $_SESSION['Items'] = $doc;
    }    
  elseif(($type != ST_SALESORDER || isset($_GET['CopyOrder'])) && $type != ST_SALESQUOTE && $trans_no != 0) { // this is template

        $doc = new Cart(ST_SALESORDER, array($trans_no));
        $doc->trans_type = $type;
        $doc->trans_no = 0;
        $doc->document_date = new_doc_date();
        if ($type == ST_SALESINVOICE) {
            $doc->due_date = get_invoice_duedate($doc->payment, $doc->document_date);
            $doc->pos = get_sales_point(user_pos());
        } else
            $doc->due_date = $doc->document_date;
        $doc->reference = $Refs->get_next($doc->trans_type, null, array('date' => Today()));
        //$doc->Comments='';
        foreach($doc->line_items as $line_no => $line) {
            $doc->line_items[$line_no]->qty_done = 0;
        }
        $_SESSION['Items'] = $doc;
    } else
        $_SESSION['Items'] = new Cart($type, array($trans_no));
    copy_from_cart();
}

@apmuthu and @joe
here is an idea though I dont think it should be in core. People can already template an order and copy invoices and deliveries. if you copy or direct deliver you will get a delivery ref number and that could be used for an api unique ID. Or if you have to use an order could you not use the order# already?

Re: Recurrent Sales Orders

Thank you!

Re: Recurrent Sales Orders

I did get all of this code inputted, however, when I copy a Sales Order, I get the following yellow caution bar at the top:

Missing refline context data: 'date'

In the Reference Number box, I also get this: YYYY-0001

Re: Recurrent Sales Orders

Maybe it doesn't support date in the transaction reference?
I already had my ref setup without a date. So I didn't get that, I only use numbers.
If you want to do that go here in the app.
Setup->Transaction References

then change sales order to '{00001}'

I would like to look into the date thing but don't have the time right now

Re: Recurrent Sales Orders

Interesting.  I haven't received the date error message lately, but now I don't get it copying at all, but rather, showing a page with no data and a "Back" link.

I did try your suggestion of changing the Ref number.  That didn't seem to help.  I still get the "Back" link with no new sales order when I click the "Copy" button.