Create Extension for Microsoft Office Accounting

Dot Net team at Maven Infosoft has created many Extensions for Microsoft Office Accounting. Here you will find how to create Microsoft Office Accounting extension.

Create Application Extension for Microsoft Office Accounting:

You can create your own application which can be integrated to your accounting company. You need to follow given steps for creating New Application which can be integrated to MOA.

Assumption: You might have created your company in MSOA and you have to pass company name in step – 9 at the place of “yourCompany.sbc”.

  1. Create Windows based Project.
  2. You have to add references of following DLLS.
    • ILoader: c:WINDOWSassemblyGAC_32ILoader2.0.5201.0__31bf3856ad364e35ILoader.dll
    • SBAIAPI: c:Program FilesMicrosoft Small BusinessSmall Business Accounting 2007AssembliesSBAIAPI.dll
    • SBAIUI: c:Program FilesMicrosoft Small BusinessSmall Business Accounting 2007AssembliesSBAIUI.dll
  3. Now you need to Import two namespace for MOA
      - using Microsoft.BusinessSolutions.SmallBusinessAccounting.UI;
      -using Microsoft.BusinessSolutions.SmallBusinessAccounting;
  4. Provide the Information related to your Loader
      - const string loaderFULLNAME = “Loader, Version=2.0.5201.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″;
  5. Provide the details related to your Assembly
    • const string loaderNAMESPACE = “Microsoft.BusinessSolutions.SmallBusinessAccounting.Loader.Loader”;
  6. Create object for ISmallBusinessInstance.(It is an interface so no needs to create New Instance for this
  7. Load the assembly which was initialized before.
  8. Assembly assem = Assembly.Load(loaderFULLNAME);

  9. Load the assembly which in your system using Loader
  10. ILoader ldr = assem.CreateInstance(loaderNAMESPACE) as ILoader;

  11. Create string object and initialize with .sbc file which is stored in Your MYDocument. You can provide other path also.
    • string sbaFile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) Path.DirectorySeparatorChar + “Small Business Accounting” Path.DirectorySeparatorChar + “Companies” + Path.DirectorySeparatorChar + “yourCompany.sbc”;
  12. Load the file in your application using loader.
  13. – sbi = ldr.GetSbaObjects(sbaFile).SmallBusinessInstance as ISmallBusinessInstance

  14. Now your sbi object (instance of SmallBusinessInstance) is ready to Use.

Manage customer details using SmallBusinessInstance Object

Now it’s time to implement SmallBusinessInstance object to access the details related to Customers. [sbi is an object of SmallBusinessInstance]

How to view existing customers?

  • Create object of DataTable. And initialize the Details of sbi.CustomerAccounts.DataView.Table to the object of DataTable.
  • You can use this DataTable object and assign that object to DataSource of GridView or ComboBox to view the details related to Customers.

How to create New Customers?

  • Create an object of ICustomerAccount. And assign the value of sbi.CreateCustomerAccount(); ICustomerAccount cust = sbi.CreateCustomerAccount();
  • Now you can access the Properties on Customer Account (e.g. Name, Active);
  • You cannot access the property of Address, Email and Fax directly from this object you need to create the object of ICustomerVendorAddress , ICustomerVendorEmail and ICustomerVendorFax respectively
    • ICustomerVendorAddress: You have to create object of ICustomerVendorAddress and initialize it. ICustomerVendorAddress address = cust.CustomerVendorAddresses.GetByType(CustomerVendorAddressType.Business); where you can find different CustomerVendorAddressType. Like (Business, Home, Postal, etc) Now you can access the properties of Address.
    • ICustomerVendorEmail: You have to create object of ICustomerVendorAddress and initialize it. ICustomerVendorEmail emailAddress = cust.CustomerVendorEmails.GetByType(CustomerVendorEmailType.Email1); where you can find different CustomerVendorEmailType. Like (Email1, Email2, and Email3). Now you can access the properties of Email
    • ICustomerVendorFax: You have to create object of ICustomerVendorAddress and initialize it. ICustomerVendorFax faxNumber = cust.CustomerVendorFaxes.GetByType(CustomerVendorFaxType.Business); where you can find different CustomerVendorFaxType. Like (Business, Home and Other). Now you can access the properties of Fax.
  • Now you can save the Customer. cust.Save();

Manage Payment details using SmallBusinessInstance object Now you can implement the Payment module of customer in following ways.

How to Create New Payment for Customers?

  • For payment of customer you have to specify for which customer you need to make payment.
  • You need to provide AccountId of customer for Payment.
  • Create ICustomerAccount object and initialize it with sbi.CustomerAccounts
    ICustomerAccount cust = (ICustomerAccount)sbi.CustomerAccounts.GetByPrimaryKey(AccountID);
  • Create object of ICustomerPayment and initialize it with sbi.CreateCustomerPayment()
    ICustomerPayment payment = sbi.CreateCustomerPayment();
  • Now assign the value of payment.Customer as cust
    payment.Customer = cust;
  • Now provide the details of Amount.
  • And finally save the record
    payment.Save();

Manage Invoice details using SmallBusinessInstance object. You can manage the details of Invoice using the APIs of Microsoft Accounting.

How to View existing Invoice?

  • Create object of DataTable. And initialize the Details of sbi.SalesInvoices.DataView.Table to the object of DataTable.
  • You can use this DataTable object and assign that object to DataSource of GridView or ComboBox to view the details related to Invoice.

How to create New Invoice?

  • For Invoice of customer you have to specify for which customer you need to create invoice.
  • You need to provide AccountId of customer for creating Invoice.
  • Create object of ISalesInvoice and initialize it with sbi.CreateSalesInvoice(false). ISalesInvoice invoice = sbi.CreateSalesInvoice(false);
  • Create object of IItemLine.

IItemLine line;

  • Initialize the object of IItemLine with invoice.CreateSalesInvoiceLine(parameters) IItemLine line = invoice.CreateSalesInvoiceLine(DocumentLineType.ContractItemLineType) as IItemLine;
  • Now assign the value for LineItem property of IItemLine object line.LineItem = sbi.ItemAccounts.GetByPrimaryKey(ProdId) as IItemAccount;
  • Provide the Quantity and other details of IItemAccount object.
  • Finally save the details of Invoice

invoice.Save();