mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-21 18:29:57 +00:00
* feat: new banking module (#54720)
* feat: initial SPA setup for banking
* wip: bring over new banking module
* feat: added Espresso design tokens
* feat: button styles
* fix: add all ink colors
* wip: espresso design system changes
* feat: button and badge espresso components
* fix: button styling for reconcile
* feat: Espresso progress bar
* feat: Espresso toggle switch
* feat: Espresso tabs design
* fix: vertical tab support
* fix: button sizing across modals
* feat: Espresso style table layout
* feat: Espresso tooltip
* feat: Espresso elevations and checkbox
* feat: Dialog with Espresso styles
* feat: Espresso textarea
* fix: input styles
* fix: colors on bank picker
* fix: breadcrumb styling
* fix: bank picker styling
* feat: create doctypes and fields for bank reconciliation
* feat: APIs for banking
* fix: use date format parser
* fix: font styling to match Espresso
* wip: settings modal
* feat: settings dialog component
* fix: icons and invalid requests
* feat: preferences tab
* fix: adjust icon stroke width to 1.5
* feat: rule configuration in settings
* fix: remove sheet component
* feat: alert and error banner component
* feat: dropdown in Espresso
* feat: popover and select in Espresso
* fix: cleanup more styles
* fix: match size of link fields
* feat: command styling
* fix: remove unused style tokens
* fix: styles for global date picker dropdown
* fix: styles for match and reconcile
* feat: table Espresso component
* feat: remove all other design tokens
* fix: remove unused tokens
* fix: form elements
* fix: remove unused styles and fix filters in bank transaction list
* feat: fetch bank rec doctypes for filtering
* fix: record payment modal
* feat: support for dark mode switching
* fix: move bank logos to public folder
* feat: add support for RTL
* feat: support for RTL
* chore: send layout direction in dev boot
* fix: make checkbox work in RTL
* feat: dark mode support
* fix: dark mode style
* feat: bank logos in dark mode
* feat: dark mode bank logos
* chore: use dark mode bank logos everywhere
* chore: move rule evaluation to controller
* chore: add tests for bank transaction rules
* fix: move deps to fix actions errors
* fix: move tw-animate-css to deps
* fix: remove shadcn
* fix: do not open modal if no transactions selected
* fix: add translation strings
* feat: add banner on existing bank reconciliation tool
* feat: bank statement import
* fix: translations and layout directions
* fix: validation for transaction matching rule
* fix: styles
* fix: show conflicting transactions in alert
* fix: show help text for new banking module forms
* feat: show total debits and credits
* fix: dark mode colors in automatic config
* feat: add keyboard shortcuts help
* feat: added keyboard shortcut for settings
* fix: decrease size of progress bar
* chore: bump packages
* feat: add tests for statement import
* fix: settings dialog
* fix: show banner on small screens
* fix: show banner when no bank account set
(cherry picked from commit 6de5367f12)
# Conflicts:
# erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
* chore: resolve conflicts
* fix: add type hints to whitelisted methods
---------
Co-authored-by: Nikhil Kothari <nik.kothari22@live.com>
101 lines
3.5 KiB
TypeScript
101 lines
3.5 KiB
TypeScript
import { Button } from "@/components/ui/button"
|
|
import ErrorBanner from "@/components/ui/error-banner"
|
|
import { Form } from "@/components/ui/form"
|
|
import _ from "@/lib/translate"
|
|
import { BankTransactionRule } from "@/types/Accounts/BankTransactionRule"
|
|
import { FrappeError, useFrappeGetDoc, useFrappeUpdateDoc } from "frappe-react-sdk"
|
|
import { toast } from "sonner"
|
|
import { RuleForm } from "./RuleForm"
|
|
import { useForm } from "react-hook-form"
|
|
import { Skeleton } from "@/components/ui/skeleton"
|
|
import { SettingsPanelContent, SettingsPanelDescription, SettingsPanelHeader, SettingsPanelTitle } from "@/components/ui/settings-dialog"
|
|
import { useHotkeys } from "react-hotkeys-hook"
|
|
|
|
type Props = {
|
|
onClose: VoidFunction,
|
|
ruleID: string
|
|
}
|
|
|
|
const EditRule = ({ onClose, ruleID }: Props) => {
|
|
|
|
const { data: rule, isValidating, error, mutate } = useFrappeGetDoc<BankTransactionRule>("Bank Transaction Rule", ruleID, undefined, {
|
|
revalidateOnMount: true
|
|
})
|
|
|
|
const { updateDoc, loading, error: updateError } = useFrappeUpdateDoc<BankTransactionRule>()
|
|
|
|
const onSubmit = (data: BankTransactionRule) => {
|
|
updateDoc("Bank Transaction Rule", ruleID, data)
|
|
.then(() => {
|
|
toast.success(_("Rule updated."))
|
|
mutate()
|
|
onClose()
|
|
})
|
|
}
|
|
|
|
return <>
|
|
<SettingsPanelHeader
|
|
actions={
|
|
<div className="flex items-center gap-2">
|
|
<Button variant='outline' size='md' type='button' onClick={() => onClose()}>{_("Cancel")}</Button>
|
|
<Button type='submit' form='rule-form' size='md' disabled={isValidating || loading}>
|
|
{_("Save")}
|
|
</Button>
|
|
</div>
|
|
}
|
|
>
|
|
<SettingsPanelTitle>
|
|
{rule?.rule_name}
|
|
</SettingsPanelTitle>
|
|
<SettingsPanelDescription className="sr-only">
|
|
{_("Edit this rule")}
|
|
</SettingsPanelDescription>
|
|
</SettingsPanelHeader>
|
|
<SettingsPanelContent className="px-0">
|
|
{isValidating && <div className="px-4 flex flex-col gap-4 h-full">
|
|
<Skeleton className="h-10 w-full" />
|
|
<Skeleton className="h-10 w-full" />
|
|
<Skeleton className="h-10 w-full" />
|
|
<Skeleton className="h-10 w-full" />
|
|
<Skeleton className="h-10 w-full" />
|
|
</div>}
|
|
|
|
{error && <div className="px-4 flex flex-col gap-4 h-full">
|
|
<ErrorBanner error={error} />
|
|
</div>}
|
|
{rule && <EditRuleForm rule={rule} onSubmit={onSubmit} error={updateError} />}
|
|
</SettingsPanelContent>
|
|
</>
|
|
|
|
|
|
}
|
|
|
|
const EditRuleForm = ({ rule, onSubmit, error }: { rule: BankTransactionRule, onSubmit: (data: BankTransactionRule) => void, error?: FrappeError | null }) => {
|
|
|
|
const form = useForm<BankTransactionRule>({
|
|
defaultValues: {
|
|
...rule,
|
|
}
|
|
})
|
|
|
|
useHotkeys('meta+s', () => {
|
|
form.handleSubmit(onSubmit)()
|
|
}, {
|
|
enabled: true,
|
|
preventDefault: true,
|
|
enableOnFormTags: true
|
|
})
|
|
|
|
return (
|
|
<Form {...form}>
|
|
<form id='rule-form' onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col justify-between h-full overflow-y-auto px-2">
|
|
<div className="flex flex-col gap-4">
|
|
{error && <ErrorBanner error={error} />}
|
|
<RuleForm isEdit />
|
|
</div>
|
|
</form>
|
|
</Form>
|
|
)
|
|
}
|
|
|
|
export default EditRule |