using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using Sockeye.Biz;

namespace Sockeye.Models
{
    public class Purchase : ICoreBizObjectModel
    {
        public long Id { get; set; }
        public uint Concurrency { get; set; }
        public long? CustomerId { get; set; }
        public string RegTo { get; set; }
        public long? LicenseId { get; set; }//when null and also when pgroup is a licenseable type means it shoudl be processed by SockBotProcessPurchases license gen
        [NotMapped]
        public string CustomerViz { get; set; }
        [Required]
        public long VendorId { get; set; }
        [NotMapped]
        public string VendorViz { get; set; }
        public long? ProductId { get; set; }//When null means it's new and should be processed by SockbotProcessPurchases job into proper purchase record
        [Required]
        public ProductGroup PGroup { get; set; }
        [NotMapped]
        public string ProductViz { get; set; }
        public string SalesOrderNumber { get; set; }
        public string DbId { get; set; }//if a RAVEN order 
        /*
     "accounting": {
                "currency": "USD",
                "product_net": 577.5,
                "discount": 0.0,
                "product_vat": 75.08,
                "shipping": 0.0,
                "shipping_vat": 0.0,
                "eu_vat": -75.08,
                "margin_net": -29.05,
                "your_revenue": 548.45
    */
        public string Currency { get; set; }//All values sb US dollars, but just in case
        public decimal ProductNet { get; set; } = 0;//total billed for the product before taxes
        public decimal Discount { get; set; } = 0;
        public decimal VendorFee { get; set; } = 0;//margin_net charged by myCommerce; their fee for processing the order
        public decimal Revenue { get; set; } = 0;//amount we are paid for the order (product net - discount - vendorfee)



        [Required]
        public DateTime PurchaseDate { get; set; }
        public DateTime? ExpireDate { get; set; }
        public DateTime? CancelDate { get; set; }
        public string CouponCode { get; set; }
        public string Notes { get; set; }
        public bool RenewNoticeSent { get; set; } = false;
        public int Quantity { get; set; } = 1;
        public long? VendorNotificationId { get; set; }
        public bool Processed { get; set; } = false;//indicates it was fully processed and need not be processed by license generating jobs (all imported data set to processed)
        public string Wiki { get; set; }
        public List<string> Tags { get; set; }
        //workaround for notification    
        [NotMapped, JsonIgnore]
        public string Name { get; set; }

        public Purchase()
        {
            Tags = new List<string>();
        }

        [NotMapped, JsonIgnore]
        public SockType SType { get => SockType.Purchase; }
    }//eoc
}//eons

/*

## How to make test sales and product links in ShareIt

fake sale of v8 to get license emails to update rockfish to auto read in the deets
	FAKE CREDIT CARD
		I have generated a test credit card number for your account. Please use the following as the credit card number making sure to use the word test and the 12 digit number with no spaces. 
    You can use any valid information you would like for the other fields.
		test134661442658
		Expiration Date: any date in the future
		CVS code: 123
	Example typical database ID: 
	    tZy9aSHjacFf9a9v3EtzUqM1amq/eMvJa2nXswLle74=
	Links to purchase 
    $50 customization charge https://order.mycommerce.com/cart/new?vendorid=14466&PRODUCT%5B300525428%5D=1
      Use this for custom report work minimum $50 for small changes
                             
		subscription month to month https://order.mycommerce.com/cart/new?vendorid=14466&PRODUCT%5B301028467%5D=1
		subscription yearly https://order.mycommerce.com/cart/new?vendorid=14466&PRODUCT%5B301028468%5D=1
		Perpetual single license: https://order.mycommerce.com/cart/new?vendorid=14466&PRODUCT%5B301028314%5D=1		
		*** TESTING THIS ONE FIRST  Perpetual single one year maintenance ACTIVE DISCOUNT PRICE: https://order.mycommerce.com/cart/new?vendorid=14466&PRODUCT%5B301028315%5D=1		
		Perpetual single one year maintenance NEW FULL PRICE: https://order.mycommerce.com/cart/new?vendorid=14466&PRODUCT%5B301028317%5D=1		
		v7 single for comparison 300740315 https://order.mycommerce.com/cart/new?vendorid=14466&PRODUCT%5B300740315%5D=1
	Address to use for testing
		05-3610 Christie Parkway Courtenay B.C. Canada V9J 9T6

*/
