@stamhoofd/models 2.19.0 â 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/models/Member.js.map +1 -1
- package/dist/src/models/MemberResponsibilityRecord.d.ts +5 -0
- package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -1
- package/dist/src/models/MemberResponsibilityRecord.js +16 -1
- package/dist/src/models/MemberResponsibilityRecord.js.map +1 -1
- package/dist/src/models/Organization.d.ts +2 -0
- package/dist/src/models/Organization.d.ts.map +1 -1
- package/dist/src/models/Organization.js +19 -3
- package/dist/src/models/Organization.js.map +1 -1
- package/dist/src/models/RegisterCode.d.ts +0 -10
- package/dist/src/models/RegisterCode.d.ts.map +1 -1
- package/dist/src/models/RegisterCode.js +0 -86
- package/dist/src/models/RegisterCode.js.map +1 -1
- package/dist/src/models/STCredit.d.ts +0 -7
- package/dist/src/models/STCredit.d.ts.map +1 -1
- package/dist/src/models/STCredit.js +0 -69
- package/dist/src/models/STCredit.js.map +1 -1
- package/dist/src/models/STInvoice.d.ts +2 -20
- package/dist/src/models/STInvoice.d.ts.map +1 -1
- package/dist/src/models/STInvoice.js +0 -364
- package/dist/src/models/STInvoice.js.map +1 -1
- package/dist/src/models/STPendingInvoice.d.ts +1 -21
- package/dist/src/models/STPendingInvoice.d.ts.map +1 -1
- package/dist/src/models/STPendingInvoice.js +0 -213
- package/dist/src/models/STPendingInvoice.js.map +1 -1
- package/dist/src/models/UsedRegisterCode.d.ts +0 -5
- package/dist/src/models/UsedRegisterCode.d.ts.map +1 -1
- package/dist/src/models/UsedRegisterCode.js +0 -101
- package/dist/src/models/UsedRegisterCode.js.map +1 -1
- package/package.json +2 -2
- package/src/models/Member.ts +5 -5
- package/src/models/MemberResponsibilityRecord.ts +21 -2
- package/src/models/Organization.ts +23 -3
- package/src/models/RegisterCode.ts +0 -95
- package/src/models/STCredit.ts +0 -82
- package/src/models/STInvoice.ts +2 -433
- package/src/models/STPendingInvoice.ts +2 -247
- package/src/models/UsedRegisterCode.ts +0 -115
- package/dist/src/helpers/InvoiceBuilder.d.ts +0 -29
- package/dist/src/helpers/InvoiceBuilder.d.ts.map +0 -1
- package/dist/src/helpers/InvoiceBuilder.js +0 -407
- package/dist/src/helpers/InvoiceBuilder.js.map +0 -1
- package/dist/src/helpers/InvoiceBuilder.test.d.ts +0 -2
- package/dist/src/helpers/InvoiceBuilder.test.d.ts.map +0 -1
- package/dist/src/helpers/InvoiceBuilder.test.js +0 -52
- package/dist/src/helpers/InvoiceBuilder.test.js.map +0 -1
- package/src/helpers/InvoiceBuilder.test.ts +0 -57
- package/src/helpers/InvoiceBuilder.ts +0 -501
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { createMollieClient, SequenceType } from '@mollie/api-client';
|
|
2
1
|
import { column, ManyToOneRelation, Model } from "@simonbackx/simple-database";
|
|
3
|
-
import {
|
|
4
|
-
import { Email } from "@stamhoofd/email";
|
|
5
|
-
import { calculateVATPercentage, PaymentMethod, PaymentProvider, PaymentStatus, STInvoiceItem, STInvoiceMeta, STPackage as STPackageStruct, STPricingType, Version } from '@stamhoofd/structures';
|
|
6
|
-
import { Formatter } from "@stamhoofd/utility";
|
|
2
|
+
import { STInvoiceMeta } from '@stamhoofd/structures';
|
|
7
3
|
import { v4 as uuidv4 } from "uuid";
|
|
8
4
|
|
|
9
|
-
import {
|
|
10
|
-
import { MolliePayment, Organization, Payment, Registration, STCredit, STInvoice, STPackage } from './';
|
|
5
|
+
import { Organization } from './';
|
|
11
6
|
|
|
12
7
|
/**
|
|
13
8
|
* Things that should get paid, but are not yet invoiced yet because:
|
|
@@ -65,244 +60,4 @@ export class STPendingInvoice extends Model {
|
|
|
65
60
|
updatedAt: Date
|
|
66
61
|
|
|
67
62
|
static organization = new ManyToOneRelation(Organization, "organization");
|
|
68
|
-
|
|
69
|
-
static async getForOrganization(organizationId: string): Promise<STPendingInvoice | undefined> {
|
|
70
|
-
const invoices = await STPendingInvoice.where({ organizationId })
|
|
71
|
-
return invoices[0] ?? undefined
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Always run this in the queue!
|
|
76
|
-
*/
|
|
77
|
-
static async addItems(organization: Organization, invoiceItems: STInvoiceItem[]): Promise<STPendingInvoice | undefined> {
|
|
78
|
-
// Get the pending invoice if it exists
|
|
79
|
-
const pendingInvoice = await STPendingInvoice.getForOrganization(organization.id)
|
|
80
|
-
return await this.addItemsTo(pendingInvoice, organization, invoiceItems)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Always run this in the queue!
|
|
85
|
-
*/
|
|
86
|
-
static async addItemsTo(pendingInvoice: STPendingInvoice | undefined, organization: Organization, invoiceItems: STInvoiceItem[]): Promise<STPendingInvoice | undefined> {
|
|
87
|
-
if (invoiceItems.length > 0) {
|
|
88
|
-
if (!pendingInvoice) {
|
|
89
|
-
// Create one
|
|
90
|
-
pendingInvoice = new STPendingInvoice()
|
|
91
|
-
pendingInvoice.organizationId = organization.id
|
|
92
|
-
pendingInvoice.meta = STInvoiceMeta.create({
|
|
93
|
-
companyName: organization.meta.companyName ?? organization.name,
|
|
94
|
-
companyContact: organization.privateMeta.billingContact ?? "",
|
|
95
|
-
companyAddress: organization.meta.companyAddress ?? organization.address,
|
|
96
|
-
companyVATNumber: organization.meta.VATNumber,
|
|
97
|
-
VATPercentage: calculateVATPercentage(organization.meta.companyAddress ?? organization.address, organization.meta.VATNumber)
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
pendingInvoice.meta.items.push(...invoiceItems)
|
|
101
|
-
|
|
102
|
-
// Can we compress
|
|
103
|
-
if (pendingInvoice.invoiceId === null) {
|
|
104
|
-
console.log("Compressing pending invoice items "+pendingInvoice.id)
|
|
105
|
-
pendingInvoice.meta.items = STInvoiceItem.compress(pendingInvoice.meta.items)
|
|
106
|
-
}
|
|
107
|
-
await pendingInvoice.save()
|
|
108
|
-
}
|
|
109
|
-
return pendingInvoice
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Always run this in the queue!
|
|
114
|
-
*/
|
|
115
|
-
static async addAutomaticItems(organization: Organization): Promise<STPendingInvoice | undefined> {
|
|
116
|
-
// Get the pending invoice if it exists
|
|
117
|
-
const pendingInvoice = await STPendingInvoice.getForOrganization(organization.id)
|
|
118
|
-
|
|
119
|
-
// Generate temporary pending invoice items for the current state without adding them IRL
|
|
120
|
-
const notYetCreatedItems = await STPendingInvoice.createItems(organization.id, pendingInvoice)
|
|
121
|
-
return await this.addItemsTo(pendingInvoice, organization, notYetCreatedItems)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* This method checks all the packages of the given organization and will return
|
|
126
|
-
* new invoice items that should get charged. You'll need to add them to
|
|
127
|
-
* the pending invoice yourself (always in a queue!)
|
|
128
|
-
*/
|
|
129
|
-
static async createItems(organizationId: string, pendingInvoice?: STPendingInvoice) {
|
|
130
|
-
const packages = await STPackage.getForOrganization(organizationId)
|
|
131
|
-
|
|
132
|
-
// Always use midnight as a reference time (because this method should always return the same values if it called multiple times on the same day)
|
|
133
|
-
const today = new Date()
|
|
134
|
-
today.setHours(0, 0, 0, 0)
|
|
135
|
-
|
|
136
|
-
// But use now as reference for activation detection
|
|
137
|
-
const now = new Date()
|
|
138
|
-
|
|
139
|
-
let membersCount: number | null = null
|
|
140
|
-
const pendingItems: STInvoiceItem[] = []
|
|
141
|
-
|
|
142
|
-
for (const pack of packages) {
|
|
143
|
-
if (pack.meta.startDate > now) {
|
|
144
|
-
continue
|
|
145
|
-
}
|
|
146
|
-
if (pack.meta.pricingType === STPricingType.PerMember && (pack.validUntil === null || pack.validUntil >= today)) {
|
|
147
|
-
|
|
148
|
-
if (membersCount === null) {
|
|
149
|
-
membersCount = await Registration.getActiveMembers(organizationId)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Calculate the items that are already pending and remove them
|
|
153
|
-
const pendingCount = pendingInvoice ? pendingInvoice.meta.items.reduce((c, item) => c + ((item.package && item.package.id === pack.id) ? item.amount : 0), 0) : 0
|
|
154
|
-
const item = STInvoiceItem.fromPackage(STPackageStruct.create(pack), membersCount, pendingCount, today)
|
|
155
|
-
if (item.price > 0) {
|
|
156
|
-
console.log('Adding item to pending invoice', item)
|
|
157
|
-
pendingItems.push(item)
|
|
158
|
-
}
|
|
159
|
-
} else if ((pack.validUntil === null || pack.validUntil >= today) && pack.meta.paidAmount < pack.meta.minimumAmount) {
|
|
160
|
-
|
|
161
|
-
// Check if paid amount matches at least one
|
|
162
|
-
const pendingCount = pendingInvoice ? pendingInvoice.meta.items.reduce((c, item) => c + ((item.package && item.package.id === pack.id) ? item.amount : 0), 0) : 0
|
|
163
|
-
const item = STInvoiceItem.fromPackage(STPackageStruct.create(pack), 0, pendingCount, today)
|
|
164
|
-
if (item.price > 0) {
|
|
165
|
-
console.log('Adding item to pending invoice', item)
|
|
166
|
-
pendingItems.push(item)
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Add all payments that are not yet charged
|
|
172
|
-
|
|
173
|
-
return pendingItems
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
static async charge(organization: Organization) {
|
|
177
|
-
const pendingInvoice = await this.getForOrganization(organization.id)
|
|
178
|
-
|
|
179
|
-
if (!pendingInvoice || pendingInvoice.meta.priceWithVAT === 0) {
|
|
180
|
-
throw new SimpleError({
|
|
181
|
-
code: "no_pending_invoice",
|
|
182
|
-
message: "No pending invoice",
|
|
183
|
-
human: "Je kan op dit moment niet afrekenen omdat er geen openstaand bedrag is."
|
|
184
|
-
})
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (pendingInvoice.invoiceId !== null) {
|
|
188
|
-
throw new SimpleError({
|
|
189
|
-
code: "payment_pending",
|
|
190
|
-
message: "Payment pending",
|
|
191
|
-
human: "Er is momenteel al een afrekening in behandeling (dit kan 3 werkdagen duren), wacht enkele dagen voor je het opnieuw probeert."
|
|
192
|
-
})
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (organization.serverMeta.mollieCustomerId === undefined) {
|
|
196
|
-
throw new SimpleError({
|
|
197
|
-
code: "no_mollie_customer",
|
|
198
|
-
message: "No connected mollie customer",
|
|
199
|
-
human: "Er is nog geen domiciliÃĢring of automatische afrekening ingesteld"
|
|
200
|
-
})
|
|
201
|
-
}
|
|
202
|
-
// Step 1: create the invoice
|
|
203
|
-
const invoice = STInvoice.createFor(organization)
|
|
204
|
-
|
|
205
|
-
invoice.meta.items = pendingInvoice.meta.items.slice() // make a copy (needed to prevent mutating pending invoice and invoice at the same time)
|
|
206
|
-
|
|
207
|
-
if (invoice.meta.priceWithVAT == 0) {
|
|
208
|
-
throw new SimpleError({
|
|
209
|
-
code: "no_pending_invoice",
|
|
210
|
-
message: "No pending invoice",
|
|
211
|
-
human: "Je kan op dit moment niet afrekenen omdat er geen openstaand bedrag is."
|
|
212
|
-
})
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
await STCredit.applyCredits(organization.id, invoice, false)
|
|
216
|
-
|
|
217
|
-
const price = invoice.meta.priceWithVAT
|
|
218
|
-
|
|
219
|
-
// Create payment
|
|
220
|
-
const payment = new Payment()
|
|
221
|
-
payment.organizationId = null
|
|
222
|
-
payment.method = PaymentMethod.DirectDebit
|
|
223
|
-
payment.status = PaymentStatus.Created
|
|
224
|
-
payment.price = price
|
|
225
|
-
payment.paidAt = null
|
|
226
|
-
payment.provider = PaymentProvider.Mollie
|
|
227
|
-
await payment.save()
|
|
228
|
-
invoice.paymentId = payment.id
|
|
229
|
-
invoice.setRelation(STInvoice.payment, payment)
|
|
230
|
-
await invoice.save()
|
|
231
|
-
|
|
232
|
-
const description = "Stamhoofd - "+invoice.id
|
|
233
|
-
|
|
234
|
-
if (price <= 0) {
|
|
235
|
-
// Needs to happen before markPaid! (because the pending invoice will get modified)
|
|
236
|
-
pendingInvoice.invoiceId = invoice.id
|
|
237
|
-
await pendingInvoice.save()
|
|
238
|
-
|
|
239
|
-
await invoice.markPaid()
|
|
240
|
-
} else {
|
|
241
|
-
// Mollie payment is required
|
|
242
|
-
const apiKey = STAMHOOFD.MOLLIE_API_KEY
|
|
243
|
-
if (!apiKey) {
|
|
244
|
-
throw new SimpleError({
|
|
245
|
-
code: "",
|
|
246
|
-
message: "Betalingen zijn tijdelijk onbeschikbaar"
|
|
247
|
-
})
|
|
248
|
-
}
|
|
249
|
-
const mollieClient = createMollieClient({ apiKey });
|
|
250
|
-
|
|
251
|
-
const molliePayment = await mollieClient.payments.create({
|
|
252
|
-
amount: {
|
|
253
|
-
currency: 'EUR',
|
|
254
|
-
value: (price / 100).toFixed(2)
|
|
255
|
-
},
|
|
256
|
-
//method: molliePaymentMethod.directdebit,
|
|
257
|
-
description,
|
|
258
|
-
customerId: organization.serverMeta.mollieCustomerId,
|
|
259
|
-
sequenceType: SequenceType.recurring,
|
|
260
|
-
redirectUrl: "https://"+STAMHOOFD.domains.dashboard+'/settings/billing/payment?id='+encodeURIComponent(payment.id),
|
|
261
|
-
webhookUrl: 'https://'+STAMHOOFD.domains.api+"/v"+Version+"/billing/payments/"+encodeURIComponent(payment.id)+"?exchange=true",
|
|
262
|
-
metadata: {
|
|
263
|
-
invoiceId: invoice.id,
|
|
264
|
-
paymentId: payment.id,
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
console.log(molliePayment)
|
|
268
|
-
if (molliePayment.method === 'creditcard') {
|
|
269
|
-
console.log("Corrected payment method to creditcard")
|
|
270
|
-
payment.method = PaymentMethod.CreditCard
|
|
271
|
-
await payment.save();
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Save payment
|
|
275
|
-
const dbPayment = new MolliePayment()
|
|
276
|
-
dbPayment.paymentId = payment.id
|
|
277
|
-
dbPayment.mollieId = molliePayment.id
|
|
278
|
-
await dbPayment.save();
|
|
279
|
-
|
|
280
|
-
// Only if all went okay
|
|
281
|
-
pendingInvoice.invoiceId = invoice.id
|
|
282
|
-
await pendingInvoice.save()
|
|
283
|
-
|
|
284
|
-
const invoicingTo = await organization.getInvoicingToEmails()
|
|
285
|
-
|
|
286
|
-
if (invoicingTo && payment.method === PaymentMethod.DirectDebit) {
|
|
287
|
-
// Generate a temporary PDF file
|
|
288
|
-
const builder = new InvoiceBuilder(invoice)
|
|
289
|
-
const pdf = await builder.build()
|
|
290
|
-
|
|
291
|
-
// Send the e-mail
|
|
292
|
-
Email.sendInternal({
|
|
293
|
-
to: invoicingTo,
|
|
294
|
-
bcc: "simon@stamhoofd.be",
|
|
295
|
-
subject: "Pro-forma factuur voor "+organization.name,
|
|
296
|
-
text: "Dag "+organization.name+", \n\nBedankt voor jullie vertrouwen in Stamhoofd. Jullie hebben momenteel een openstaand bedrag van "+Formatter.price(price)+" in Stamhoofd (zie bijlage). Zoals eerder aangegeven zal dit via domiciliÃĢring worden aangerekend (op dezelfde bankrekening waarmee de vorige betaling is gedaan). Hiervoor hoeven jullie dus niets te doen. Kijk eventueel na of er voldoende geld op jullie rekening staat. De betaling zal ÊÊn van de komende drie werkdagen plaatsvinden. Wil je het rekeningnummer voor de volgende betaling wijzigen? Dan kan je de stappen volgen op https://"+organization.marketingDomain+"/docs/bankrekening-domiciliering-wijzigen/.\n\nNa betaling ontvangen jullie een definitieve factuur. Je kan in Stamhoofd altijd het openstaande bedrag nakijken bij Instellingen > Facturen en betalingen. Neem gerust contact met ons op (via "+organization.i18n.$t("shared.emails.general")+") als je denkt dat er iets fout is gegaan of als je nog bijkomende vragen zou hebben.\n\nMet vriendelijke groeten,\nStamhoofd\n\n",
|
|
297
|
-
attachments: [
|
|
298
|
-
{
|
|
299
|
-
filename: "pro-forma-factuur.pdf",
|
|
300
|
-
href: pdf.getPublicPath(),
|
|
301
|
-
contentType: "application/pdf"
|
|
302
|
-
}
|
|
303
|
-
]
|
|
304
|
-
}, organization.i18n)
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
63
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { column, Model } from "@simonbackx/simple-database";
|
|
2
|
-
import { Email } from "@stamhoofd/email";
|
|
3
|
-
import { Formatter } from "@stamhoofd/utility";
|
|
4
2
|
import { v4 as uuidv4 } from "uuid";
|
|
5
3
|
|
|
6
|
-
import { Organization, RegisterCode, STCredit, STPendingInvoice } from "./";
|
|
7
|
-
import { STInvoiceItem } from "@stamhoofd/structures";
|
|
8
|
-
import { QueueHandler } from "@stamhoofd/queues";
|
|
9
4
|
|
|
10
5
|
export class UsedRegisterCode extends Model {
|
|
11
6
|
static table = "used_register_codes";
|
|
@@ -53,114 +48,4 @@ export class UsedRegisterCode extends Model {
|
|
|
53
48
|
skipUpdate: true
|
|
54
49
|
})
|
|
55
50
|
updatedAt: Date
|
|
56
|
-
|
|
57
|
-
static async getFor(organizationId: string): Promise<UsedRegisterCode | undefined> {
|
|
58
|
-
const code = await this.where({ organizationId }, { limit: 1 })
|
|
59
|
-
return code[0] ?? undefined
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async reward() {
|
|
63
|
-
if (this.creditId) {
|
|
64
|
-
// Already received
|
|
65
|
-
console.error("Already rewarded for used register code "+this.id)
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const code = await RegisterCode.getByID(this.code)
|
|
70
|
-
if (!code || !code.organizationId) {
|
|
71
|
-
console.error("Couldn't find code "+this.code+" for used register code "+this.id)
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const organization = await Organization.getByID(this.organizationId)
|
|
76
|
-
if (!organization) {
|
|
77
|
-
console.error("Couldn't find organization with id "+this.organizationId+" for used register code "+this.id)
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const receivingOrganization = await Organization.getByID(code.organizationId)
|
|
82
|
-
if (!receivingOrganization) {
|
|
83
|
-
console.error("Couldn't find receiving organization with id "+code.organizationId+" for used register code "+this.id)
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const usedCount = await UsedRegisterCode.getUsedCount(this.code) + 1
|
|
88
|
-
|
|
89
|
-
const credit = new STCredit()
|
|
90
|
-
credit.organizationId = code.organizationId
|
|
91
|
-
credit.change = code.invoiceValue ? 0 : Math.min(100 * 100, usedCount * 10 * 100)
|
|
92
|
-
credit.description = organization.name+" doorverwezen đ"
|
|
93
|
-
|
|
94
|
-
// Expire in one year (will get extended for every purchase or activation)
|
|
95
|
-
credit.expireAt = new Date()
|
|
96
|
-
credit.expireAt.setFullYear(credit.expireAt.getFullYear() + 1)
|
|
97
|
-
credit.expireAt.setMilliseconds(0)
|
|
98
|
-
|
|
99
|
-
await credit.save()
|
|
100
|
-
this.creditId = credit.id
|
|
101
|
-
await this.save()
|
|
102
|
-
|
|
103
|
-
if (code.invoiceValue) {
|
|
104
|
-
const name = "Aankoop Stamhoofd voor " + organization.name
|
|
105
|
-
const item = STInvoiceItem.create({
|
|
106
|
-
name,
|
|
107
|
-
description: "Via doorverwijzingscode",
|
|
108
|
-
amount: 1,
|
|
109
|
-
unitPrice: code.invoiceValue,
|
|
110
|
-
canUseCredits: false
|
|
111
|
-
})
|
|
112
|
-
console.log("Scheduling code charge for ", code)
|
|
113
|
-
await QueueHandler.schedule("billing/invoices-"+receivingOrganization.id, async () => {
|
|
114
|
-
await STPendingInvoice.addItems(receivingOrganization, [item])
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const admins = await receivingOrganization.getAdminToEmails()
|
|
119
|
-
if (admins) {
|
|
120
|
-
if (code.invoiceValue) {
|
|
121
|
-
Email.sendInternal({
|
|
122
|
-
to: admins,
|
|
123
|
-
bcc: "simon@stamhoofd.be",
|
|
124
|
-
subject: `${organization.name} heeft jullie tegoed gebruikt`,
|
|
125
|
-
text: "Dag "+receivingOrganization.name+",\n\n"+organization.name+" had jullie doorverwijzingslink gebruikt om zich op Stamhoofd te registreren, en nu hebben ze dit ook gebruikt. Zoals afgesproken wordt hiervoor " + Formatter.price(code.invoiceValue)+ " aangerekend via jullie openstaand saldo in jullie Stamhoofd account."
|
|
126
|
-
+ "\n\nâ Stamhoofd"
|
|
127
|
-
}, organization.i18n)
|
|
128
|
-
|
|
129
|
-
} else {
|
|
130
|
-
// Delay email until everything is validated and saved
|
|
131
|
-
Email.sendInternal({
|
|
132
|
-
to: admins,
|
|
133
|
-
bcc: "simon@stamhoofd.be",
|
|
134
|
-
subject: "Je hebt "+Formatter.price(credit.change)+" tegoed ontvangen đ°",
|
|
135
|
-
text: "Dag "+receivingOrganization.name+",\n\nGeweldig nieuws! "+organization.name+" had jullie doorverwijzingslink gebruikt om zich op Stamhoofd te registreren, en nu hebben ze ook voor het eerst minstens ÊÊn euro uitgegeven. Daardoor ontvangen jullie "+Formatter.price(credit.change)+" tegoed voor Stamhoofd (zie daarvoor Stamhoofd > Instellingen). "
|
|
136
|
-
+ (credit.change <= 90*100 ? ("Bij de volgende vereniging ontvangen jullie nog meer: "+Formatter.price(credit.change + 10*100)+". ") : "")
|
|
137
|
-
+ (credit.change <= 80*100 ? ("En dat blijft oplopen tot âŦ 100,00 per vereniging die je aanbrengt đ ") : "")
|
|
138
|
-
+ "Doe zo verder! Lees zeker onze tips na om nog een groter bedrag te verzamelen đ\n\nâ Stamhoofd"
|
|
139
|
-
}, organization.i18n)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
static async getAll(code: string) {
|
|
145
|
-
const used = await UsedRegisterCode.where({
|
|
146
|
-
code
|
|
147
|
-
})
|
|
148
|
-
return used
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
static async getUsed(code: string) {
|
|
152
|
-
const used = await UsedRegisterCode.where({
|
|
153
|
-
code,
|
|
154
|
-
creditId: {
|
|
155
|
-
value: null,
|
|
156
|
-
sign: "!="
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
return used
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
static async getUsedCount(code: string) {
|
|
163
|
-
const used = await this.getUsed(code)
|
|
164
|
-
return used.length
|
|
165
|
-
}
|
|
166
51
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { File, STInvoiceItem } from "@stamhoofd/structures";
|
|
2
|
-
import { Payment, STInvoice } from "../models";
|
|
3
|
-
export declare class InvoiceBuilder {
|
|
4
|
-
invoice: STInvoice;
|
|
5
|
-
payment: Payment | null;
|
|
6
|
-
document: PDFKit.PDFDocument;
|
|
7
|
-
private remainingItems;
|
|
8
|
-
private posY;
|
|
9
|
-
private page;
|
|
10
|
-
private dataBuffer;
|
|
11
|
-
constructor(invoice: STInvoice);
|
|
12
|
-
build(): Promise<File>;
|
|
13
|
-
private writeHeader;
|
|
14
|
-
drawSinglePageShape(): void;
|
|
15
|
-
drawLastPageShape(): void;
|
|
16
|
-
drawFirstPageShape(): void;
|
|
17
|
-
drawBackground(): void;
|
|
18
|
-
private remainingItemHeight;
|
|
19
|
-
drawNextPages(): void;
|
|
20
|
-
endPage(): void;
|
|
21
|
-
/**
|
|
22
|
-
* Returns the height of the drawn item
|
|
23
|
-
*/
|
|
24
|
-
drawInvoiceItem(item: STInvoiceItem, y: number, dryRun: boolean): number;
|
|
25
|
-
drawTableHeader(y: number): number;
|
|
26
|
-
drawPriceFooter(): void;
|
|
27
|
-
drawPageFooter(): void;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=InvoiceBuilder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InvoiceBuilder.d.ts","sourceRoot":"","sources":["../../../src/helpers/InvoiceBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAqD,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAM/G,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAuB/C,qBAAa,cAAc;IACvB,OAAO,EAAE,SAAS,CAAA;IAClB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAO;IAC9B,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAA;IAE5B,OAAO,CAAC,cAAc,CAAiB;IAEvC,OAAO,CAAC,IAAI,CAAI;IAChB,OAAO,CAAC,IAAI,CAAI;IAEhB,OAAO,CAAC,UAAU,CAAY;gBAElB,OAAO,EAAE,SAAS;IAKxB,KAAK;IAmEX,OAAO,CAAC,WAAW;IAmFnB,mBAAmB;IAOnB,iBAAiB;IAOjB,kBAAkB;IAOlB,cAAc;IAQd,OAAO,CAAC,mBAAmB;IAW3B,aAAa;IA2Eb,OAAO;IAQP;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAqD/D,eAAe,CAAC,CAAC,EAAE,MAAM;IAiBzB,eAAe;IA+Ff,cAAc;CAYjB"}
|