LaRetta Posted June 24, 2005 Posted June 24, 2005 Well my logic breaks on this one and I know it can be better also. LineItems holds Quantity (number) of 'eaches' sold. Products holds QtyPerCase (number) of how many are in a case. Joined on ProductID. Packing Slip requirements: Currently we just display eaches (only the Quantity field). Owner wants it changed to display total 'cases' and 'eaches'. What I have (yep, ugly) ... Let( [ cs = Div(Qty; Products::QtyPerCase) ; ea = Qty / Products::QtyPerCase - cs ] ; Case( ea > 0 ; cs & " Cases, " & ea & " Eaches"; cs = 1; cs & " Case"; not cs; ea & " Eaches"; cs & " Cases") ) If Quantity is 1 and QtyPerCase is 12 it displays as: 0 Cases, .0833333 Eaches. Geez. Need to fix the eaches and I'd like to eliminate the cases portion if it's under a case also. I got myself a bit lost. Does it show? LaRetta
comment Posted June 24, 2005 Posted June 24, 2005 Try: Let ( [ cs = Div ( Quantity ; QtyPerCase ) ; pc = Mod ( Quantity ; QtyPerCase ) ] ; Case ( cs ; cs & " Case" & Case ( cs - 1 ; "s" ) ) & Case ( pc ; Case ( cs ; ", " ) & pc & " Piece" & Case ( pc - 1 ; "s" ) ) ) And pardon me for changing the vocabulary - I've never heard of "eaches". If Quantity = 25, you'd get "2 Cases, 1 Each", which to me means "Let's you and I get some beer - 2 cases, one each".
LaRetta Posted June 24, 2005 Author Posted June 24, 2005 I had tried using Mod() on the ... errr pieces portion. Oh! This means I'm *getting* it but just not quite *getting* it!! YAY!!! And I couldn't remember how you and JT and Ray split the (s) for single/plural in the Case() portion. Maybe I'll remember it now. Yep, I had asked Owner about that wording ... It isn't 'bottles' because sometimes it could be tabs, etc. Eaches is all we could think of - pieces is perfect! I will thank you in advance for the calculation, Michael. I have absolutely no doubt that it's perfect. LaRetta
Recommended Posts
This topic is 7160 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now