# This file is part of Tryton.  The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta
from trytond.pyson import Eval

UNCL5189 = [
    ('1', "Handling commission"),
    ('2', "Amendment commission"),
    ('3', "Acceptance commission"),
    ('4', "Commission for obtaining acceptance"),
    ('5', "Commission on delivery"),
    ('6', "Advising commission"),
    ('7', "Confirmation commission"),
    ('8', "Deferred payment commission"),
    ('9', "Commission for taking up documents"),
    ('10', "Opening commission"),
    ('11', "Fee for payment under reserve"),
    ('12', "Discrepancy fee"),
    ('13', "Domicilation commission"),
    ('14', "Commission for release of goods"),
    ('15', "Collection commission"),
    ('16', "Negotiation commission"),
    ('17', "Return commission"),
    ('18', "B/L splitting charges"),
    ('19', "Trust commission"),
    ('20', "Transfer commission"),
    ('21', "Commission for opening irrevocable documentary credits"),
    ('22', "Pre-advice commission"),
    ('23', "Supervisory commission"),
    ('24', "Model charges"),
    ('25', "Risk commission"),
    ('26', "Guarantee commission"),
    ('27', "Reimbursement commission"),
    ('28', "Stamp duty"),
    ('29', "Brokerage"),
    ('30', "Bank charges"),
    ('31', "Bank charges information"),
    ('32', "Courier fee"),
    ('33', "Phone fee"),
    ('34', "Postage fee"),
    ('35', "S.W.I.F.T. fee"),
    ('36', "Telex fee"),
    ('37', "Penalty for late delivery of documents"),
    ('38', "Penalty for late delivery of valuation of works"),
    ('39', "Penalty for execution of works behind schedule"),
    ('40', "Other penalties"),
    ('41', "Bonus for works ahead of schedule"),
    ('42', "Other bonus"),
    ('44', "Project management cost"),
    ('45', "Pro rata retention"),
    ('46', "Contractual retention"),
    ('47', "Other retentions"),
    ('48', "Interest on arrears"),
    ('49', "Interest"),
    ('50', "Charge per credit cover"),
    ('51', "Charge per unused credit cover"),
    ('52', "Minimum commission"),
    ('53', "Factoring commission"),
    ('54', "Chamber of commerce charge"),
    ('55', "Transfer charges"),
    ('56', "Repatriation charges"),
    ('57', "Miscellaneous charges"),
    ('58', "Foreign exchange charges"),
    ('59', "Agreed debit interest charge"),
    ('60', "Manufacturer's consumer discount"),
    ('61', "Fax advice charge"),
    ('62', "Due to military status"),
    ('63', "Due to work accident"),
    ('64', "Special agreement"),
    ('65', "Production error discount"),
    ('66', "New outlet discount"),
    ('67', "Sample discount"),
    ('68', "End-of-range discount"),
    ('69', "Charge for a customer specific finish"),
    ('70', "Incoterm discount"),
    ('71', "Point of sales threshold allowance"),
    ('72', "Technical modification costs"),
    ('73', "Job-order production costs"),
    ('74', "Off-premises costs"),
    ('75', "Additional processing costs"),
    ('76', "Attesting charge"),
    ('77', "Rush delivery surcharge"),
    ('78', "Special construction costs"),
    ('79', "Freight charges"),
    ('80', "Packing charge"),
    ('81', "Repair charge"),
    ('82', "Loading charge"),
    ('83', "Setup charge"),
    ('84', "Testing charge"),
    ('85', "Warehousing charge"),
    ('86', "Gold surcharge"),
    ('87', "Copper surcharge"),
    ('88', "Material surcharge/deduction"),
    ('89', "Lead surcharge"),
    ('90', "Price index surcharge"),
    ('91', "Platinum surcharge"),
    ('92', "Silver surcharge"),
    ('93', "Wolfram surcharge"),
    ('94', "Aluminum surcharge"),
    ('95', "Discount"),
    ('96', "Insurance"),
    ('97', "Minimum order / minimum billing charge"),
    ('98', "Material surcharge (special materials)"),
    ('99', "Surcharge"),
    ('100', "Special rebate"),
    ('101', "Carbon footprint charge"),
    ('102', "Fixed long term"),
    ('103', "Temporary"),
    ('104', "Standard"),
    ('105', "Yearly turnover"),
    ]
UNCL7161 = [
    ('AA', "Advertising allowance"),
    ('AAA', "Telecommunication charges"),
    ('AAB', "Returned goods charges"),
    ('AAC', "Modification costs"),
    ('AAD', "Job-order production"),
    ('AAE', "Outlays"),
    ('AAF', "Off-premises surcharge"),
    ('AAG', "Gold surcharge"),
    ('AAH', "Processing surcharge"),
    ('AAI', "Attestation fee"),
    ('AAJ', "Copper surcharge"),
    ('AAK', "Energy surcharge"),
    ('AAL', "Deduction for missing parts"),
    ('AAM', "Rubber surcharge"),
    ('AAN', "Brass surcharge"),
    ('AAO', "Material surcharge/deduction"),
    ('AAP', "Lead surcharge"),
    ('AAQ', "Price index surcharge"),
    ('AAR', "Platinum surcharge"),
    ('AAS', "Acceptance cost"),
    ('AAT', "Rush delivery"),
    ('AAU', "Selenium surcharge"),
    ('AAV', "Special construction charge"),
    ('AAW', "Deduction for delayed return"),
    ('AAX', "Wolfram surcharge"),
    ('AAY', "Airport fee"),
    ('AAZ', "Concession fee"),
    ('ABA', "Compulsory storage fee"),
    ('ABB', "Defuel"),
    ('ABC', "Into plane fee"),
    ('ABD', "Overtime"),
    ('ABE', "Reservicing charge"),
    ('ABF', "Tooling cost"),
    ('ABG', "Tooling charge"),
    ('ABH', "Throughput allowance"),
    ('ABI', "Superfund fee"),
    ('ABJ', "Airport system fee"),
    ('ABK', "Miscellaneous"),
    ('ABL', "Packaging surcharge"),
    ('ABM', "Scrap surcharge"),
    ('ABN', "Dunnage charge"),
    ('ABO', "Air freight transportation"),
    ('ABP', "Carriage charge"),
    ('ABQ', "Tonnage rebate"),
    ('ABR', "Containerisation"),
    ('ABS', "Carton packing"),
    ('ABT', "Hessian wrapped"),
    ('ABU', "Polyethylene wrap packing"),
    ('ABV', "Miscellaneous customs charge"),
    ('ABW', "Customs duty charge"),
    ('ABX', "Miscellaneous special tooling charge"),
    ('ABY', "Tooling amortisation"),
    ('ABZ', "Miscellaneous rebate or discount"),
    ('ACA', "Allowance"),
    ('ACB', "Future discount off retail"),
    ('ACC', "Miscellaneous setting costs (tooling)"),
    ('ACD', "Minimum amount costs for quantity based surcharges"),
    ('ACE', "Below schedule quantity after quantity-based surcharge"),
    ('ACF', "Miscellaneous treatment"),
    ('ACG', "Enamelling treatment"),
    ('ACH', "Heat treatment"),
    ('ACI', "Plating treatment"),
    ('ACJ', "Painting"),
    ('ACK', "Polishing"),
    ('ACL', "Priming"),
    ('ACM', "Preservation treatment"),
    ('ACN', "Miscellaneous other surcharges"),
    ('ACO', "Alloy surcharge"),
    ('ACP', "Coke surcharge"),
    ('ACQ', "Royalty surcharge"),
    ('ACR', "Wheel handling charge"),
    ('ACS', "Fitting surcharge"),
    ('ACT', "Non-standard surcharge"),
    ('ACU', "Standard surcharge"),
    ('ACV', "Wheel surcharge"),
    ('ACW', "Washer surcharge"),
    ('ACX', "Ocean freight charge"),
    ('ACY', "Container deposit charge"),
    ('ACZ', "Damaged merchandise"),
    ('ADA', "Bopsheet charge"),
    ('ADB', "Drum deposit"),
    ('ADC', "Consolidation"),
    ('ADD', "Inland transportation"),
    ('ADE', "Bill of lading charge"),
    ('ADF', "Excise tax-destination"),
    ('ADG', "Customs bond charge"),
    ('ADH', "Per pound charge"),
    ('ADI', "Royalties"),
    ('ADJ', "Airbag charge"),
    ('ADK', "Transfer charge"),
    ('ADL', "Slipsheet charge"),
    ('ADM', "Binding services"),
    ('ADN', "Repair or replacement of broken returnable package"),
    ('ADO', "Efficient logistics"),
    ('ADP', "Merchandising"),
    ('ADQ', "Product mix"),
    ('ADR', "Other services"),
    ('ADS', "Full pallet ordering"),
    ('ADT', "Pick-up"),
    ('ADU', "Handling by the 1st level sub-contractor"),
    ('ADV', "Handling by the 2nd level sub-contractor"),
    ('ADX', "Handling by the contractor"),
    ('ADY', "New product introduction"),
    ('ADZ', "Direct delivery"),
    ('AEA', "Diversion"),
    ('AEB', "Disconnect"),
    ('AEC', "Distribution"),
    ('AED', "Handling of hazardous cargo"),
    ('AEF', "Rents and leases"),
    ('AEG', "System usage"),
    ('AEH', "Location differential"),
    ('AEI', "Aircraft refueling"),
    ('AEJ', "Fuel shipped into storage"),
    ('AG ', "Silver surcharge"),
    ('AJ ', "Adjustments"),
    ('AL ', "Aluminium surcharge"),
    ('AM ', "Additional material"),
    ('AU ', "Authentication charge"),
    ('CA ', "Cataloguing services"),
    ('CAA', "Cancellation charge"),
    ('CAB', "Cartage"),
    ('CAC', "Cash discount"),
    ('CAD', "Certification fee"),
    ('CAE', "Certificate of conformance"),
    ('CAF', "Certificate of origin"),
    ('CAG', "Competitive allowance"),
    ('CAH', "Competitive auto allowance"),
    ('CAI', "Cutting charge"),
    ('CAJ', "Consular costs"),
    ('CAK', "Customer collection rebate"),
    ('CB ', "Commission"),
    ('CD ', "Car loading"),
    ('CG ', "Cleaning charge"),
    ('CK ', "COD charge"),
    ('CL ', "Contract allowance"),
    ('CO ', "Cents off"),
    ('CP ', "Competitive price"),
    ('CS ', "Cigarette stamping"),
    ('CT ', "Count and recount"),
    ('CW ', "Container allowance"),
    ('DA ', "Defective allowance"),
    ('DAA', "Deficit freight"),
    ('DAB', "Layout/design"),
    ('DAD', "Driver assigned unloading"),
    ('DAE', "Distributor discount/allowance"),
    ('DI ', "Discount"),
    ('DL ', "Delivery"),
    ('DM ', "Demurrage"),
    ('EAA', "Early buy allowance"),
    ('EAB', "Early payment allowance"),
    ('EG ', "Engraving"),
    ('EP ', "Expediting premium"),
    ('ER ', "Exchange rate guarantee charge"),
    ('EX ', "Export shipping charge"),
    ('FA ', "Freight allowance"),
    ('FAA', "Fabrication charge"),
    ('FAB', "Freight equalization"),
    ('FAC', "Freight surcharge"),
    ('FC ', "Freight charge"),
    ('FG ', "Free goods"),
    ('FH ', "Filling/handling charge"),
    ('FI ', "Finance charge"),
    ('FN ', "Special finish charge"),
    ('FR ', "Flat rate"),
    ('GAA', "Grinding"),
    ('HAA', "Hose charge"),
    ('HD ', "Handling"),
    ('HH ', "Hoisting and hauling"),
    ('IA ', "Invoice adjustment"),
    ('IAA', "Installation"),
    ('IAB', "Installation and warranty"),
    ('ID ', "Inside delivery charge"),
    ('IF ', "Inspection fee"),
    ('IN ', "Insurance"),
    ('IR ', "Installation and training"),
    ('IS ', "Invoice services"),
    ('KO ', "Koshering"),
    ('L1 ', "Shipper load, carrier count"),
    ('LA ', "Labelling"),
    ('LAA', "Labour charge"),
    ('LAB', "Labour (repair and return orders)"),
    ('LAC', "License fee"),
    ('LF ', "Legalisation fee"),
    ('LS ', "Local sales tax"),
    ('MA ', "Material allowance (special materials)"),
    ('MAA', "Mileage or travel"),
    ('MAB', "Mileage fee (for repair and return)"),
    ('MAC', "Minimum order/minimum billing charge"),
    ('MAD', "Monthly rental"),
    ('MAE', "Mounting"),
    ('MC ', "Material surcharge (special materials)"),
    ('MI ', "Mail invoice"),
    ('ML ', "Mail invoice to each location"),
    ('NAA', "Non-returnable containers"),
    ('OA ', "Outside cable connectors"),
    ('OAA', "Overtime loading"),
    ('PA ', "Pack invoice with shipment"),
    ('PAA', "Phosphatizing (steel treatment)"),
    ('PAB', "Postage charge"),
    ('PAC', "Premium charge"),
    ('PAD', "Promotional allowance"),
    ('PAE', "Promotional discount"),
    ('PC ', "Packing"),
    ('PD ', "Palladium surcharge"),
    ('PI ', "Pick-up allowance"),
    ('PL ', "Palletizing"),
    ('PN ', "Pallet charge"),
    ('PO ', "Per order charge"),
    ('QAA', "Quantity surcharge"),
    ('QD ', "Quantity discount"),
    ('RAA', "Rebate"),
    ('RAB', "Repack charge"),
    ('RAC', "Repair"),
    ('RAD', "Returnable container"),
    ('RAE', "Resellers discount"),
    ('RAF', "Restocking charge"),
    ('RAG', "Roll rebate"),
    ('RAH', "Road/rail tanker rebate"),
    ('RE ', "Re-delivery charge"),
    ('RF ', "Refurbishing charge"),
    ('RH ', "Rail wagon hire"),
    ('RO ', "Roe allowance/charge"),
    ('RP ', "Repair charge"),
    ('RV ', "Freight charge/costs of loading"),
    ('SA ', "Salvage"),
    ('SAA', "Shipping and handling"),
    ('SAB', "Special allowance"),
    ('SAC', "Special credit"),
    ('SAD', "Special packaging"),
    ('SAE', "Stamping"),
    ('SAF', "Supplemental items"),
    ('SAG', "Surcharge (dollar value)"),
    ('SAH', "Surcharge (percentage)"),
    ('SAI', "Shipper load, consignee unload"),
    ('SAJ', "Small packages charge"),
    ('SC ', "Surcharge"),
    ('SD ', "Shrinkage allowance"),
    ('SF ', "Special rebate"),
    ('SG ', "Shrink-wrap charge"),
    ('SH ', "Special handling service"),
    ('SM ', "Special finish"),
    ('ST ', "Stamp duties"),
    ('SU ', "Set-up"),
    ('SZ ', "Steel surcharge"),
    ('TAA', "Telephone charge"),
    ('TAB', "Tank rental"),
    ('TAC', "Testing charge"),
    ('TAD', "Testing allowance"),
    ('TAE', "Truckload discount"),
    ('TD ', "Trade discount"),
    ('TS ', "State tax"),
    ('TT ', "Transportation - third party billing"),
    ('TV ', "Transportation - vendor provided"),
    ('TX ', "Tax"),
    ('TZ ', "Temporary allowance"),
    ('UM ', "Unsaleable merchandise allowance"),
    ('V1 ', "Drop yard"),
    ('V2 ', "Drop dock"),
    ('VAA', "Vendor freight"),
    ('VAB', "Volume discount"),
    ('VL ', "Vehicle load allowance"),
    ('WH ', "Warehousing"),
    ('XAA', "Combine all same day shipment"),
    ('YY ', "Split pickup"),
    ('ZZZ', "Mutually defined"),
    ]


class Uom(metaclass=PoolMeta):
    __name__ = 'product.uom'

    unece_code = fields.Char("UNECE Code",
        domain=[
            ('unece_code', 'not in', ['ZZ', 'XZZ']),
            ],
        help="Standard code of "
        "the United Nations Economic Commission for Europe.")


class Template(metaclass=PoolMeta):
    __name__ = 'product.template'

    unece_allowance_charge_code = fields.Selection(
        [(None, "")] + UNCL5189,
        "UNECE Allowance/Charge Code",
        states={
            'invisible': Eval('type') != 'service',
            },
        help="Standard code of "
        "the United Nations Economic Commission for Europe.")
    unece_special_service_code = fields.Selection(
        [(None, "")] + UNCL7161,
        "UNECE Special Service Code",
        states={
            'invisible': Eval('type') != 'service',
            },
        help="Standard code of "
        "the United Nations Economic Commission for Europe.")


class Product(metaclass=PoolMeta):
    __name__ = 'product.product'
