dev: move/rename nullsourcepos

This commit is contained in:
Simon Michael 2024-11-02 14:59:43 -10:00
parent 5d2259d942
commit 4d38c63ec8
8 changed files with 40 additions and 37 deletions

View File

@ -793,7 +793,7 @@ tests_Balancing =
(Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2007 01 28)
Nothing
Unmarked
@ -808,7 +808,7 @@ tests_Balancing =
(Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2007 01 28)
Nothing
Unmarked
@ -825,7 +825,7 @@ tests_Balancing =
(Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2007 01 28)
Nothing
Unmarked
@ -841,7 +841,7 @@ tests_Balancing =
(Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2007 01 28)
Nothing
Unmarked
@ -859,7 +859,7 @@ tests_Balancing =
(Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2011 01 01)
Nothing
Unmarked
@ -876,7 +876,7 @@ tests_Balancing =
(Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2011 01 01)
Nothing
Unmarked
@ -895,7 +895,7 @@ tests_Balancing =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2009 01 01)
Nothing
Unmarked
@ -913,7 +913,7 @@ tests_Balancing =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2009 01 01)
Nothing
Unmarked
@ -931,7 +931,7 @@ tests_Balancing =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2009 01 01)
Nothing
Unmarked
@ -946,7 +946,7 @@ tests_Balancing =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2009 01 01)
Nothing
Unmarked
@ -961,7 +961,7 @@ tests_Balancing =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2009 01 01)
Nothing
Unmarked
@ -980,7 +980,7 @@ tests_Balancing =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2009 01 01)
Nothing
Unmarked
@ -998,7 +998,7 @@ tests_Balancing =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2009 01 01)
Nothing
Unmarked

View File

@ -1242,7 +1242,7 @@ samplejournalMaybeExplicit explicit = nulljournal
{jtxns = [
txnTieKnot $ Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2008 01 01,
tdate2=Nothing,
tstatus=Unmarked,
@ -1259,7 +1259,7 @@ samplejournalMaybeExplicit explicit = nulljournal
,
txnTieKnot $ Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2008 06 01,
tdate2=Nothing,
tstatus=Unmarked,
@ -1276,7 +1276,7 @@ samplejournalMaybeExplicit explicit = nulljournal
,
txnTieKnot $ Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2008 06 02,
tdate2=Nothing,
tstatus=Unmarked,
@ -1293,7 +1293,7 @@ samplejournalMaybeExplicit explicit = nulljournal
,
txnTieKnot $ Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2008 06 03,
tdate2=Nothing,
tstatus=Cleared,
@ -1310,7 +1310,7 @@ samplejournalMaybeExplicit explicit = nulljournal
,
txnTieKnot $ Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2008 10 01,
tdate2=Nothing,
tstatus=Unmarked,
@ -1326,7 +1326,7 @@ samplejournalMaybeExplicit explicit = nulljournal
,
txnTieKnot $ Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2008 12 31,
tdate2=Nothing,
tstatus=Unmarked,

View File

@ -19,7 +19,6 @@ module Hledger.Data.Posting (
vpost,
post',
vpost',
nullsourcepos,
nullassertion,
balassert,
balassertTot,
@ -181,9 +180,6 @@ post' acc amt ass = posting {paccount=acc, pamount=mixedAmount amt, pbalanceasse
vpost' :: AccountName -> Amount -> Maybe BalanceAssertion -> Posting
vpost' acc amt ass = (post' acc amt ass){ptype=VirtualPosting, pbalanceassertion=ass}
nullsourcepos :: (SourcePos, SourcePos)
nullsourcepos = (SourcePos "" (mkPos 1) (mkPos 1), SourcePos "" (mkPos 2) (mkPos 1))
nullassertion :: BalanceAssertion
nullassertion = BalanceAssertion
{baamount=nullamt

View File

@ -84,7 +84,7 @@ instance HasAmounts Transaction where
nulltransaction :: Transaction
nulltransaction = Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=nulldate,
tdate2=Nothing,
tstatus=Unmarked,
@ -581,7 +581,7 @@ tests_Transaction =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2007 01 28)
Nothing
Unmarked
@ -605,7 +605,7 @@ tests_Transaction =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2007 01 28)
Nothing
Unmarked
@ -628,7 +628,7 @@ tests_Transaction =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2007 01 28)
Nothing
Unmarked
@ -644,7 +644,7 @@ tests_Transaction =
Transaction
0
""
nullsourcepos
nullsourcepospair
(fromGregorian 2010 01 01)
Nothing
Unmarked

View File

@ -53,6 +53,7 @@ import Text.Megaparsec (SourcePos(SourcePos), mkPos)
import Hledger.Utils.Regex
-- synonyms for various date-related scalars
#if MIN_VERSION_time(1,11,0)
import Data.Time.Calendar (Year)
@ -401,6 +402,12 @@ instance Show Status where -- custom show.. bad idea.. don't do it..
show Pending = "!"
show Cleared = "*"
nullsourcepos :: SourcePos
nullsourcepos = SourcePos "" (mkPos 1) (mkPos 1)
nullsourcepospair :: (SourcePos, SourcePos)
nullsourcepospair = (SourcePos "" (mkPos 1) (mkPos 1), SourcePos "" (mkPos 2) (mkPos 1))
-- | A balance assertion is a declaration about an account's expected balance
-- at a certain point (posting date and parse order). They provide additional
-- error checking and readability to a journal file.

View File

@ -1116,7 +1116,7 @@ tests_JournalReader = testGroup "JournalReader" [
[("a:b", AccountDeclarationInfo{adicomment = "type:asset\n"
,aditags = [("type","asset")]
,adideclarationorder = 1
,adisourcepos = fst nullsourcepos
,adisourcepos = nullsourcepos
})
]
]

View File

@ -85,7 +85,7 @@ Right samplejournal2 =
jtxns = [
txnTieKnot Transaction{
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2008 01 01,
tdate2=Just $ fromGregorian 2009 01 01,
tstatus=Unmarked,

View File

@ -385,7 +385,7 @@ tests_Commands = testGroup "Commands" [
,testGroup "apply account directive" [
testCase "works" $ do
let
ignoresourcepos j = j{jtxns=map (\t -> t{tsourcepos=nullsourcepos}) (jtxns j)}
ignoresourcepos j = j{jtxns=map (\t -> t{tsourcepos=nullsourcepospair}) (jtxns j)}
sameParse str1 str2 = do
j1 <- ignoresourcepos <$> readJournal' str1 -- PARTIAL:
j2 <- ignoresourcepos <$> readJournal' str2 -- PARTIAL:
@ -651,7 +651,7 @@ journal7 = nulljournal {jtxns =
[
txnTieKnot Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2007 01 01,
tdate2=Nothing,
tstatus=Unmarked,
@ -668,7 +668,7 @@ journal7 = nulljournal {jtxns =
,
txnTieKnot Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2007 02 01,
tdate2=Nothing,
tstatus=Unmarked,
@ -685,7 +685,7 @@ journal7 = nulljournal {jtxns =
,
txnTieKnot Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2007 01 02,
tdate2=Nothing,
tstatus=Unmarked,
@ -702,7 +702,7 @@ journal7 = nulljournal {jtxns =
,
txnTieKnot Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2007 01 03,
tdate2=Nothing,
tstatus=Unmarked,
@ -719,7 +719,7 @@ journal7 = nulljournal {jtxns =
,
txnTieKnot Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2007 01 03,
tdate2=Nothing,
tstatus=Unmarked,
@ -736,7 +736,7 @@ journal7 = nulljournal {jtxns =
,
txnTieKnot Transaction {
tindex=0,
tsourcepos=nullsourcepos,
tsourcepos=nullsourcepospair,
tdate=fromGregorian 2007 01 03,
tdate2=Nothing,
tstatus=Unmarked,