Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Date handling doesn't work very well. #2

@spadusa

Description

@spadusa

If I try to create a new Payment on an Invoice, I might do something like this:

let newPayment: Payment = {
                            type: 'Payment',
                            invoice: {
                                id: '123123'
                            },
                            paymentDate: '2016-12-05',
                            appliedBy: 'SomeSource',
                            amount: '400'
                        };

connectwise.InvoicePaymentsApi.financeInvoicesIdPaymentsPost({id: 123123, payment: newPayment})

And it would submit a request with the date. And it would fail on the CW side with an Unsupported format applied to paymentDate. Further, Typescript throws a Type warning on the paymentDate line because it's defined as a Date type and not a string type.

if I change the paymentDate line to
paymentDate: new Date()

Now Typescript doesn't complain about it, but CW still does as it gets sent out as paymentDate: "2016-12-30T05:00:00.000Z"

I'd recommend either handling all dates in a consistent manner, or if time is a constraint, making all date fields a union type of string|Date and let the individual dev pass it in the correct format without TypeScript yelling about it.

Ultimately I'm using MomentJS for all my datetime stuff, so I'm just going to ignore the Typescript complaining for now. However, I'm sure you know that it's a real pain for the IDE to complain about this while Typescript still compiles and works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions