Financial Proposal Service
In order to help you build your own Solution, find below an example of a complete and functional YAML model. It contains all sections that can serve as the foundation for your project.
This model example reflects a real use case for the Financial Proposal Service, which is intended to perform certain registration operations (CRUD) and customized queries to the database.
The features of this solution are:
- Customer registration;
- Installments amounts simulation registration;
- Proposal and Installments registration;
- Proposal status change;
- Customer payment registration;
- OData Query Controllers for customized data queries;
- User interface project/application for specified CRUD services
YAML Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661 | Name: FinancialProposal # Solution name
RootNamespace: Sample.FinancialProposal # Solution root namespace
# Business entities
Entities:
- Name: Customer
KeyType: Guid
Properties:
- Name: Name
Type: string
- Name: Cpf
Type: string
- Name: Income
Type: decimal
- Name: BirthDate
Type: DateTimeOffset
- Name: CustomerAddresses
Type: '[CustomerAddress]' # Determines a relationship OneToMany with CustomerAddress
- Name: CustomerAddress
KeyType: Guid
Properties:
- Name: Customer
Type: Customer
- Name: CustomerId
Type: Guid
- Name: Type
Type: int
- Name: Address
Type: string
- Name: Number
Type: int
- Name: ZipCode
Type: string
- Name: Neighborhood
Type: string
- Name: City
Type: string
- Name: State
Type: string
- Name: ProposalSimulation
KeyType: Guid
Properties:
- Name: CustomerId
Type: Guid
- Name: DateBase
Type: DateTimeOffset
- Name: RequestedValue
Type: decimal
- Name: NumberInstallments
Type: int
- Name: OfferValue
Type: decimal
- Name: Tax
Type: float
- Name: Proposal
Type: Proposal # Determines a relationship OneToOne with Proposal
- Name: Proposal
KeyType: Guid
Properties:
- Name: Number
Type: int
- Name: ProposalSimulation
Type: ProposalSimulation
- Name: ProposalSimulationId
Type: Guid
- Name: Installments
Type: '[Installment]'
- Name: ProposalPayment
Type: ProposalPayment
- Name: Status # 0-Registered / 1-Approved / 2-Disapproved / 3-Payed
Type: int
- Name: Installment
KeyType: Guid
Properties:
- Name: Proposal
Type: Proposal
- Name: ProposalId
Type: Guid
- Name: Number
Type: int
- Name: DueDate
Type: DateTimeOffset
- Name: Amount
Type: decimal
- Name: ProposalPayment
KeyType: Guid
Properties:
- Name: Proposal
Type: Proposal
- Name: ProposalId
Type: Guid
- Name: TransactionCode
Type: string
- Name: BankCode
Type: string
- Name: Agency
Type: string
- Name: Account
Type: string
- Name: AccountType
Type: int
- Name: Status # 0-Registered / 1-Sent to the Bank / 2-Finished
Type: int
# Database instance types
DbInstances:
- Name: MyDbInstance01
Type: PostgreSql
# Dedicated databases by service
Databases:
- Name: Customer
DbInstanceName: MyDbInstance01
- Name: IdentityManager
DbInstanceName: MyDbInstance01
- Name: Proposal
DbInstanceName: MyDbInstance01
# Identity Server configuration section
IdentityConfig:
DatabaseName: IdentityManager # Dedicated database for Identity Server data storage
# Database data contexts
DbContexts:
- Name: CustomerCtx
DatabaseName: Customer
DbMappings: # Mapping between Entity and Database Tables
- Name: CustomerDbMapping
EntityName: Customer
Relationships:
- ChildEntityName: CustomerAddress
ParentPropertyName: CustomerAddresses
ChildPropertyName: Customer
IsRequired: true
Type: OneToMany
ForeignKeyProperty: CustomerId
- Name: CustomerAddressDbMapping
EntityName: CustomerAddress
- Name: ProposalCtx
DatabaseName: Proposal
DbMappings:
- Name: SimulationDbMapping
EntityName: ProposalSimulation
Relationships:
- ChildEntityName: Proposal
ParentPropertyName: Proposal
ChildPropertyName: ProposalSimulation
IsRequired: false
Type: OneToOne
ForeignKeyProperty: ProposalSimulationId
- Name: ProposalDbMapping
EntityName: Proposal
Relationships:
- ChildEntityName: Installment
ParentPropertyName: Installments
ChildPropertyName: Proposal
IsRequired: true
Type: OneToMany
ForeignKeyProperty: ProposalId
- ChildEntityName: ProposalPayment
ParentPropertyName: ProposalPayment
ChildPropertyName: Proposal
IsRequired: false
Type: OneToOne
ForeignKeyProperty: ProposalId
- Name: InstallmentDbMapping
EntityName: Installment
- Name: PaymentDbMapping
EntityName: ProposalPayment
# Data access repository pattern
Repositories:
- Name: CustomerRepository
DbContextName: CustomerCtx
EntityName: Customer
- Name: CustomerAddressRepository
DbContextName: CustomerCtx
EntityName: CustomerAddress
- Name: ProposalSimulationRepository
DbContextName: ProposalCtx
EntityName: ProposalSimulation
- Name: ProposalRepository
DbContextName: ProposalCtx
EntityName: Proposal
- Name: InstallmentRepository
DbContextName: ProposalCtx
EntityName: Installment
- Name: ProposalPaymentRepository
DbContextName: ProposalCtx
EntityName: ProposalPayment
# Validations rules for the business entity
EntityValidations:
- Name: CustomerValidations_1
Type: PropertyValidation
EntityName: Customer
PropertyValidationParams:
- PropertyName: Name
StopOnFirstRuleFailure: true
Rules: # Pre-defined types that run sequentially
- Type: IsNotEmpty
- Type: IsLengthBetween
Expressions:
- Value(@ConstInt::0) # Expression to get the number "0" as constant
- Value(@ConstInt::100)
- PropertyName: Cpf
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- Type: IsCpf
- PropertyName: Income
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- PropertyName: BirthDate
StopOnFirstRuleFailure: true
Rules:
- Type: IsLessThan
Expressions:
- Value(@UtcToday) # Expression to get the current date
- Name: ProposalSimulationValidations_1
Type: PropertyValidation
EntityName: ProposalSimulation
PropertyValidationParams:
- PropertyName: CustomerId
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- PropertyName: DateBase
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- PropertyName: RequestedValue
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- Type: IsBetween
Expressions:
- Value(@ConstDecimal::50) # Expression to get the decimal number "50" as constant
- Value(@ConstDecimal::5000)
- PropertyName: NumberInstallments
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- Type: IsBetween
Expressions:
- Value(@ConstInt::2)
- Value(@ConstInt::36)
- PropertyName: OfferValue
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- Type: IsGreaterThan
Expressions:
- Value(@Prop::RequestedValue) # Expression to get the value of another property
- Name: ProposalValidations_1
Type: PropertyValidation
EntityName: Proposal
PropertyValidationParams:
- PropertyName: ProposalSimulationId
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- PropertyName: Status
StopOnFirstRuleFailure: true
Rules:
- Type: IsEqual
Expressions:
- Value(@ConstInt::0)
- Name: ProposalPaymentValidations_1
Type: PropertyValidation
EntityName: ProposalPayment
PropertyValidationParams:
- PropertyName: ProposalId
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- PropertyName: BankCode
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- PropertyName: Agency
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- PropertyName: Account
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- PropertyName: AccountType
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- Type: IsBetween
Expressions:
- Value(@ConstInt::1)
- Value(@ConstInt::3)
- PropertyName: Status
StopOnFirstRuleFailure: true
Rules:
- Type: IsNotEmpty
- Type: IsEqual
Expressions:
- Value(@ConstInt::1)
# Services and Controllers (CRUD and QUERY)
Services:
- Name: CustomerService
Type: WebAPI
Controllers:
- Name: Customer
Type: CRUD
RepositoryName: CustomerRepository
EntityName: Customer
Contexts:
- Context: Create
Validations: # Validations performed only for the "Create" context
- Name: CustomerValidations
Type: EntityValidation
Order: 1
ExecValidationName: CustomerValidations_1 # Executes an EntityValidation type
Rules: # Business rules performed only for the "Create" context
- Name: AddInRepository
Type: WriteOperationRule # Executes a business rule for persisting data in the database
Order: 1
- Context: Update
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: UpdatePartial
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: Delete
Rules:
- Name: DeleteInRepository
Type: WriteOperationRule
Order: 1
- Context: ReadAll
Rules:
- Name: ReadInRepository
Type: ReadOperationRule # Executes a business rule for reading data from the database
Order: 1
- Context: ReadByKey
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
- Name: CustomerRecords
Type: QUERY # OData Query pattern for custom queries
RepositoryName: CustomerRepository
EntityName: Customer
- Name: CustomerAddress
Type: CRUD
RepositoryName: CustomerAddressRepository
EntityName: CustomerAddress
Contexts:
- Context: Create
Rules:
- Name: AddInRepository
Type: WriteOperationRule
Order: 1
- Context: Update
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: UpdatePartial
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: Delete
Rules:
- Name: DeleteInRepository
Type: WriteOperationRule
Order: 1
- Context: ReadAll
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
- Context: ReadByKey
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
Metadata:
Version: v1
Title: Customer API
Description: Proposal Context - Customer Api v1
TermsOfServiceUrl: https://example.com/terms
Contact:
ContactName: Customer Api Team
ContactEmail: customerapi@sample.com
ContactUrl: https://example.com/contact
License:
LicenseInfo: Use under LICX
LicenseUrl: https://example.com/license
- Name: ProposalService
Type: WebAPI
Controllers:
- Name: ProposalSimulation # Installments amounts simulation registration
Type: CRUD
RepositoryName: ProposalSimulationRepository
EntityName: ProposalSimulation
Contexts:
- Context: Create
Validations:
- Name: ProposalSimulationValidations
Type: EntityValidation
Order: 1
ExecValidationName: ProposalSimulationValidations_1
Rules:
- Name: AddInRepository
Type: WriteOperationRule
Order: 1
- Context: Update
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: UpdatePartial
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: Delete
Rules:
- Name: DeleteInRepository
Type: WriteOperationRule
Order: 1
- Context: ReadAll
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
- Context: ReadByKey
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
- Name: ProposalSimulationRecords # OData Query Controller
Type: QUERY
RepositoryName: ProposalSimulationRepository
EntityName: ProposalSimulation
- Name: Proposal # Proposal registration
Type: CRUD
RepositoryName: ProposalRepository
EntityName: Proposal
Contexts:
- Context: Create
Validations:
- Name: ProposalValidations
Type: EntityValidation
Order: 1
ExecValidationName: ProposalValidations_1
Rules:
- Name: AddInRepository
Type: WriteOperationRule
Order: 1
- Context: Update
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: UpdatePartial
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: Delete
Rules:
- Name: DeleteInRepository
Type: WriteOperationRule
Order: 1
- Context: ReadAll
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
- Context: ReadByKey
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
- Name: ProposalRecords
Type: QUERY
RepositoryName: ProposalRepository
EntityName: Proposal
- Name: ProposalInstallments # Proposal Installments registration
Type: CRUD
RepositoryName: InstallmentRepository
EntityName: Installment
Contexts:
- Context: Create
Rules:
- Name: AddInRepository
Type: WriteOperationRule
Order: 1
- Context: Update
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: UpdatePartial
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: Delete
Rules:
- Name: DeleteInRepository
Type: WriteOperationRule
Order: 1
- Context: ReadAll
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
- Context: ReadByKey
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
- Name: ProposalPayment # Customer Payment registration
Type: CRUD
RepositoryName: ProposalPaymentRepository
EntityName: ProposalPayment
Contexts:
- Context: Create
Validations:
- Name: ProposalPaymentValidations
Type: EntityValidation
Order: 1
ExecValidationName: ProposalPaymentValidations_1
Rules:
- Name: AddInRepository
Type: WriteOperationRule
Order: 1
- Context: Update
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: UpdatePartial
Rules:
- Name: UpdateInRepository
Type: WriteOperationRule
Order: 1
- Context: Delete
Rules:
- Name: DeleteInRepository
Type: WriteOperationRule
Order: 1
- Context: ReadAll
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
- Context: ReadByKey
Rules:
- Name: ReadInRepository
Type: ReadOperationRule
Order: 1
Metadata:
Version: v1
Title: Proposal API
Description: Proposal Context - Proposal Api v1
TermsOfServiceUrl: https://example.com/terms
Contact:
ContactName: Proposal Api Team
ContactEmail: proposalapi@sample.com
ContactUrl: https://example.com/contact
License:
LicenseInfo: Use under LICX
LicenseUrl: https://example.com/license
|
OData Example
| - Name: ProposalSimulationRecords
Type: QUERY
RepositoryName: ProposalSimulationRepository
EntityName: ProposalSimulation
|
Expand Request Example
| https://loadbalancer.bea.internal:44300/proposalservice/odata/proposalsimulationrecordsquery?$expand=Proposal($expand=Installments)
|
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 | {
"@odata.context": "https://loadbalancer.bea.internal:44300/proposalservice/odata/$metadata#ProposalSimulationRecordsQuery(Proposal(Installments()))",
"value": [
{
"Id": "f73cd92f-9920-479e-b979-d62e48ac6960",
"CustomerId": "dda392f9-a133-4a37-a5db-1c9d37713c7f",
"DateBase": "2020-04-01T00:00:00Z",
"RequestedValue": 500.0,
"NumberInstallments": 3,
"OfferValue": 750.0,
"Tax": 3.5,
"Proposal": {
"Id": "69c111fd-c28a-4e4f-8c36-1ec906edeada",
"Number": 1,
"ProposalSimulationId": "f73cd92f-9920-479e-b979-d62e48ac6960",
"Status": 1,
"Installments": [
{
"Id": "6df28988-ae87-462d-9f64-4b1862390dbb",
"ProposalId": "69c111fd-c28a-4e4f-8c36-1ec906edeada",
"Number": 1,
"DueDate": "2020-05-01T00:00:00Z",
"Amount": 350.0
},
{
"Id": "addf96fc-b372-4ccf-97fe-3d4966710eda",
"ProposalId": "69c111fd-c28a-4e4f-8c36-1ec906edeada",
"Number": 3,
"DueDate": "2020-07-01T00:00:00Z",
"Amount": 350.0
},
{
"Id": "f29f46f0-984b-4dfa-aa70-1de019359318",
"ProposalId": "69c111fd-c28a-4e4f-8c36-1ec906edeada",
"Number": 2,
"DueDate": "2020-06-01T00:00:00Z",
"Amount": 350.0
}
]
}
}
]
}
|
Select Request Example
| https://loadbalancer.bea.internal:44300/proposalservice/odata/proposalsimulationrecordsquery?$select=CustomerId,RequestedValue,OfferValue,Tax
|
Response
| {
"@odata.context": "https://loadbalancer.bea.internal:44300/proposalservice/odata/$metadata#ProposalSimulationRecordsQuery(CustomerId,RequestedValue,OfferValue,Tax)",
"value": [
{
"CustomerId": "dda392f9-a133-4a37-a5db-1c9d37713c7f",
"RequestedValue": 500.0,
"OfferValue": 750.0,
"Tax": 3.5
}
]
}
|