예제 #1
0
        internal static XmlLineItem Deserialize( XmlReader xmlReader, Version version, ITransaction trans )
        {
            XmlLineItem lineItem = null;

            switch( xmlReader.Name )
            {
                case "credit":
                    lineItem = new XmlLineItem();
                    lineItem.TransactionType = TransactionType.Credit;
                    break;
                case "debit":
                    lineItem = new XmlLineItem();
                    lineItem.TransactionType = TransactionType.Debit;
                    break;
                default:
                    throw new ApplicationException( "Unknown node" );
            }

            lineItem.IsEstimated = trans.IsEstimated;
            lineItem.IsGenerated = trans.IsGenerated;
            lineItem.IsVoided = trans.IsVoided;

            if( trans != null ) // Set initial amount if not set otherwise
            {
                lineItem.Amount = trans.Amount;
                lineItem.Memo = trans.Memo;
            }

            if( xmlReader.GetAttribute( "id" ) != null )
                lineItem.Id = int.Parse( xmlReader.GetAttribute( "id" ) );

            if( xmlReader.GetAttribute( "accountId" ) != null )
                lineItem.AccountId = Int32.Parse( xmlReader.GetAttribute( "accountId" ) );

            if( xmlReader.GetAttribute( "category" ) != null )
                lineItem.Category = xmlReader.GetAttribute( "category" );

            if( xmlReader.GetAttribute( "amount" ) != null )
                lineItem.Amount = Decimal.Parse( xmlReader.GetAttribute( "amount" ) );

            if( xmlReader.GetAttribute( "memo" ) != null )
                lineItem.Memo = xmlReader.GetAttribute( "memo" );

            lineItem.Number = xmlReader.GetAttribute( "number" );	// could be null

            if( xmlReader.GetAttribute( "recordId" ) != null )
                lineItem.OnlineRecordId = int.Parse( xmlReader.GetAttribute( "recordId" ) );

            if( xmlReader.GetAttribute( "tax" ) != null )
                lineItem.IsTaxRelated = (xmlReader.GetAttribute( "tax" ).ToLower() == "true");

            if( xmlReader.GetAttribute( "reconciled" ) != null )
                lineItem.IsReconciled = (xmlReader.GetAttribute( "reconciled" ).ToLower() == "true");

            return lineItem;
        }
예제 #2
0
 internal void AddLineItem( XmlLineItem item )
 {
     this.lineItems.Add( item );
 }
예제 #3
0
 public override ILineItem NewLineItem()
 {
     XmlLineItem item = new XmlLineItem();
     item.Id = this.Provider.nextLineItemId++;
     item.SetTransaction( this );
     lineItems.Add( item );
     this.Provider.lineItems.Add( item.Id, item );
     return item;
 }