Coder Social home page Coder Social logo

morgan-stanley-pl's People

Contributors

ncortines avatar rano99 avatar sanchin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

morgan-stanley-pl's Issues

Error when 'No Data Available for the Criteria Selected'

The script Throws Error:

fetching data...
VM231:254 please ignore the "GET https://api.nbp.pl/api/exchangerates/rates/a/usd/YYYY-MM-DD/?format=json 404 (Not Found - Brak danych)" errors logged on the console by the browser - THEY ARE EXPECTED
(anonymous) @ VM231:254
(anonymous) @ VM231:270
undefined
VM231:269 ups!, TypeError: Cannot read property 'filter' of undefined

When there is no data from Morgan Stanley provided for the range of dates defined in Filter:
const PERIOD_START = '2016-01-01'
const PERIOD_END = '2016-31-12'
You can check this by going: MorganStanley (www) -> Activity (tab) -> Change Date (link) -> Previous Year (option)

Solution:

  • You don't need to see any results - you got nothing to declare from this source of income
  • Change Filter dates to desired period

PIT 2017 form changes

This issue is track changes in the PIT form(s)

Some user has reported these changes in form PIT-38
p.36 -> p.35
p.37 -> p.36

Wrong sale date with limited order

When a sale originates from a limited order, a wrong date is used for the sale. The date when the order was placed is used. The actual sale date should be used instead.

Cash withdrawals

Currently withdrawals from cash account cause the script to fail.
Need to fix the script to ignore cash withdrawals.

What about dividends?

I know that for 2018 we no longer have to pay income tax for stock vesting (capital gains tax after selling), but what about dividends?

I mean - the difference between US (15%) and Poland (19%) that resulted in the laughably small tax in most cases (couple gr for starters). I think the new law about vesting doesn't say anything in that regard.

Static currency exchange rates

In order to avoid third-party libraries, services, CORS, etc., the currency exchange rates need to be hardcoded inside the script

Moreover npb.pl's API does not support CORS

To resolve this limitation the best solution would be to deploy a local service on the client machine which would fetch the rates on the fly

The main script would still be executed from the Console as it is now but, instead of having a set currency exchange rates hardcoded, it would be able to fetch any exchange rate on demand via REST on http://localhost:{port-number}/{currency-date}

For convenience, this service could be distributed as a NPM package

A less transparent and expensive solution would involve hosting this service

Wrong PIT fields

In the output csv file, the following label is wrong as of 2018:

total profit pln (PIT/ZG p, 31):

Instead it should say:

total profit pln (PIT/ZG p, 32):

Problem with "Release Shared" records

This issue was introduced with the fix for #5

As the transaction type was changed from "Release" to "Release Shared" the script does not calculate correctly income in situations when there are shares which are withheld to cover the tax. In that case "Release" means all shares, and "Release Shared" means net shares released after taxation. I think (not sure about that) for tax purpose we need the full amount which is "Release", not "Release Shared".

Tax law changes 2019

It seems like new tax law changes are being introduced in 2019.

From now on, the tax calculation will be simplified since we will only pay for shares sold in a given year (we will not longer pay for the fact we got them).

Questions to be answered:

  • Do these changes affect PIT for 2018?
  • When these changes take effect, at the moment to fill in PIT, how to compensate if we already paid for shares we got but didn't sell yet?

Incorrect dates in dividend details

The script seems to handle dates for dividends improperly in my case, but works ok for share releases.

I have the following dividends for 2017:
screen shot 2018-05-05 at 11 47 04

However, they are being reported by the script as:
screen shot 2018-05-05 at 11 49 02

This results in the exchange rates being checked for improper days, which results in wrong PLN amounts.

What is more, the JSON from morgan stanley seems to be ok, e.g. for the second one:

				{
					"salePrice": "$61.1626",
					"uniqueRowId": "2",
					(...)
					"transTypeForUIRef": "Dividend Reinvested",
					"orderDate": "01/01/1900",
					(...)
					"tradeDate": "07/18/2017",
					(...)
					"transactionType": "Dividend Reinvested",
					"uniqueProductType": "RESTRICTED_STOCK",
					"segmentIdAvailable": true
				},

Problem with "Release" records

For some reason, some people don't have "Release" records, only "Released Shared" records. I guess most people have both records generated when releases are vested.
Since both records seem to have the same date and value, it is safe to default to use "Released Shared" instead of "Release" records

No exchange rate found (3 days easter holiday)

By default, the script goes up to 3 days back on time to find the exchange rate.
However, in 2017 there was 3 days period (easter) in which there were no exchange rates published.
Solution is to change 3 to 4 for the retry count.

Wrong PIT-36 fields

The script currently says:

total dividend 19% tax pln (PIT-36 p. 387)
total dividend 15% (*) tax withhold (PIT-36 p. 389)

I believe it should say 413 and 415 respectively, right now (but I'm just guessing based on some discussion and screenshots from last year and matching the fields on that screenshot so better double-check these field numbers yourself)

Some syntax issues?

Hi @ncortines I tried running the script for 2020 tax year, and I had to change boolean compounds order at the beginning of processSaleDetails to:

        const saleDateString = sale.withdrawalDate || sale.order.uniqueFillDate
        return getExchangeRate(new Date(saleDateString))
            .then(sellExchangeRate => {
                const longTermCostTransactions = (sale.costBasis && sale.costBasis.longTerm && sale.costBasis.longTerm.rows) || []
                const shortTermCostTransactions = (sale.costBasis && sale.costBasis.shortTerm && sale.costBasis.shortTerm.rows) || []

because sale.order arrived undefined, and so did sale.costBasis. Not sure why.

Also, I'm getting Uncaught (in promise) TypeError: can't convert undefined to object in stringifyList. The stringified data is as follows:

0: "sales summary:"
​"1.0.date": "2020-08-06"
​"1.0.settlement date": "2020-08-10"
​"1.0.quantity": "0.00"
​"1.0.exchange rate": "3.71"
​"1.0.earnings usd": "0.00"
​"1.0.earnings pln": "0.00"
​"1.0.cost pln": "0.00"
​"1.0.fees usd": "50.05"
​"1.0.fees pln": "185.90"
​"1.0.cost + fees pln": "185.90"
​2: "total earnings pln (PIT-38 p. 22): 0.00"
​3: "total earnings cost (with fees) pln (PIT-38 p. 23): 666.66"
​4: "total profit pln (PIT/ZG p. 32): -666.66"
​5: "breakdown of sale from 2020-08-06:"
​7: "dividends summary:"
​"8.0.date": "2020-07-22"
​"8.0.exchange rate": "3.88"
​"8.0.amount usd": "66.66"
​"8.0.amount pln": "66.66"
​9: "total dividend earnings pln: 66.66"
​10: "total dividend 19% tax pln (PIT-38 p. 45): 66.66"
​11: "total dividend 15% (*) tax withhold (PIT-38 p. 46): 66.66"
​12: "(*) Assuming you filled in W-8BEN. Otherwise adjust this number"

I changed some sensitive data to "666"/"66", but what's also interesting is that the "total profit pln" field has a negative value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.