refactor: improve notification naming and introduce type-safe enums
- Rename billFwd* to billsNotification* for clarity - Rename rentDueNotification* to rentNotification* for consistency - Rename utilBillsProofOfPayment to billsProofOfPayment - Introduce enums for type safety: - BillsNotificationStrategy (WhenPayed, WhenAttached) - BillsNotificationStatus (Scheduled, Sent, Failed) - RentNotificationStatus (Sent, Failed) - Replace "pending" status with "scheduled" for better semantics - Fix function names to proper camelCase - Fix incorrect import path in web-app/app/lib/format.ts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { BillingLocation, BilledTo } from '@evidencija-rezija/shared-code';
|
||||
import { BillingLocation, BilledTo, BillsNotificationStatus, BillsNotificationStrategy } from '@evidencija-rezija/shared-code';
|
||||
|
||||
/**
|
||||
* Checks if billFwdStatus should be updated to "pending" based on attachment status
|
||||
* Checks if billsNotificationStatus should be updated to `Scheduled` based on attachment status
|
||||
* @param location - The billing location containing the bill
|
||||
* @param currentBillId - The ID of the bill being updated (to exclude from check)
|
||||
* @param hasNewAttachment - Whether a new attachment is being added to the current bill
|
||||
* @returns true if billFwdStatus should be set to "pending"
|
||||
* @returns true if billsNotificationStatus should be set to `Scheduled`
|
||||
*/
|
||||
export const shouldUpdateBillFwdStatusWhenAttached = (
|
||||
export const shouldUpdateBillsNotificationStatusWhenAttached = (
|
||||
location: BillingLocation,
|
||||
currentBillId: string | undefined,
|
||||
hasNewAttachment: boolean
|
||||
@@ -17,18 +17,18 @@ export const shouldUpdateBillFwdStatusWhenAttached = (
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check billFwdEnabled is true
|
||||
if (location.billFwdEnabled !== true) {
|
||||
// Check billsNotificationEnabled is true
|
||||
if (location.billsNotificationEnabled !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check billFwdStrategy is "when-attached"
|
||||
if (location.billFwdStrategy !== "when-attached") {
|
||||
// Check billsNotificationStrategy is `WhenAttached`
|
||||
if (location.billsNotificationStrategy !== BillsNotificationStrategy.WhenAttached) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check bills have already been sent or are pending -> don't sent them again
|
||||
if (location.billFwdStatus === "pending" || location.billFwdStatus === "sent") {
|
||||
// Check bills have already been sent or are scheduled -> don't send them again
|
||||
if (location.billsNotificationStatus === BillsNotificationStatus.Scheduled || location.billsNotificationStatus === BillsNotificationStatus.Sent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ export const shouldUpdateBillFwdStatusWhenAttached = (
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if billFwdStatus should be updated to "pending" based on paid status
|
||||
* Checks if billsNotificationStatus should be updated to "scheduled" based on paid status
|
||||
* @param location - The billing location containing the bill
|
||||
* @param currentBillId - The ID of the bill being updated (to exclude from check)
|
||||
* @param isPaid - Whether the current bill is being marked as paid
|
||||
* @returns true if billFwdStatus should be set to "pending"
|
||||
* @returns true if billsNotificationStatus should be set to "scheduled"
|
||||
*/
|
||||
export const shouldUpdateBillFwdStatusWhenPayed = (
|
||||
export const shouldUpdateBillsNotificationStatusWhenPayed = (
|
||||
location: BillingLocation,
|
||||
currentBillId: string | undefined,
|
||||
isPaid: boolean
|
||||
@@ -65,18 +65,18 @@ export const shouldUpdateBillFwdStatusWhenPayed = (
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check billFwdEnabled is true
|
||||
if (location.billFwdEnabled !== true) {
|
||||
// Check billsNotificationEnabled is true
|
||||
if (location.billsNotificationEnabled !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check billFwdStrategy is "when-payed"
|
||||
if (location.billFwdStrategy !== "when-payed") {
|
||||
// Check billsNotificationStrategy is `WhenPayed`
|
||||
if (location.billsNotificationStrategy !== BillsNotificationStrategy.WhenPayed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check bills have already been sent or are pending -> don't sent them again
|
||||
if (location.billFwdStatus === "pending" || location.billFwdStatus === "sent") {
|
||||
// Check bills have already been sent or are scheduled -> don't sent them again
|
||||
if (location.billsNotificationStatus === BillsNotificationStatus.Scheduled || location.billsNotificationStatus === BillsNotificationStatus.Sent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user