Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. Package Calculations for Shipping, do you see room for improvement

Package Calculations for Shipping, do you see room for improvement

Scheduled Pinned Locked Moved Algorithms
databasequestioncsharpcsslinq
9 Posts 5 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jkirkerx
    wrote on last edited by
    #1

    I'm in the process of writing my 4th generation package calculator. Over the years, UPS and FedEx require that you enter package dimensions and weight to get a quote. Before I was able to create a clump, which I call a unit of mass, based off the cart database which contains each products dimensions, then cube that clump into a cube shape. But times have changed. My 3rd generation package calculator was a complete failure overall, in which I tried using SQL Linq to calculate from the database So here is my 4th generation attempt. I get all the items from the database, and throw the items into 1 of 4 categories - List(Of These will always be separate packages Isolated Items - Case Quantities, you just slap a label on them and ship Long Items, like sticks, long levels over 6ft These can be combined into a single package, if under the max parameters Thin Items like pancakes, AAA batteries less than 1/2" height Common Items - you can throw them in a box, slap a label and ship Then I wrote 4 functions that calculate the length, width, height, dimensional weight, gravity weight. Within each function, a loop runs. Each function is slightly different, ... 1. lines up the items by length, then loops down the lengths going wider, then taller 2. stacks them up like a tower, largest on the bottom 3. Isolate - its just a package, get the length, width, height, weight and go 4. Common - I'm in doubt on this one, needs improvement If the limit is reached, the Create_Package fires and makes a Package. So now I have these packages, and run Package_Combine, in which I see if I can throw a THIN package into the common box, to reduce the number of packages, because each package has a base cost of $7.00, and shoppers freak out. The packages are a class of package_types, that are sent off to UPS or Fedex for a Quote, in which those programs I wrote loop and submit each package as a single shipment. My code is too large to post. So I will post a snippet of 2 functions to start with. So my question is, do you think I'm on the right track. Does a better more efficient way pop into your head. Did I make it way too complicated? Think I get can further refine the 4 functions into 1 function by using more Linq? I have to get this right this time, I'm tired of being poor and need to raise my income. I don't have the funds to just pay someone to write this, and how would I validate that person before hire. Oh and I expect to hear crickets on this p

    Richard DeemingR L J I 4 Replies Last reply
    0
    • J jkirkerx

      I'm in the process of writing my 4th generation package calculator. Over the years, UPS and FedEx require that you enter package dimensions and weight to get a quote. Before I was able to create a clump, which I call a unit of mass, based off the cart database which contains each products dimensions, then cube that clump into a cube shape. But times have changed. My 3rd generation package calculator was a complete failure overall, in which I tried using SQL Linq to calculate from the database So here is my 4th generation attempt. I get all the items from the database, and throw the items into 1 of 4 categories - List(Of These will always be separate packages Isolated Items - Case Quantities, you just slap a label on them and ship Long Items, like sticks, long levels over 6ft These can be combined into a single package, if under the max parameters Thin Items like pancakes, AAA batteries less than 1/2" height Common Items - you can throw them in a box, slap a label and ship Then I wrote 4 functions that calculate the length, width, height, dimensional weight, gravity weight. Within each function, a loop runs. Each function is slightly different, ... 1. lines up the items by length, then loops down the lengths going wider, then taller 2. stacks them up like a tower, largest on the bottom 3. Isolate - its just a package, get the length, width, height, weight and go 4. Common - I'm in doubt on this one, needs improvement If the limit is reached, the Create_Package fires and makes a Package. So now I have these packages, and run Package_Combine, in which I see if I can throw a THIN package into the common box, to reduce the number of packages, because each package has a base cost of $7.00, and shoppers freak out. The packages are a class of package_types, that are sent off to UPS or Fedex for a Quote, in which those programs I wrote loop and submit each package as a single shipment. My code is too large to post. So I will post a snippet of 2 functions to start with. So my question is, do you think I'm on the right track. Does a better more efficient way pop into your head. Did I make it way too complicated? Think I get can further refine the 4 functions into 1 function by using more Linq? I have to get this right this time, I'm tired of being poor and need to raise my income. I don't have the funds to just pay someone to write this, and how would I validate that person before hire. Oh and I expect to hear crickets on this p

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      I've not had a chance to give your question the attention it deserves, but one obvious issue sticks out:

      jkirkerx wrote:

      For Each p As model_rateItems In pItems _    .OrderByDescending(Function(m) m.Length) _    .OrderByDescending(Function(m) m.Width) _    .OrderByDescending(Function(m) m.Height)

      That's only going to sort by the height; each OrderBy method discards any previous ordering. To sort by all three, you need to use ThenBy on the subsequent sortings:

      For Each p As model_rateItems In pItems _
      .OrderByDescending(Function(m) m.Length) _
      .ThenByDescending(Function(m) m.Width) _
      .ThenByDescending(Function(m) m.Height)


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      J S 2 Replies Last reply
      0
      • Richard DeemingR Richard Deeming

        I've not had a chance to give your question the attention it deserves, but one obvious issue sticks out:

        jkirkerx wrote:

        For Each p As model_rateItems In pItems _    .OrderByDescending(Function(m) m.Length) _    .OrderByDescending(Function(m) m.Width) _    .OrderByDescending(Function(m) m.Height)

        That's only going to sort by the height; each OrderBy method discards any previous ordering. To sort by all three, you need to use ThenBy on the subsequent sortings:

        For Each p As model_rateItems In pItems _
        .OrderByDescending(Function(m) m.Length) _
        .ThenByDescending(Function(m) m.Width) _
        .ThenByDescending(Function(m) m.Height)


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        J Offline
        J Offline
        jkirkerx
        wrote on last edited by
        #3

        Oh I didn't know that, will make the change now. I'm starting to use Linq more now, since you helped me with my MVC project.

        1 Reply Last reply
        0
        • J jkirkerx

          I'm in the process of writing my 4th generation package calculator. Over the years, UPS and FedEx require that you enter package dimensions and weight to get a quote. Before I was able to create a clump, which I call a unit of mass, based off the cart database which contains each products dimensions, then cube that clump into a cube shape. But times have changed. My 3rd generation package calculator was a complete failure overall, in which I tried using SQL Linq to calculate from the database So here is my 4th generation attempt. I get all the items from the database, and throw the items into 1 of 4 categories - List(Of These will always be separate packages Isolated Items - Case Quantities, you just slap a label on them and ship Long Items, like sticks, long levels over 6ft These can be combined into a single package, if under the max parameters Thin Items like pancakes, AAA batteries less than 1/2" height Common Items - you can throw them in a box, slap a label and ship Then I wrote 4 functions that calculate the length, width, height, dimensional weight, gravity weight. Within each function, a loop runs. Each function is slightly different, ... 1. lines up the items by length, then loops down the lengths going wider, then taller 2. stacks them up like a tower, largest on the bottom 3. Isolate - its just a package, get the length, width, height, weight and go 4. Common - I'm in doubt on this one, needs improvement If the limit is reached, the Create_Package fires and makes a Package. So now I have these packages, and run Package_Combine, in which I see if I can throw a THIN package into the common box, to reduce the number of packages, because each package has a base cost of $7.00, and shoppers freak out. The packages are a class of package_types, that are sent off to UPS or Fedex for a Quote, in which those programs I wrote loop and submit each package as a single shipment. My code is too large to post. So I will post a snippet of 2 functions to start with. So my question is, do you think I'm on the right track. Does a better more efficient way pop into your head. Did I make it way too complicated? Think I get can further refine the 4 functions into 1 function by using more Linq? I have to get this right this time, I'm tired of being poor and need to raise my income. I don't have the funds to just pay someone to write this, and how would I validate that person before hire. Oh and I expect to hear crickets on this p

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          One throws the items into a box, specifies the dimensions of the box (customer packaging - if one want any applicable discount), weighs the box, selects a shipping option (ground; 2-day; etc.) and prints and attaches a label. Note that many carriers supply "standard size boxes" that are priced based on size, not weight (up to say a 70 lb max). Seems the challenge is to have all items to be shipped to a given customer collected ("picked") at the same time for shipping; not what box it may fit in (which may need extra "packing" for fragile items). The shipped boxes I receive tend to be much larger than their actually contents. (I currently program self-service shipping kiosks).

          J 1 Reply Last reply
          0
          • L Lost User

            One throws the items into a box, specifies the dimensions of the box (customer packaging - if one want any applicable discount), weighs the box, selects a shipping option (ground; 2-day; etc.) and prints and attaches a label. Note that many carriers supply "standard size boxes" that are priced based on size, not weight (up to say a 70 lb max). Seems the challenge is to have all items to be shipped to a given customer collected ("picked") at the same time for shipping; not what box it may fit in (which may need extra "packing" for fragile items). The shipped boxes I receive tend to be much larger than their actually contents. (I currently program self-service shipping kiosks).

            J Offline
            J Offline
            jkirkerx
            wrote on last edited by
            #5

            I under stand that. But I can't customers to standardize on boxes. I've been trying for 7 years now. It would be easier to get the customer to commit to purchasing boxes in certain sizes, and then I just calculate which boxes I need. Now this is a calculator for determining the ship rate before the customer makes a purchase. I'm going to take the code and turn it into a console app, with some fake data, so folks that are interested can play with it.

            1 Reply Last reply
            0
            • J jkirkerx

              I'm in the process of writing my 4th generation package calculator. Over the years, UPS and FedEx require that you enter package dimensions and weight to get a quote. Before I was able to create a clump, which I call a unit of mass, based off the cart database which contains each products dimensions, then cube that clump into a cube shape. But times have changed. My 3rd generation package calculator was a complete failure overall, in which I tried using SQL Linq to calculate from the database So here is my 4th generation attempt. I get all the items from the database, and throw the items into 1 of 4 categories - List(Of These will always be separate packages Isolated Items - Case Quantities, you just slap a label on them and ship Long Items, like sticks, long levels over 6ft These can be combined into a single package, if under the max parameters Thin Items like pancakes, AAA batteries less than 1/2" height Common Items - you can throw them in a box, slap a label and ship Then I wrote 4 functions that calculate the length, width, height, dimensional weight, gravity weight. Within each function, a loop runs. Each function is slightly different, ... 1. lines up the items by length, then loops down the lengths going wider, then taller 2. stacks them up like a tower, largest on the bottom 3. Isolate - its just a package, get the length, width, height, weight and go 4. Common - I'm in doubt on this one, needs improvement If the limit is reached, the Create_Package fires and makes a Package. So now I have these packages, and run Package_Combine, in which I see if I can throw a THIN package into the common box, to reduce the number of packages, because each package has a base cost of $7.00, and shoppers freak out. The packages are a class of package_types, that are sent off to UPS or Fedex for a Quote, in which those programs I wrote loop and submit each package as a single shipment. My code is too large to post. So I will post a snippet of 2 functions to start with. So my question is, do you think I'm on the right track. Does a better more efficient way pop into your head. Did I make it way too complicated? Think I get can further refine the 4 functions into 1 function by using more Linq? I have to get this right this time, I'm tired of being poor and need to raise my income. I don't have the funds to just pay someone to write this, and how would I validate that person before hire. Oh and I expect to hear crickets on this p

              J Offline
              J Offline
              jkirkerx
              wrote on last edited by
              #6

              I created a console app if you want to play with it, it's a VS2015 project with all the code that I wrote for it. it has data or shopping cart items that you can load, and will output the results to the screen So this is for my old program Internet Commerce Engine 5 written in VB I have a new program called project Indigo written in MVC C# that I will port this over in Sept 2016 So sorry about it being in VB. But the concept should be the same. DropBox that you can download the project, now its the folder. I fixed the console output and worked on Package_C1 Dropbox - Code Project[^] Preview of Project Indigo Shopping, not much there yet Project Indigo! - Home Page[^] Project Indigo! - Browse[^] I could use help with the Navigation Bar in the shopping section, much harder than I thought to construct using Bootstrap.

              1 Reply Last reply
              0
              • J jkirkerx

                I'm in the process of writing my 4th generation package calculator. Over the years, UPS and FedEx require that you enter package dimensions and weight to get a quote. Before I was able to create a clump, which I call a unit of mass, based off the cart database which contains each products dimensions, then cube that clump into a cube shape. But times have changed. My 3rd generation package calculator was a complete failure overall, in which I tried using SQL Linq to calculate from the database So here is my 4th generation attempt. I get all the items from the database, and throw the items into 1 of 4 categories - List(Of These will always be separate packages Isolated Items - Case Quantities, you just slap a label on them and ship Long Items, like sticks, long levels over 6ft These can be combined into a single package, if under the max parameters Thin Items like pancakes, AAA batteries less than 1/2" height Common Items - you can throw them in a box, slap a label and ship Then I wrote 4 functions that calculate the length, width, height, dimensional weight, gravity weight. Within each function, a loop runs. Each function is slightly different, ... 1. lines up the items by length, then loops down the lengths going wider, then taller 2. stacks them up like a tower, largest on the bottom 3. Isolate - its just a package, get the length, width, height, weight and go 4. Common - I'm in doubt on this one, needs improvement If the limit is reached, the Create_Package fires and makes a Package. So now I have these packages, and run Package_Combine, in which I see if I can throw a THIN package into the common box, to reduce the number of packages, because each package has a base cost of $7.00, and shoppers freak out. The packages are a class of package_types, that are sent off to UPS or Fedex for a Quote, in which those programs I wrote loop and submit each package as a single shipment. My code is too large to post. So I will post a snippet of 2 functions to start with. So my question is, do you think I'm on the right track. Does a better more efficient way pop into your head. Did I make it way too complicated? Think I get can further refine the 4 functions into 1 function by using more Linq? I have to get this right this time, I'm tired of being poor and need to raise my income. I don't have the funds to just pay someone to write this, and how would I validate that person before hire. Oh and I expect to hear crickets on this p

                I Offline
                I Offline
                ip address
                wrote on last edited by
                #7

                Thanks! I was looking this info

                J 1 Reply Last reply
                0
                • Richard DeemingR Richard Deeming

                  I've not had a chance to give your question the attention it deserves, but one obvious issue sticks out:

                  jkirkerx wrote:

                  For Each p As model_rateItems In pItems _    .OrderByDescending(Function(m) m.Length) _    .OrderByDescending(Function(m) m.Width) _    .OrderByDescending(Function(m) m.Height)

                  That's only going to sort by the height; each OrderBy method discards any previous ordering. To sort by all three, you need to use ThenBy on the subsequent sortings:

                  For Each p As model_rateItems In pItems _
                  .OrderByDescending(Function(m) m.Length) _
                  .ThenByDescending(Function(m) m.Width) _
                  .ThenByDescending(Function(m) m.Height)


                  "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                  S Offline
                  S Offline
                  Slacker007
                  wrote on last edited by
                  #8

                  :thumbsup:

                  1 Reply Last reply
                  0
                  • I ip address

                    Thanks! I was looking this info

                    J Offline
                    J Offline
                    jkirkerx
                    wrote on last edited by
                    #9

                    Well I'm still working on it!, but taking a break on it today. It needs improvement on the Common items, and a better way to arrange the items. I'm thinking aspect ratios today, to treat each item by aspect ratio or shape, to determine how to stack them, then take a measurement of the dimensional weight.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups