a few things on posting period.
1. its driven by the trandate, so by default it will be the period that the trandate is in
2. its a list/record type, so you need the internal id to set it, you'll have to do a search/lookup to find the period internal id
3. if you can... avoid doing 2 by just setting the trandate so it falls in the right period, because 2 is kind of annoying