-- * Creating Penny transactions

-- | Given OFX data, creates a 'Tranche.TopLine'.
topLineTranche
  :: OfxIn
  -- ^
  -> OfxOut
  -- ^
  -> Tranche.TopLine ()
topLineTranche inp out = Tranche.Tranche ()
  $ Fields.TopLineFields zt pye origPye
  where
    zt = _zonedTime out
    pye = _payee out
    origPye = case OFX.txPayeeInfo . _ofxTxn $ inp of
      Nothing -> X.empty
      Just (Left s) -> X.pack s
      Just (Right p) -> X.pack . OFX.peNAME $ p

-- | Given OFX data, create the foreign posting.
topLineTranche
  :: OfxIn
  -- ^
  -> OfxOut
  -- ^
  -> Tranche.TopLine ()
topLineTranche inp out = Tranche.Tranche ()
  $ Fields.TopLineFields zt pye origPye
  where
    zt = _zonedTime out
    pye = _payee out
    origPye = case OFX.txPayeeInfo . _ofxTxn $ inp of
      Nothing -> X.empty
      Just (Left s) -> X.pack s
      Just (Right p) -> X.pack . OFX.peNAME $ p

-- | Given OFX data, create the foreign posting.
topLineTranche inp out = Tranche.Tranche ()
  $ Fields.TopLineFields zt pye origPye
  where
    zt = _zonedTime out
    pye = _payee out
    origPye = case OFX.txPayeeInfo . _ofxTxn $ inp of
      Nothing -> X.empty
      Just (Left s) -> X.pack s
      Just (Right p) -> X.pack . OFX.peNAME $ p

-- | Given OFX data, create the foreign posting.