2
I’m a beginner and I’m stuck on the invoice closing validation. I built a list in this format:
[
date: '2017-5-9', value: '59.99', type: 'credit', typePag: 1 },
{ date: '2017-12-17',value: 'R$ 151.08',type: 'debit', typePag: 2 }
];
What I need:
We have closing the credit card on the 5th of every right month, the installment always falls on the 10th, a purchase or payment made on the day 2017-01-05 onwards the first installment falls on the day 2017-02-10, in case it has on the day 2017-01-03 will fall in 2017-01-10.
Ai in case if the payment is debit, it will fall at the same instant described in the date column.
I tried so many ways and ended up not getting.
What I tried to do, I created a go through, in that I checked the dates if it is > 5/02 and if it was credit he added the value to the invoice of the month q comes or be 10/03, and if it was debit he would already add the value for the day, if it was <5 would fall in the invoice of the same month. did something like that
Note: I am using nodejs. And how do I submit to an api ?
Now I have doubts: In the case of credit, how do you know that it is a purchase and if it is the first payment ? ... If you made a purchase using credit on the date: 2018-04-02 the first instalment would be on the date 2018-05-10 correct ? Then the closing of this installment would be in the month 06?
– NoobSaibot
Opa good afternoon, The typePag Field: 1 would be sale, 2 would be purchase. 2 Referent " the first installment would be on the date 2018-05-10 correct ? So the closing of this installment would be in the month 06? "Yes correct a purchase or a sale if it is > 5 the installment will fall in the following month.
– Samael Pereira Simões
Sorry for the delay, just one more question, if it is debit and the purchase is made between > 5/02 and < 10/02 would fall in the same month ? I have an example almost ready, and rereading your question arose this question.
– NoobSaibot
if it is larger than day 5 the invoice will fall in the one of the following month, if it is less than 5 will fall in the invoice of the same month
– Samael Pereira Simões