ad-hoc freight descriptions

Discussions relating to plugin development, and the Jiwa API.

ad-hoc freight descriptions

Postby pricerc » Fri Mar 01, 2024 9:19 am

I've got a freight plugin working well for talking to NZ Post's API.

I am now just considering options for streamlining the user experience.

The customer uses branded courier bags supplied by the courier company - A4, A5, A4 with bubbles, etc. And currently, they have these as "obsolete" parts in their inventory - they don't show up on price lists, but they can still buy them and hold the stock.

We've got the logic working that if a part number is added to the S/O that matches a Freight Description, that we add a Freight item, complete with volume.

So my question is: do we have to use a pre-defined freight descriptions, or can I synthesise them "on the fly"?

This would allow them to just add new courier packaging to inventory, and use that as the "freight description", instead of having to enter the same thing in multiple places.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: ad-hoc freight descriptions

Postby SBarnes » Sat Mar 02, 2024 8:26 am

Where does the volume come from and is "freight item" a completely seperate part?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: ad-hoc freight descriptions

Postby pricerc » Wed Mar 06, 2024 1:37 pm

Inventory items already have volume.

For now, we've hard-coded dimensions in a dictionary in the plugin - NZ Post have a small, finite set of standard packages, so it was easy enough to just load them into a switch/case statement.

I have added some logic, which appears to be working ok, but it feels wrong.

We've added a "Freight" product group. If the item in this product group is added to an S/O, but its name doesn't exist as a "Freight Description" (for the only carrier we have in the system), it is adding the item to the "Freight Description" list (directly using SQL, because the S/O version of the Carrier doesn't implement "Save" on its FreightDesciptionCollection).

If the item doesn't have volume and mass (which we're using as a default/maximum) then they will need to supply the dimensions directly on the freight tab.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: ad-hoc freight descriptions

Postby SBarnes » Thu Mar 07, 2024 5:37 am

pricerc wrote:
because the S/O version of the Carrier doesn't implement "Save" on its FreightDesciptionCollection).



The full version of the carrier and the freight items and its collection are in JiwaFinancials.Jiwa.JiwaCarrierMaint that will actually do updates and inserts, then calling read on the FreightDescriptions collection on the sales order would make them show up.

As for the descriptions on the fly would UOM on inventory be able to be adapted for what you are trying to achieve?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: ad-hoc freight descriptions

Postby pricerc » Thu Mar 07, 2024 2:04 pm

SBarnes wrote:The full version of the carrier and the freight items and its collection are in JiwaFinancials.Jiwa.JiwaCarrierMaint that will actually do updates and inserts, then calling read on the FreightDescriptions collection on the sales order would make them show up.


I figured that out in ILspy, but decided that it was a lot of overhead for a fairly trivial process at the tail end of entering an order, so just went with adding it with a sneaky SQL command. Which I mostly nicked from ILspy. (*)

I'm also adding it to the 'active' S/O FreightDescriptions collection so that the Freight Tab works until the S/O is next saved, at which point it will be refreshed and pick up the new entry.

SBarnes wrote:As for the descriptions on the fly would UOM on inventory be able to be adapted for what you are trying to achieve?

I don't think so. I'm talking about the "Freight Descriptions" in the Carrier Maintenance screen?

And on the "Freight Tab" on the S/O. Where I was hoping I'd be able to just use "ad-hoc" values for the "Freight Descriptions". I now realise that they are actually lookups into the relevant Carrier's "FreightDescriptionsCollection".... so ad-hoc isn't (currently) an option.


(*) yes, I know it might break in a future version of Jiwa. But I expect it will be one of the simpler problems I face when upgrading this customer from 7 to 8....
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: ad-hoc freight descriptions

Postby SBarnes » Thu Mar 07, 2024 4:09 pm

Hi Ryan,

Below is code that will do what you want just create a new plugin and add the sales order forms under the forms tab and add Carrier maintenance under the business logic for some reason trying to add an attachment is having a problem on the forums.

Code: Select all
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using JiwaFinancials.Jiwa;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Drawing;
using ServiceStack;
using ServiceStack.DataAnnotations;
using ServiceStack.Model;
using FarPoint.Win.Spread;
using FarPoint.Win.Spread.CellType;
using JiwaFinancials.Jiwa.JiwaApplication;
using JiwaFinancials.Jiwa.JiwaApplication.Controls;
using JiwaFinancials.Jiwa.JiwaApplication.JiwaManageGrid;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.VisualBasic.CompilerServices;
using System.ComponentModel;
using Microsoft.VisualBasic;
using JiwaFinancials.Jiwa.JiwaApplication.Entities;
using JiwaFinancials.Jiwa.JiwaCarrierMaint;

using Infragistics.Win.UltraWinToolbars;

#region "FormPlugin"
public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
{

    public override object InitializeLifetimeService()
    {
        // returning null here will prevent the lease manager
        // from deleting the Object.
        return null;
    }

    public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
    }

    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      if(JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
      {
         JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm sForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)JiwaForm;
         
         var cellType = new FarPoint.Win.Spread.CellType.ButtonCellType();
            cellType.Text = "New Description";
            sForm.grdFreightItems.AddColumn("NewDesc", cellType, "New Description", 5, false, true, false, false, 255, false, false, 2, false, false);
         sForm.grdFreightItems.ButtonClicked += delegate(object sender, EditorNotifyEventArgs e)
         {
              JiwaGrid jiwaGrid = (JiwaGrid)sender;
              string str = Conversions.ToString(jiwaGrid.get_GridText("Key", e.Row)).Trim();
              object tag = jiwaGrid.ActiveSheet.Columns[e.Column].Tag;
              if (Operators.ConditionalCompareObjectEqual(tag, "NewDesc", false))
              {
               JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderHistory hist = sForm.SalesOrder.SalesOrderHistorys[sForm.SalesOrder.CurrentHistoryNo];
               if(hist.Carrier == null || hist.Carrier.RecID == "")
               {
                  System.Windows.Forms.MessageBox.Show("Choose a Carrier first");
                  return;
               }
                  string newDescription = Microsoft.VisualBasic.Interaction.InputBox("Enter the new description", "New Description");
               if(newDescription != null && newDescription.Trim() != "")
               {
                  Carrier carrier = sForm.Manager.BusinessLogicFactory.CreateBusinessLogic<Carrier>(null);
                  
                  
                  carrier.Read(hist.Carrier.RecID);

                  FreightDescription description = sForm.Manager.CollectionItemFactory.CreateCollectionItem<FreightDescription>();
                  description.Description = newDescription;
                  description.Enabled = "True";
                  carrier.FreightDescriptions.Add(description);
                  carrier.Save();
                  hist.Carrier.FreightDescriptionCollection.Clear();
                  hist.Carrier.FreightDescriptionCollection.Read();
                  sForm.DisplayFreightItems();
               }
              }            
         };
      }
    }
   
   


}
#endregion

Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: ad-hoc freight descriptions

Postby SBarnes » Mon Mar 11, 2024 12:22 pm

Plugin now attached.
Attachments
Plugin Adhoc freight descriptions.xml
(35.48 KiB) Downloaded 126 times
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 17 guests

cron