-
Notifications
You must be signed in to change notification settings - Fork 103
LF-5274 Add animal batch selector with quantity and sale value to the revenue entry form #4170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: integration
Are you sure you want to change the base?
Changes from all commits
9b6319a
da269b4
1e90431
c820543
9f99348
779bc71
c2cb54a
7469dbb
154d2ac
b235e9d
781aa96
9dea14f
cde473a
f0fc254
a88f221
ca95e6b
843ed58
b9edf3e
180af06
f6d423f
a2f8c1a
fd472c7
241e57c
5b67340
b7d99d9
1c241ae
1692236
c9d9701
a5ce471
f826c44
296565c
b45719e
2443b18
cd6a2dc
a5e5df7
073fba6
82e86fb
bff4d1c
4e3c08e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,10 +20,10 @@ import history from '../../../../history'; | |
| import styles from './styles.module.scss'; | ||
| import { createRevenueDetailsUrl } from '../../../../util/siteMapConstants'; | ||
|
|
||
| const getColumns = (t, mobileView, totalAmount, quantityTotal, currencySymbol) => [ | ||
| const getColumns = (t, titleLabel, mobileView, totalAmount, currencySymbol) => [ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition to making the table general to both crops and animals by passing the column title, this PR removes the quantity sum and changes "DAILY TOTAL" --> "TOTAL" as discussed in dev-design.
Note: only the mobile view of this table is ever used in app (i.e. the footer is always defined by |
||
| { | ||
| id: 'title', | ||
| label: t('FINANCES.TRANSACTION.CROPS'), | ||
| label: t(titleLabel), | ||
| format: (d) => | ||
| mobileView ? ( | ||
| <div className={styles.mobileCrops}> | ||
|
|
@@ -38,7 +38,7 @@ const getColumns = (t, mobileView, totalAmount, quantityTotal, currencySymbol) = | |
| columnProps: { | ||
| style: { padding: `0 ${mobileView ? 8 : 12}px` }, | ||
| }, | ||
| Footer: mobileView ? null : t('FINANCES.TRANSACTION.DAILY_TOTAL'), | ||
| Footer: mobileView ? null : <div className={styles.uppercase}>{t('common:TOTAL')}</div>, | ||
| }, | ||
| { | ||
| id: mobileView ? null : 'quantity', | ||
|
|
@@ -48,7 +48,6 @@ const getColumns = (t, mobileView, totalAmount, quantityTotal, currencySymbol) = | |
| columnProps: { | ||
| style: { width: '100px' }, | ||
| }, | ||
| Footer: mobileView ? null : <div className={styles.bold}>{quantityTotal}</div>, | ||
| }, | ||
| { | ||
| id: 'amount', | ||
|
|
@@ -62,20 +61,16 @@ const getColumns = (t, mobileView, totalAmount, quantityTotal, currencySymbol) = | |
| }, | ||
| ]; | ||
|
|
||
| const FooterCell = ({ t, quantityTotal, totalAmount }) => ( | ||
| const FooterCell = ({ t, totalAmount }) => ( | ||
| <div className={styles.mobileCropSaleFooterCell}> | ||
| <div>{t('FINANCES.TRANSACTION.DAILY_TOTAL')}</div> | ||
| <div className={styles.bold}>{quantityTotal}</div> | ||
| <div className={styles.uppercase}>{t('common:TOTAL')}</div> | ||
| <div className={styles.bold}>{totalAmount}</div> | ||
| </div> | ||
| ); | ||
|
|
||
| export default function CropSaleTable({ data, currencySymbol, mobileView }) { | ||
| export default function EntitySaleTable({ data, currencySymbol, mobileView, titleLabel }) { | ||
| const { t } = useTranslation(); | ||
| const { items, amount, relatedId } = data; | ||
| const quantityUnit = items?.[0]?.quantityUnit; | ||
| const quantityTotal = items.reduce((total, { quantity }) => total + quantity, 0); | ||
| const quantityWithUnit = `${quantityTotal} ${quantityUnit}`; | ||
| const totalAmount = `${currencySymbol}${amount.toFixed(2)}`; | ||
|
|
||
| if (!items?.length) { | ||
|
|
@@ -85,15 +80,11 @@ export default function CropSaleTable({ data, currencySymbol, mobileView }) { | |
| return ( | ||
| <Table | ||
| kind={TableKind.V2} | ||
| columns={getColumns(t, mobileView, totalAmount, quantityWithUnit, currencySymbol)} | ||
| columns={getColumns(t, titleLabel, mobileView, totalAmount, currencySymbol)} | ||
| data={items} | ||
| minRows={10} | ||
| shouldFixTableLayout={true} | ||
| FooterCell={ | ||
| mobileView | ||
| ? () => <FooterCell t={t} totalAmount={totalAmount} quantityTotal={quantityWithUnit} /> | ||
| : null | ||
| } | ||
| FooterCell={mobileView ? () => <FooterCell t={t} totalAmount={totalAmount} /> : null} | ||
| onClickMore={() => history.push(createRevenueDetailsUrl(relatedId))} | ||
| /> | ||
| ); | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright 2026 LiteFarm.org | ||
| * This file is part of LiteFarm. | ||
| * | ||
| * LiteFarm is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * LiteFarm is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| import { Semibold } from '../../Typography'; | ||
| import SaleLineItem from './SaleLineItem'; | ||
| import styles from './styles.module.scss'; | ||
|
|
||
| interface AnimalSaleItemProps { | ||
| animalName: string; | ||
| entityId: string; | ||
| system: string; | ||
| currency: string; | ||
| fieldPrefix: string; | ||
| entityIdFieldKey: string; | ||
| disabledInput: boolean; | ||
| } | ||
|
|
||
| function AnimalSaleItem({ | ||
| animalName, | ||
| entityId, | ||
| system, | ||
| currency, | ||
| fieldPrefix, | ||
| entityIdFieldKey, | ||
| disabledInput, | ||
| }: AnimalSaleItemProps) { | ||
| return ( | ||
| <div className={styles.saleItemContainer}> | ||
| <div className={styles.saleItemInputGroup}> | ||
| <Semibold>{animalName}</Semibold> | ||
| <SaleLineItem | ||
| fieldPrefix={fieldPrefix} | ||
| entityId={entityId} | ||
| entityIdFieldKey={entityIdFieldKey} | ||
| system={system} | ||
| currency={currency} | ||
| disabledInput={disabledInput} | ||
| /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default AnimalSaleItem; |

Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change related to the Storybook crash, as described in the PR description.