@@ -13,7 +13,8 @@ import {
13
13
PREVIEW , PRINT , DATE , MASKED , ZERO , ISET , PAY_METHOD , defaultPrintSettings ,
14
14
} from '../../utils/constants'
15
15
import {
16
- getFromStorage , getPdf , getInvoiceSettings , printPDF , currency , groupBy , generateUuid4 ,
16
+ getFromStorage , getPdf , getInvoiceSettings , printPDF , currency ,
17
+ groupBy , generateUuid4 , getProducts ,
17
18
} from '../../utils/helper'
18
19
import Alert from '../Alert'
19
20
import HoverTotal from '../HoverTotal'
@@ -41,6 +42,7 @@ const Invoice = ({ showPdfPreview }) => {
41
42
42
43
const [ invoiceItems , setInvoiceItems ] = useState ( invoiceState . invoiceItems ?? [ ] )
43
44
const [ isInvoiceItemFormOpen , setIsInvoiceItemFormOpen ] = useState ( false )
45
+ const [ isGrossWeightNetWeight , setIsGrossWeightNetWeight ] = useState ( false )
44
46
45
47
const openInvoiceItemsPanel = useConstCallback ( ( ) => setIsInvoiceItemFormOpen ( true ) )
46
48
@@ -73,6 +75,7 @@ const Invoice = ({ showPdfPreview }) => {
73
75
oldPurchase : ZERO ,
74
76
grandTotal : ZERO ,
75
77
[ PAY_METHOD . CHEQUE ] : ZERO ,
78
+ [ PAY_METHOD . CREDIT ] : ZERO ,
76
79
[ PAY_METHOD . CARD ] : ZERO ,
77
80
[ PAY_METHOD . UPI ] : ZERO ,
78
81
[ PAY_METHOD . CASH ] : ZERO ,
@@ -160,7 +163,7 @@ const Invoice = ({ showPdfPreview }) => {
160
163
updatedInvoiceFooter = { ...invoiceFooter , ...change }
161
164
}
162
165
const {
163
- oldPurchase, grossTotal, cheque, card, upi, interState,
166
+ oldPurchase, grossTotal, cheque, card, upi, interState, credit ,
164
167
} = updatedInvoiceFooter
165
168
const calcSettings = getInvoiceSettings ( ISET . CALC )
166
169
const cgst = interState
@@ -178,7 +181,7 @@ const Invoice = ({ showPdfPreview }) => {
178
181
igst,
179
182
totalAmount,
180
183
grandTotal : currency ( totalAmount - oldPurchase ) ,
181
- cash : currency ( totalAmount - oldPurchase - card - cheque - upi ) ,
184
+ cash : currency ( totalAmount - oldPurchase - card - cheque - upi - credit ) ,
182
185
} )
183
186
}
184
187
@@ -221,6 +224,9 @@ const Invoice = ({ showPdfPreview }) => {
221
224
setInvoiceItems ( invoiceItems . map ( ( item , i ) => {
222
225
if ( i === index ) {
223
226
const newItem = { ...item , ...valueObject }
227
+ if ( valueObject . product && item . product !== valueObject . product ) {
228
+ newItem . price = getProducts ( newItem . product ) . price
229
+ }
224
230
if ( valueObject . isOldItem ) {
225
231
newItem . quantity = 1
226
232
newItem . product = null
@@ -484,6 +490,8 @@ const Invoice = ({ showPdfPreview }) => {
484
490
headerText = "Invoice item"
485
491
>
486
492
< InvoiceItems
493
+ isGrossWeightNetWeight = { isGrossWeightNetWeight }
494
+ setIsGrossWeightNetWeight = { setIsGrossWeightNetWeight }
487
495
invoiceItems = { invoiceItems }
488
496
currentInvoiceItemIndex = { currentInvoiceItemIndex }
489
497
currentInvoiceItem = { invoiceItems [ currentInvoiceItemIndex ] }
0 commit comments