开发者

How yo use MYOB in RAILS Application

Can anyone explain to integrate the MYOB in ra开发者_Python百科ils application


Integration to MYOB is not as simple as it might look.

In order to integrate to MYOB, you have to install the ODBC drivers, have the MYOB application installed and have direct access to the MYOB company file.

what is your integration requirements and purpose?

the solution we choose to go for is to build a desktop app that will facilitate the integration between the web app and MYOB.

hope this helps.


You can, however the only way to really do this is with the MYOB ODBC driver. The way this driver works is that it uses the Myobp.exe as a middle man between ODBC and the .MYO file.

The MYOB ODBC driver presents a SQL interface to MYOB, however there are some caveats. It's not a real SQL interface to MYOB. The data you can get in and out is closely matched by the Import and Export functions that MYOB presents in the program itself.

For getting data out, with the ODBC interface you can write SQL queries, and even some SQL type functions can be in these queries, but you may occasionally come across some things that will catch you out.

For getting data in, the ODBC driver presents uses a schema of tables with the prefix "Import_", with these tables all you can do is import data and they will not return things like the invoice number you just imported. This also means you cannot update existing entries the same way you would expect with a real SQL interface.

However, some data imports will result in an update of existing data if some of the fields match. My experience with MYOB and it's ODBC interface primarily deals with getting sales orders from a system I wrote entered into MYOB, so certain things can be done.

I did write my first version of this system in Rails, however you can't use the standard Rails models without adjusting the way they work because Rails is very opinionated on how it expects the database to act.

More recently I re-wrote it in Clojure and used handwritten queries.

For multiline inserts (for example the lines of an invoice) MYOB uses a transaction as a wrapper to indicate what lines should be on the one invoice.

So your best bet if you want to use Rails, would be to avoid using the Rails models, and perhaps write direct SQL queries and interface to that with your controllers and views.

I can't get to my old code right now, but it's something along the lines of this:

def create_myob_invoice( iso )
  # We can assume we have the job
  # Now, for each iso line, we add an invoice
  latest_invoice_number = Sale.find( :first, :order => 'InvoiceNumber DESC' ).InvoiceNumber.to_i
  if latest_invoice_number
    # We need to wrap it all in a transaction so MYOB knows they're all the one invoice
    MyobDatabase.transaction do
      iso.lines.each do |line|
        new_service_line = ImportServiceSale.new
        # Map iso fields to MYOB service sale fields
        # e.g. suff like:
        new_service_line.Description = "#{line.sDescription}"
        new_service_line.save
      end
    end
  end
end

You may also be able to find something to help over at: http://freelancing-gods.com/posts/talking_to_myob_with_ruby

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜