/* ĊĠĠĠ ĠImplements Ġendpoints Ġrelated Ġto Ġin voices . Ċ Ġ*/ Ċ Ċ package Ġio . ple o . ant ae us . core . services Ċ Ċ import Ġio . ple o . ant ae us . core . exceptions . Invoice NotFoundException Ċ import Ġio . ple o . ant ae us . data . Invoice Dal Ċ import Ġio . ple o . ant ae us . models . Invoice Ċ import Ġio . ple o . ant ae us . models . Invoice Status Ċ Ċ class ĠInvoice Service ( private Ġval Ġinvoice Dal : ĠInvoice Dal ) Ġ{ ĊĊĠĠĠ Ġfun Ġfetch All (): ĠList < Invoice > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinvoice Dal . fetch In voices () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfetch ( id : ĠInt ): ĠInvoice Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinvoice Dal . fetch Invoice ( id ) Ġ?: Ġthrow ĠInvoice NotFoundException ( id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfetch In voices By Status ( status : ĠInvoice Status ): ĠList < Invoice > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinvoice Dal . fetch In voices By Status ( status ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġupdate Invoice ( invoice : ĠInvoice ): ĠInvoice ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinvoice Dal . update Invoice ( invoice ) Ġ?: Ġthrow ĠInvoice NotFoundException ( invoice . id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġmark As Paid ( paid : ĠInvoice ): ĠInvoice ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġupdated Ġ= Ġpaid . copy ( status Ġ= ĠInvoice Status . PA ID ) ĊĠĠĠĠĠĠĠ Ġreturn Ġinvoice Dal . update Invoice ( updated ) Ġ?: Ġthrow ĠInvoice NotFoundException ( paid . id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġmark As Failed ( failed : ĠInvoice ): ĠInvoice ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġupdated Ġ= Ġfailed . copy ( status Ġ= ĠInvoice Status . FAILED ) ĊĠĠĠĠĠĠĠ Ġreturn Ġinvoice Dal . update Invoice ( updated ) Ġ?: Ġthrow ĠInvoice NotFoundException ( failed . id ) ĊĠĠĠ Ġ} Ċ } Ċ