from basic_info import models as basic_models


def create_basic_fixtures():
    merchant = basic_models.Merchant.objects.create(
        name='测试商户',
        type=basic_models.MerchantTypeEnum.FACTORY,
    )
    basic_models.MerchantSetting.objects.create(
        merchant=merchant,
        key=basic_models.MerchantSettingKeyEnum.AUTO_CREATE_STOCK_CHANGE_TASKS,
        type=basic_models.MerchantSettingTypeEnum.BOOL,
        val_bool=True,
    )
    supplier = basic_models.Supplier.objects.create(
        merchant=merchant,
        name='测试供应商',
    )
    warehouse_strict = basic_models.WareHouse.objects.create(
        merchant=merchant,
        name='严进仓',
        mode=basic_models.WareHouseModeEnum.RESTRICT_IN,
    )
    warehouse_relaxed = basic_models.WareHouse.objects.create(
        merchant=merchant,
        name='宽进仓',
        mode=basic_models.WareHouseModeEnum.UNRESTRICTED,
    )
    category = basic_models.ProductCategory.objects.create(
        merchant=merchant,
        name='面料',
        product_prefix='FAB',
    )
    product = basic_models.Product.objects.create(
        merchant=merchant,
        category=category,
        name='测试面料',
        human_id='FAB-001',
        unit=basic_models.ProductUnitEnum.METER,
    )
    operator = basic_models.Employee.objects.create(
        merchant=merchant,
        name='经办人',
        status=basic_models.EmployeeStatusEnum.ACTIVE,
    )
    return merchant, supplier, warehouse_strict, warehouse_relaxed, product, operator


def create_sales_fixtures():
    merchant = basic_models.Merchant.objects.create(
        name='销售商户',
        type=basic_models.MerchantTypeEnum.FACTORY,
    )
    basic_models.MerchantSetting.objects.create(
        merchant=merchant,
        key=basic_models.MerchantSettingKeyEnum.AUTO_CREATE_STOCK_CHANGE_TASKS,
        type=basic_models.MerchantSettingTypeEnum.BOOL,
        val_bool=True,
    )
    customer = basic_models.Customer.objects.create(
        merchant=merchant,
        name='客户A',
        mobile='13800000000',
        created_by=None,
    )
    warehouse_strict = basic_models.WareHouse.objects.create(
        merchant=merchant,
        name='销售严进仓',
        mode=basic_models.WareHouseModeEnum.RESTRICT_IN,
    )
    warehouse_relaxed = basic_models.WareHouse.objects.create(
        merchant=merchant,
        name='销售宽进仓',
        mode=basic_models.WareHouseModeEnum.UNRESTRICTED,
    )
    warehouse_strict_out = basic_models.WareHouse.objects.create(
        merchant=merchant,
        name='销售严出仓',
        mode=basic_models.WareHouseModeEnum.RESTRICT_IN_OUT,
    )
    category = basic_models.ProductCategory.objects.create(
        merchant=merchant,
        name='销售品类',
        product_prefix='SAL',
    )
    product = basic_models.Product.objects.create(
        merchant=merchant,
        category=category,
        name='销售面料',
        human_id='SAL-001',
        unit=basic_models.ProductUnitEnum.METER,
    )
    operator = basic_models.Employee.objects.create(
        merchant=merchant,
        name='销售员',
        status=basic_models.EmployeeStatusEnum.ACTIVE,
    )
    return merchant, customer, warehouse_strict, warehouse_relaxed, warehouse_strict_out, product, operator
