Hub 2.0 step 5: the church's address
Own domain R0, Cross Code address R10, domain included R25 (custom price for other endings), once per invoice and never discounted; renewal date with a reminder 30 days before, once per renewal, and Renewed to move it on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
const {
|
||||
tierNamed, reviewTier, planPrice, extraStorageBlocks, STORAGE, BUNDLE_PERCENT, YEARLY_MONTHS, FOUNDING_PERCENT,
|
||||
tierNamed, reviewTier, planPrice, extraStorageBlocks, STORAGE, ADDRESS, BUNDLE_PERCENT, YEARLY_MONTHS, FOUNDING_PERCENT,
|
||||
} = require('./tiers');
|
||||
const { ymd, day, addDays, addMonths, periodLabel, shortDate } = require('./dates');
|
||||
const { PRODUCTS, PRODUCT_NAMES, BILLABLE } = require('../products');
|
||||
@@ -126,6 +126,24 @@ function reviewLicence(licence, product) {
|
||||
};
|
||||
}
|
||||
|
||||
/** The monthly price of the customer's address in cents (a custom price wins). */
|
||||
function addressMonthlyCents(customer) {
|
||||
if (customer.addressCustomCents != null && customer.addressCustomCents >= 0) return customer.addressCustomCents;
|
||||
return (ADDRESS[customer.addressType || 'own_domain']?.monthly || 0) * 100;
|
||||
}
|
||||
|
||||
/** The address line for a period, or null (own domain, or free). 12 months' price when yearly. */
|
||||
function addressLine(customer, { start, end, cycle }) {
|
||||
const cents = addressMonthlyCents(customer);
|
||||
if (!cents) return null;
|
||||
const option = ADDRESS[customer.addressType] || ADDRESS.own_domain;
|
||||
const m = monthsIn(cycle);
|
||||
return {
|
||||
description: `${option.label}${customer.domain ? ` (${customer.domain})` : ''}, ${m === 12 ? '12 months' : periodLabel(start, end)}`,
|
||||
quantity: m, unitCents: cents, amountCents: m * cents,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A customer's invoice lines for a period: each billed product (with a prorated line for days
|
||||
* owed before the period), its founding discount, the bundle discount, then add-ons. Pure.
|
||||
@@ -221,6 +239,10 @@ function customerInvoiceLines({ customer, licences, period, reviewed }) {
|
||||
}
|
||||
lines.push(...addOns);
|
||||
|
||||
// The church's address: once per invoice with any product on it, never discounted.
|
||||
const address = addressLine(customer, { start, end, cycle });
|
||||
if (address && products.length) lines.push(address);
|
||||
|
||||
const plan = plans.length === 1 && plans[0].product === 'events'
|
||||
? plans[0].plan
|
||||
: plans.map(p => (p.product === 'website' ? PRODUCT_NAMES.website : `${PRODUCT_NAMES[p.product]} ${p.plan}`)).join(' · ') || null;
|
||||
@@ -334,6 +356,6 @@ function statement({ invoices, payments, from, to }) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
recipientFor, contactInstall, cleanLines, totals, planLines, productLabel, customerInvoiceLines, draftCustomerInvoice,
|
||||
recipientFor, contactInstall, cleanLines, totals, planLines, productLabel, customerInvoiceLines, draftCustomerInvoice, addressMonthlyCents,
|
||||
planChangesOf, invoiceState, statement, invoiceDescription, anchorDayOf, monthsIn,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user