using InABox.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InABox.Poster.MYOB;

public class MYOBGlobalPosterSettings : GlobalPosterSettings
{
    [EditorSequence(1)]
    [MYOBCompanyFileEditor]
    public MYOBCompanyFile CompanyFile => InitializeField(ref _companyFile, nameof(CompanyFile));
    private MYOBCompanyFile? _companyFile;

    [EditorSequence(2)]
    [TextBoxEditor]
    public string CompanyFileUserID { get; set; }

    [EditorSequence(3)]
    [PasswordEditor(ViewButtonVisible = true)]
    public string CompanyFilePassword { get; set; }

    [EditorSequence(4)]
    [CheckBoxEditor]
    public bool NoCredentials { get; set; }

    [TextBoxEditor(ToolTip = "The MYOB tax code which should be used for global supplier tax codes, customer tax codes, freight tax codes, etc.")]
    public string DefaultTaxCode { get; set; }

    protected override void DoPropertyChanged(string name, object? before, object? after)
    {
        base.DoPropertyChanged(name, before, after);

        if(name == nameof(NoCredentials) && NoCredentials)
        {
            CompanyFileUserID = "";
            CompanyFilePassword = "";
        }
    }
}
