-- * Helpers for dealing with OFX data

-- | Given an OfxIn, make a default OfxOut.
defaultOfxOut :: OfxIn -> OfxOut
defaultOfxOut ofxIn = OfxOut
  { _payee = case OFX.txPayeeInfo . _ofxTxn $ ofxIn of
      Nothing -> ""
      Just (Left str) -> X.pack str
      Just (Right pye) -> X.pack . OFX.peNAME $ pye
  , _flag = Nothing
  , _foreignAccount = []
  , _flipSign = False
  , _offsettingAccount = []
  , _commodity = ""
  , _arrangement = Arrangement CommodityOnRight True
  , _zonedTime = OFX.txDTPOSTED . _ofxTxn $ ofxIn
  }
defaultOfxOut :: OfxIn -> OfxOut
defaultOfxOut ofxIn = OfxOut
  { _payee = case OFX.txPayeeInfo . _ofxTxn $ ofxIn of
      Nothing -> ""
      Just (Left str) -> X.pack str
      Just (Right pye) -> X.pack . OFX.peNAME $ pye
  , _flag = Nothing
  , _foreignAccount = []
  , _flipSign = False
  , _offsettingAccount = []
  , _commodity = ""
  , _arrangement = Arrangement CommodityOnRight True
  , _zonedTime = OFX.txDTPOSTED . _ofxTxn $ ofxIn
  }
defaultOfxOut ofxIn = OfxOut
  { _payee = case OFX.txPayeeInfo . _ofxTxn $ ofxIn of
      Nothing -> ""
      Just (Left str) -> X.pack str
      Just (Right pye) -> X.pack . OFX.peNAME $ pye
  , _flag = Nothing
  , _foreignAccount = []
  , _flipSign = False
  , _offsettingAccount = []
  , _commodity = ""
  , _arrangement = Arrangement CommodityOnRight True
  , _zonedTime = OFX.txDTPOSTED . _ofxTxn $ ofxIn
  }