InvoiceModel

The InvoiceModel object represents a model added to an invoice. In EPASS, a model is a product that a customer can purchase, such as a stove or a dishwasher.

Add a Model to an Invoice


POST /invoicing/invoice/model/add


This endpoint adds a product model to an open invoice. Models can’t be added to EPASS without an existing open invoice to add them to.

Invoice Conditions

An invoice must meet this list of conditions before you can add a model to it.

Condition Value
Invoice Status Invoice Status must be Open or Committed.
Branch Code The invoice must have a valid Branch Code. If not provided, it will use the branch supplied during the login process, and if that is empty, it uses the constant value Default.
Invoice JobStatus If the Invoice JobStatus has Require All Serials to be Reserved enabled then you cannot add InvoiceModel records via the API.
Any Job Status cascading that is configured in EPASS will be enforced through the API.
Estimate If the Invoice is an estimate then there are no restrictions related to the customer being allowed to charge or credit limits.
Bill To Customer BillToCustomer must be allowed to charge if the invoice is not estimate and the payment type is AR.
Credit Limits will be enforced in the following situation:
- The invoice is not an estimate
- Credit Limit is enabled for the Customer
- The Invoice Payment Type is AR
- Require Credit Approval is disabled
- Either the Job Status is dispatchable or Dispatching is disabled completely

Payload

Required Fields

The following fields are the absolute minimum fields that should be required to add a model to an invoice.

Field Type Description
InvoiceCode string Must be a valid Invoice Code.
QtyOrdered integer If not provided, default to 1. Must be greater than zero.
ModelCode string Must be a valid Model Code that is not Substituted.
If To Be Discontinued is checked for the model we will return a warning message.
If the Invoice Variables option Prevent Selling Obsolete Items/Models is True then model code cannot be obsolete.
If the Invoice Variables option Prevent Selling Inactive Items/Models is True then model code must be active.
UserCreated string Must be a valid User Code that is not Obsolete. If not provided it will use the Login User.

ModelCode

If a valid ModelCode is provided then the following values will be defaulted from the Model. You can override any of the values that would come from the Model by providing your own value.

Key Value
ModelDesc Model -> Description
Color Model -> Color
Features Model -> FeaturesCode.Description
Tax1 Model -> Tax1
Tax2 Model -> Tax2
Tax3 Model -> Tax3
Tax1CostList Model -> Tax1CostList
Tax1Included Model -> Tax1Included
Tax1Percentage Model -> Tax1Percentage if Tax1Included is True
StandardCost If the Invoice Type is configured to set Standard Cost to either the Project Cost from a specific List Price, or the Project Cost from a Customer Project, then that cost will be used for StandardCost.
Otherwise it will come from the Model.StandardCost.
LandedCost If the Invoice Type is configured to set LandedCost to either the Project Cost from a specific List Price, or the Project Cost from a Customer Project, then that cost will be used for LandedCost.
Otherwise it will come from the Model.LandedCost.
ReplacementCost If the Invoice Type is configured to set ReplacementCost to either the Project Cost from a specific List Price, or the Project Cost from a Customer Project, then that cost will be used for ReplacementCost.
Otherwise it will come from the Model.ReplacementCost.
OriginalCost If the Invoice Type is configured to set OriginalCost to either the Project Cost from a specific List Price, or the Project Cost from a Customer Project, then that cost will be used for OriginalCost.
Otherwise it will come from the Model.OriginalCost.
AverageCost Model -> AverageCost
LastCost Model -> LastCost
NewUsed Model -> NewUsed
ManufacturersWarranty Model -> ManufacturersWarranty
Spiff Model -> Spiff if the Invoice Type option Spiff Number is 1 and the current date is between Model.SpiffStartDate and Model.SpiffEndDate.
Model -> Spiff2 if the Invoice Type option Spiff Number is 2 and the current date is between Model.Spiff2StartDate and Model.Spiff2EndDate.

Potentially Required Fields

These fields may be required depending on your EPASS configuration, or there is unique behavior that needs to be mentioned.

Field Type Value
Color string If the Invoice Type option Require Model Color is True, then the Color field is required.
Cube integer This is the Model.Points (or the Product.Points if the Model.Points is 0).
Points integer This is the Model.Points (or the Product.Points if the Model.Points is 0).
Reference string If the Invoice Type option Require Reference is True, then the Reference field is required.
SellingPrice integer If the BillTo customer has a valid project code, then the SellingPrice cannot be less than the project price.
If the Model has a valid SalesPrice1, then the SellingPrice cannot be less than SalePrice1.
If the Model has a valid SalesPrice2, then the SellingPrice cannot be less than SalePrice2.
If the BillTo customer does not have a valid project code and the Invoice Type option Disable Min Selling Price is not checked, then the SellingPrice cannot be less than Minimum Selling Price.
ServiceTime integer This is the Model.InstallationEstimate (or the Product.InstallationEstimate if the Model.InstallationEstimate is 0).

addRelatedLines

The adding of related detail lines can be controlled using the “addRelatedLines” section. If not provided then no related detail lines will be added.

Key Value Description
Comment boolean Determines if related Comment lines are added
Misc boolean Determines if related Misc lines are added
MiscEcoFees boolean Determines if related Eco Fees are added

Sample: Adding a Model to an Invoice

POST /invoicing/invoice/model/add  

{
    "userCreated": null,
    "color": null,
    "reference": null,
    "tripNo": null,
    "branchCode": null,
    "featuresCode": null,
    "features": null,
    "invoiceCode": "123456",
    "locationCode": "190",
    "modelCode": "AHD25SSS1",
    "qtyOrdered": null,
    "sellingPrice": 549.99,
    "tax2": null,
    "tax3": null,
    "addRelatedLines": {
        "Misc": false,
        "MiscEcoFees": false,
        "Comment": false
    }
}
  
 {
    "success": true,
    "warning": false,
    "httpStatusCode": 201,
    "generalMessage": null,
    "exceptionMessage": null,
    "keys": [
        {
            "table": "InvoiceModel",
            "keys": [
                {
                    "key": "ID",
                    "fields": [
                        {
                            "fieldName": "ID",
                            "fieldValue": 27
                        }
                    ]
                }
            ]
        },
        {
            "table": "InvoiceAddress",
            "keys": [
                {
                    "key": "ID",
                    "fields": [
                        {
                            "fieldName": "ID",
                            "fieldValue": 123456
                        }
                    ]
                }
            ]
        },
        {
            "table": "InvoiceAudit",
            "keys": [
                {
                    "key": "ID",
                    "fields": [
                        {
                            "fieldName": "ID",
                            "fieldValue": 123456
                        }
                    ]
                }
            ]
        }
    ],
    "messages": [],
    "warnings": []
}
 {
    "success": false,
    "warning": false,
    "httpStatusCode": 422,
    "generalMessage": "One or more of the fields has an invalid or missing value.",
    "exceptionMessage": null,
    "keys": [],
    "messages": [
        {
            "code": "INV-09002",
            "message": "InvoiceCode is required."
        }
    ],
    "warnings": []
}