Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

field

type

comment

HistoryBusinessModel fields

subject_type

str

Code Block
languagejson
  contribution/contract/funding --> Drop down

subject_id

uuid/int ?

https://stackoverflow.com/questions/33528098/django-model-one-foreign-key-to-many-tables Picker based on drop down ? (multiple picker displayed based drop down ? )

recipient_type

str

Code Block
languagejson
Insuree/PH/payer/User --> Drop down

recipient_id

uuid/int ?

https://stackoverflow.com/questions/33528098/django-model-one-foreign-key-to-many-tables Picker based on drop down ? (multiple picker displayed based drop down ? )

related_invoice_id

uuid

link to invoices

 code

 str 

or reference for the insurance (editable)

 code_rcp

 str 

or reference for the recipient (editable)

 code_ext

 str 

if required for external system integration such as payment systems (editable)

 date_due

 date 

date on which the payment is due (editable)

 date_invoice

 date 

Date of the “invoice“ (date of today but editable)

 *dateValidFrom

 date 

invoice covering service/item from (editable)

 *dateValidTo

 date 

invoice covering service/item to (editable)

 date_payed

 date 

Date on which the payment was actually documented as Done (editable)

 amount_discount

 float 

total of the detail discount (calculated be)

 amount_net

 float 

Total without tax (calculated be)

 tax_analysis

 json 

Code Block
languagejson
(calculated be)
tax details {
  "lines": [
    {"code":"", "label":"", "rate":"", "base":"", "amount":""}]
    …
  ],
  "total":""
}

 amount_total

 float 

total net + tax total (calculated be)

 status

 int 

ENUM: draft, validated, payed, cancelled, deleted (editable ), amended, suspended

 currency_rcp_code

 str 

currency of the recipient (if different) (hidden)

 currency_code

 str 

currency of insurance (calculated be) (hidden)

 note

 bigttext 

(editable)

 terms

 bigttext 

conditions (editable)

payment_reference

 str 

...

field

type

comment

HistoryModel fields

 

Status

int

Accepted / Rejected/refunded/cancelled (editable)

code_ext

str

payment reference (editable)

label

str

label of the payment (editable)

code_rcp

str

Reference from the payment system / bank (editable)

invoiceId

UUID

reference to invoice (hidden)

code_receipt

 str 

receipt number (editable)

amount_payed

 float

Amount that need to be matched against business items (fees might be added if there were removed before reaching the system) (editable)

fees

 float

(editable)

amount_received

float

Amount that is received (may include or not the fees) (editable)

date_payment

date

(editable)

...

  • invoicePaymentRefRecieved (payment_reference)

  • invoiceEventPaymentRejected (msg) msg to event

  • invoicePaymentRecieved(msg, InvoicePayments) → can update the status to payed (also include rejected payment), only last amendment can be payed

  • invoicePaymentRefunded(InvoicePayments)→ can update the status to validated suspended (warning the busienss service to be update via signal)

  • invoicePaymentCanceled(InvoicePayments)

  • invoiceCreate (called on save)

  • invoiceUpdate (called on save)

  • invoiceDelete

  • invoiceTaxCalculation() calculate tax details by merging the result of invoiceItemTaxCalculation

  • invoiceItemCreate

  • invoiceItemUpdate

  • invoiceItemDelete

  • invoiceItemTaxCalculation calculate tax details base on the tax_rate rule

  • nice-to-have invoiceAmend → create new empty invoice and put current idea in “related_invoice“ and set status to amended

  • invoiceValidateItems → check that we have a business item attached to the invoice are in the right status/ right price: just send a signal, handle by calculation rule, add event if issues

  • invoiceMatchItems → check that we have a business item attached to the invoice (check if the subject_type / id is not empty and point to a valid database object, check line_id/type if no subject_id)

  • (not attached to the object)invoiceCreationFromCalculation (will send a signal)

...

Listening to other modules signal are strikethrough because during the migration not all update will happens through modular therefore such trigger will complexity the invoice creation processes

Contribution

...

the grouping will be done per Head of family, therefore such invoice will have only 1 detail.

Registration on signals from other module(existing or not):

  • contributionCreated

  • invoiceCreationFromCalculation

Converters

informal sector

1 invoice per policy, with 1 invoiceLineItem, dependants might be documented in the details invoiceItemLine

Invoice:

...

field

...

type

...

comment

...

subject

...

json

...

Code Block
languagejson
referenceSource {
  "label":Product-lable
  "code":product-code,
  "type": "Contribution",
  "id":"UUID",
}

...

 recipient

...

json 

...

Code Block
languagejson
referenceActor {
  "label":Insuree-name,
  "code":CHFID,
  "type": "Insuree",
  "id":"UUID",
  "address":{"text":"",...}
}

...

 code

...

 str 

...

IV-[PRODUCT code]-CHFID

...

 date_due

...

 date 

...

policy effective date

...

 date_invoice

...

 date 

...

Date of the enrolment

...

 *dateValidFrom

...

 date 

...

validFrom: policy effective date

...

 *dateValidTo

...

 date 

...

validTo: policy expiry date

...

 amount_discount

...

 float 

...

total of the detail discount

...

 amount_net

...

 float 

...

Total without tax

...

 tax_analysis

...

 json 

...

Code Block
languagejson
null

...

 amount_total

...

 float 

...

total net

...

 status

...

 int 

...

validated

...

 currency_rcp_code

...

 str 

...

default-curency

...

 currency_code

...

 str 

...

default-curency-code

...

 note

...

 bigttext 

...

 terms

...

 bigttext 

InvoiceItem

...

field

...

type

...

comment

...

HistoryBusinessModel fields

...

validFrom: Policy efective date

validTo:Policy exiry date

...

code

...

 str 

...

PRODUCT-code

...

description

...

 str 

...

PRODUCT-label

...

details

...

 json 

...

Dependant otherName, name, gender, age, relation to insuree

...

ledger_account

...

 int 

...

Product premium accounting code

...

quantity

...

 float 

...

1

...

unit_price

...

 type 

...

BASE Policy Value

...

discount

...

 float 

...

renewal discount …

...

 tax_rate

...

 Calculation uuid 

...

null

...

tax_analysis

...

json

...

Code Block
languagejson
null

...

amount_total

...

float

...

net +tax

...

amount_net

...

qty * unitprice - discount

Image Removedplan calculation rule: Product modeling

Contract:

the invoice of a contract will match the contract value and details.

...