using System;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AyaNovaQBI
{
    internal class QBIIntegrationData
    {
        /*
		 
		 {"IsDirty":false,"QBInventoryIncomeAccountReference":"","QBInventoryCOGSAccountRef":"","QBInventoryAssetAccountRef":"","QBServiceIncomeAccountRef":"",
        "TermsDefault":"","PreWOStatus":"00000000-0000-0000-0000-000000000000","PostWOStatus":"00000000-0000-0000-0000-000000000000","OutsideServiceChargeAs":"",
        "MiscExpenseChargeAs":"","WorkorderItemLoanChargeAs":"","QBInvoiceTemplate":"","SetMemoField":true,"TransactionClass":"","ToBePrinted":true,"InvoiceHeaderTemplate":"",
        "InvoiceFooterTemplate":"","InvoiceUnitTemplate":"","InvoiceServiceTemplate":"","InvoiceTravelTemplate":"","InvoiceOutsideServiceTemplate":"","InvoiceMiscExpenseTemplate":"",
        "InvoiceLoanItemTemplate":"","HasInvoiceHeaderTemplate":false,"HasAnyInvoiceFooterTemplateFields":false,"AutoClose":true,"NothingSet":true}
		 */
        #region fields
        private long _PreWOStatus = 0;
        private long _PostWOStatus = 0;
        private string _OutsideServiceChargeAs = "";
        private string _WorkorderItemLoanChargeAs = "";
        private string _MiscExpenseChargeAs = "";
        private string _QBInvoiceTemplate = "";
        private bool _SetMemoField = true;
        private string _TransactionClass = "";
        private bool _ToBePrinted = true;
        private string _InvoiceHeaderTemplate = "";
        private string _InvoiceFooterTemplate = "";
        private string _InvoiceUnitTemplate = "";
        private string _InvoiceServiceTemplate = "";
        private string _InvoiceTravelTemplate = "";
        private string _InvoiceOutsideServiceTemplate = "";
        private string _InvoiceMiscExpenseTemplate = "";
        private string _InvoiceLoanItemTemplate = "";

        ////Case 7
        //private bool _AutoClose = true;

        #region Case 632
        //Default qb accounts to use when importing inventory and service items
        //from ayanova to QuickBooks
        private string _QBInventoryIncomeAccountReference = "";
        public string QBInventoryIncomeAccountReference
        {
            get { return _QBInventoryIncomeAccountReference; }
            set { if (_QBInventoryIncomeAccountReference != value) { _QBInventoryIncomeAccountReference = value; IsDirty = true; } }
        }

        private string _QBInventoryCOGSAccountRef = "";
        public string QBInventoryCOGSAccountRef
        {
            get { return _QBInventoryCOGSAccountRef; }
            set { if (_QBInventoryCOGSAccountRef != value) { _QBInventoryCOGSAccountRef = value; IsDirty = true; } }
        }

        private string _QBInventoryAssetAccountRef = "";
        public string QBInventoryAssetAccountRef
        {
            get { return _QBInventoryAssetAccountRef; }
            set { if (_QBInventoryAssetAccountRef != value) { _QBInventoryAssetAccountRef = value; IsDirty = true; } }
        }


        private string _QBServiceIncomeAccountRef = "";
        public string QBServiceIncomeAccountRef
        {
            get { return _QBServiceIncomeAccountRef; }
            set { if (_QBServiceIncomeAccountRef != value) { _QBServiceIncomeAccountRef = value; IsDirty = true; } }
        }
        #endregion

        //Case 519
        private string _TermsDefault = "";
        public string TermsDefault
        {
            get { return _TermsDefault; }
            set { if (_TermsDefault != value) { _TermsDefault = value; IsDirty = true; } }
        }

        [JsonIgnore]
        public bool IsDirty = false;
        #endregion

        #region Properties
        public long PreWOStatus
        {
            get { return _PreWOStatus; }
            set
            {
                if (_PreWOStatus != value)
                {
                    _PreWOStatus = value;
                    IsDirty = true;
                }
            }
        }

        public long PostWOStatus
        {
            get { return _PostWOStatus; }
            set
            {
                if (_PostWOStatus != value)
                {
                    _PostWOStatus = value;
                    IsDirty = true;
                }
            }
        }

        public string OutsideServiceChargeAs
        {
            get { return _OutsideServiceChargeAs; }
            set
            {
                if (_OutsideServiceChargeAs != value)
                {
                    _OutsideServiceChargeAs = value;
                    IsDirty = true;
                }
            }
        }
        public string MiscExpenseChargeAs
        {
            get { return _MiscExpenseChargeAs; }
            set
            {
                if (_MiscExpenseChargeAs != value)
                {
                    _MiscExpenseChargeAs = value;
                    IsDirty = true;
                }
            }
        }

        public string WorkorderItemLoanChargeAs
        {
            get { return _WorkorderItemLoanChargeAs; }
            set
            {
                if (_WorkorderItemLoanChargeAs != value)
                {
                    _WorkorderItemLoanChargeAs = value;
                    IsDirty = true;
                }
            }
        }
        public string QBInvoiceTemplate
        {
            get { return _QBInvoiceTemplate; }
            set
            {
                if (_QBInvoiceTemplate != value)
                {
                    _QBInvoiceTemplate = value;
                    IsDirty = true;
                }
            }
        }
        public bool SetMemoField
        {
            get { return _SetMemoField; }
            set
            {
                if (_SetMemoField != value)
                {
                    _SetMemoField = value;
                    IsDirty = true;
                }
            }
        }

        public string TransactionClass
        {
            get { return _TransactionClass; }
            set
            {
                if (_TransactionClass != value)
                {
                    _TransactionClass = value;
                    IsDirty = true;
                }
            }
        }

        public bool ToBePrinted
        {
            get { return _ToBePrinted; }
            set
            {
                if (_ToBePrinted != value)
                {
                    _ToBePrinted = value;
                    IsDirty = true;
                }
            }
        }

        public string InvoiceHeaderTemplate
        {
            get { return _InvoiceHeaderTemplate; }
            set
            {
                if (_InvoiceHeaderTemplate != value)
                {
                    _InvoiceHeaderTemplate = value;
                    IsDirty = true;
                }
            }
        }

        public string InvoiceFooterTemplate
        {
            get { return _InvoiceFooterTemplate; }
            set
            {
                if (_InvoiceFooterTemplate != value)
                {
                    _InvoiceFooterTemplate = value;
                    IsDirty = true;
                }
            }
        }

        public string InvoiceUnitTemplate
        {
            get { return _InvoiceUnitTemplate; }
            set
            {
                if (_InvoiceUnitTemplate != value)
                {
                    _InvoiceUnitTemplate = value;
                    IsDirty = true;
                }
            }
        }

        public string InvoiceServiceTemplate
        {
            get { return _InvoiceServiceTemplate; }
            set
            {
                if (_InvoiceServiceTemplate != value)
                {
                    _InvoiceServiceTemplate = value;
                    IsDirty = true;
                }
            }
        }

        public string InvoiceTravelTemplate
        {
            get { return _InvoiceTravelTemplate; }
            set
            {
                if (_InvoiceTravelTemplate != value)
                {
                    _InvoiceTravelTemplate = value;
                    IsDirty = true;
                }
            }
        }

        public string InvoiceOutsideServiceTemplate
        {
            get { return _InvoiceOutsideServiceTemplate; }
            set
            {
                if (_InvoiceOutsideServiceTemplate != value)
                {
                    _InvoiceOutsideServiceTemplate = value;
                    IsDirty = true;
                }
            }
        }

        public string InvoiceMiscExpenseTemplate
        {
            get { return _InvoiceMiscExpenseTemplate; }
            set
            {
                if (_InvoiceMiscExpenseTemplate != value)
                {
                    _InvoiceMiscExpenseTemplate = value;
                    IsDirty = true;
                }
            }
        }

        public string InvoiceLoanItemTemplate
        {
            get { return _InvoiceLoanItemTemplate; }
            set
            {
                if (_InvoiceLoanItemTemplate != value)
                {
                    _InvoiceLoanItemTemplate = value;
                    IsDirty = true;
                }
            }
        }



        public bool HasInvoiceHeaderTemplate
        {
            get
            {
                return _InvoiceHeaderTemplate != "";
            }
        }

        public bool HasAnyInvoiceFooterTemplateFields
        {
            get
            {
                if (this._InvoiceFooterTemplate != "" ||
                    this._InvoiceUnitTemplate != "" ||
                    this._InvoiceServiceTemplate != "" ||
                    this._InvoiceTravelTemplate != "" ||
                    this._InvoiceLoanItemTemplate != "" ||
                    this._InvoiceMiscExpenseTemplate != "" ||
                    this._InvoiceOutsideServiceTemplate != ""
                    )
                    return true;
                else
                    return false;

            }
        }

        ////Case 7
        //public bool AutoClose
        //{
        //    get { return _AutoClose; }
        //    set
        //    {
        //        if (_AutoClose != value)
        //        {
        //            _AutoClose = value;
        //            IsDirty = true;
        //        }
        //    }
        //}



        /// <summary>
        /// Flag indicating whether user has configured 
        /// QBI at all yet, this is used to present a description
        /// of the configuration that is about to take place to the user
        /// 
        /// If this is false then any missing option is considered a one-off
        /// and no general initial description is given to the user about setting 
        /// up QBI
        /// </summary>
        [JsonIgnore]
        public bool NothingSet
        {
            get
            {
                if (_PreWOStatus == 0 &&
                    _PostWOStatus == 0 &&
                    _OutsideServiceChargeAs == "" &&
                    _WorkorderItemLoanChargeAs == "" &&
                    _MiscExpenseChargeAs == "" &&
                    _TransactionClass == "" &&
                    _QBInvoiceTemplate == "") return true;
                return false;

            }
        }
        #endregion props

    }
}
